screeps-client 0.14.2 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +15 -0
- package/dist/embedded/_client/BitmapFont-CSvcwLF6.js +1 -0
- package/dist/embedded/_client/CanvasRenderer-C8fadvww.js +1 -0
- package/dist/embedded/_client/CodePanel-CHPhho9S.js +1 -0
- package/dist/embedded/_client/MapRenderer-BV1i1L45.js +2 -0
- package/dist/embedded/_client/MapViewer-D3H3HyXS.js +1 -0
- package/dist/embedded/_client/SegmentsPanel-D5OVxC4l.js +1 -0
- package/dist/embedded/_client/WebGLRenderer-D2OqSm8-.js +1 -0
- package/dist/embedded/_client/WebGPURenderer-CmkVr8LV.js +1 -0
- package/dist/embedded/_client/browserAll-BDelQmvs.js +1 -0
- package/dist/embedded/_client/clientStore-X5fpw1Qu.js +2 -0
- package/dist/embedded/_client/index-DuoXyyYs.js +18 -0
- package/dist/embedded/_client/init-BDelQmvs.js +1 -0
- package/dist/embedded/_client/roomDataStore-0NPTJjQf.js +1 -0
- package/dist/embedded/_client/src-BwP2JcoP.js +1 -0
- package/dist/embedded/_client/src-TPXksuke.js +2 -0
- package/dist/embedded/_client/terrain.worker-DvfBTPFd.js +1 -0
- package/dist/embedded/_client/tsWorker-DQ-f6vFs.js +21516 -0
- package/dist/embedded/_client/vendor-codemirror-Brvxffeo.js +34 -0
- package/dist/embedded/_client/vendor-pixi-Dpe0vQ3d.js +1288 -0
- package/dist/embedded/_client/webworkerAll-BDelQmvs.js +1 -0
- package/dist/embedded/index.html +8 -7
- package/dist/standalone/_client/BitmapFont-BBjRoL3c.js +1 -0
- package/dist/standalone/_client/CanvasRenderer-BYojH-_X.js +1 -0
- package/dist/standalone/_client/CodePanel-CBW87mpY.js +1 -0
- package/dist/standalone/_client/MapRenderer-DwUceI5B.js +2 -0
- package/dist/standalone/_client/MapViewer-yvKKoBKD.js +1 -0
- package/dist/standalone/_client/SegmentsPanel-51YXJ_uE.js +1 -0
- package/dist/standalone/_client/WebGLRenderer-D8RARwFi.js +1 -0
- package/dist/standalone/_client/WebGPURenderer-D2xvqxan.js +1 -0
- package/dist/standalone/_client/browserAll-BdVNIoG3.js +1 -0
- package/dist/standalone/_client/{clientStore-Bzb-4S7X.js → clientStore-Ca6immKQ.js} +2 -2
- package/dist/standalone/_client/index-Evwic1P4.js +18 -0
- package/dist/standalone/_client/init-BdVNIoG3.js +1 -0
- package/dist/standalone/_client/roomDataStore-0NPTJjQf.js +1 -0
- package/dist/standalone/_client/src-CI80OTL8.js +1 -0
- package/dist/standalone/_client/src-XIy2kGvh.js +2 -0
- package/dist/standalone/_client/terrain.worker-DvfBTPFd.js +1 -0
- package/dist/standalone/_client/tsWorker-DQ-f6vFs.js +21516 -0
- package/dist/standalone/_client/vendor-codemirror-Brvxffeo.js +34 -0
- package/dist/standalone/_client/vendor-pixi-DZX0pYH2.js +1288 -0
- package/dist/standalone/_client/webworkerAll-BdVNIoG3.js +1 -0
- package/dist/standalone/index.html +8 -7
- package/dist/xxscreeps-mod/_client/BitmapFont-CGYTlWF8.js +1 -0
- package/dist/xxscreeps-mod/_client/CanvasRenderer-DGRKoMRH.js +1 -0
- package/dist/xxscreeps-mod/_client/CodePanel-C_J2c7-_.js +1 -0
- package/dist/xxscreeps-mod/_client/MapRenderer-uhzXgF31.js +2 -0
- package/dist/xxscreeps-mod/_client/MapViewer-Bz7VRhSO.js +1 -0
- package/dist/xxscreeps-mod/_client/SegmentsPanel-CXkBcnk_.js +1 -0
- package/dist/xxscreeps-mod/_client/WebGLRenderer-ClLMr3A6.js +1 -0
- package/dist/xxscreeps-mod/_client/WebGPURenderer-DbT82_xG.js +1 -0
- package/dist/xxscreeps-mod/_client/browserAll-BOeCZHnn.js +1 -0
- package/dist/xxscreeps-mod/_client/{clientStore-DjZCrEbe.js → clientStore-CBiEHyn3.js} +2 -2
- package/dist/xxscreeps-mod/_client/index-CqHCqMGH.js +18 -0
- package/dist/xxscreeps-mod/_client/init-BOeCZHnn.js +1 -0
- package/dist/xxscreeps-mod/_client/roomDataStore-0NPTJjQf.js +1 -0
- package/dist/xxscreeps-mod/_client/src-BUyiLFQu.js +1 -0
- package/dist/xxscreeps-mod/_client/src-CzyO7ux4.js +2 -0
- package/dist/xxscreeps-mod/_client/terrain.worker-DvfBTPFd.js +1 -0
- package/dist/xxscreeps-mod/_client/tsWorker-DQ-f6vFs.js +21516 -0
- package/dist/xxscreeps-mod/_client/vendor-codemirror-Brvxffeo.js +34 -0
- package/dist/xxscreeps-mod/_client/vendor-pixi-CuJeANCO.js +1288 -0
- package/dist/xxscreeps-mod/_client/webworkerAll-BOeCZHnn.js +1 -0
- package/dist/xxscreeps-mod/index.html +8 -7
- package/package.json +3 -4
- package/dist/embedded/_client/BitmapFont-U_ROfwu8.js +0 -1
- package/dist/embedded/_client/CanvasRenderer-DtLbK2mB.js +0 -1
- package/dist/embedded/_client/CodePanel-BCT5gOp2.js +0 -1
- package/dist/embedded/_client/MapRenderer-BhdM60pB.js +0 -2
- package/dist/embedded/_client/MapViewer-CDbIVsBg.js +0 -1
- package/dist/embedded/_client/WebGLRenderer-CfGNTiuB.js +0 -1
- package/dist/embedded/_client/WebGPURenderer-CpnQgcJa.js +0 -1
- package/dist/embedded/_client/browserAll-BkMwFmiF.js +0 -1
- package/dist/embedded/_client/clientStore-D9C-lzp_.js +0 -2
- package/dist/embedded/_client/index-5jkGDIrC.js +0 -18
- package/dist/embedded/_client/init-BkMwFmiF.js +0 -1
- package/dist/embedded/_client/src-DAkicyZU.js +0 -1
- package/dist/embedded/_client/src-cTbBCJWr.js +0 -2
- package/dist/embedded/_client/terrain.worker-t5M0-yfM.js +0 -1
- package/dist/embedded/_client/vendor-codemirror-B6f_i0wP.js +0 -34
- package/dist/embedded/_client/vendor-pixi-QLQyXP3g.js +0 -1288
- package/dist/embedded/_client/webworkerAll-BkMwFmiF.js +0 -1
- package/dist/standalone/_client/BitmapFont-BsssDqy9.js +0 -1
- package/dist/standalone/_client/CanvasRenderer-DbxFm52R.js +0 -1
- package/dist/standalone/_client/CodePanel-CbZ9oLxx.js +0 -1
- package/dist/standalone/_client/MapRenderer-ocYYDw6I.js +0 -2
- package/dist/standalone/_client/MapViewer-ohczy5X5.js +0 -1
- package/dist/standalone/_client/WebGLRenderer-5iU-As6_.js +0 -1
- package/dist/standalone/_client/WebGPURenderer-B_MDWjNH.js +0 -1
- package/dist/standalone/_client/browserAll-BdCrI7ma.js +0 -1
- package/dist/standalone/_client/index-D_Z0lV3_.js +0 -18
- package/dist/standalone/_client/init-BdCrI7ma.js +0 -1
- package/dist/standalone/_client/src-CjsOFhYA.js +0 -1
- package/dist/standalone/_client/src-mXm3a7Ed.js +0 -2
- package/dist/standalone/_client/terrain.worker-t5M0-yfM.js +0 -1
- package/dist/standalone/_client/vendor-codemirror-B6f_i0wP.js +0 -34
- package/dist/standalone/_client/vendor-pixi--3-husAV.js +0 -1288
- package/dist/standalone/_client/webworkerAll-BdCrI7ma.js +0 -1
- package/dist/xxscreeps-mod/_client/BitmapFont-D7v8IKws.js +0 -1
- package/dist/xxscreeps-mod/_client/CanvasRenderer-DAfPkj2a.js +0 -1
- package/dist/xxscreeps-mod/_client/CodePanel-kFIhDB_i.js +0 -1
- package/dist/xxscreeps-mod/_client/MapRenderer-C1QOWyVr.js +0 -2
- package/dist/xxscreeps-mod/_client/MapViewer-tK26tzGo.js +0 -1
- package/dist/xxscreeps-mod/_client/WebGLRenderer-LTYjuDRk.js +0 -1
- package/dist/xxscreeps-mod/_client/WebGPURenderer-CbhPWdU4.js +0 -1
- package/dist/xxscreeps-mod/_client/browserAll-DM4LfWqN.js +0 -1
- package/dist/xxscreeps-mod/_client/index-ViUlM-YN.js +0 -18
- package/dist/xxscreeps-mod/_client/init-DM4LfWqN.js +0 -1
- package/dist/xxscreeps-mod/_client/src-BxX_JHtm.js +0 -2
- package/dist/xxscreeps-mod/_client/src-lTglq1gg.js +0 -1
- package/dist/xxscreeps-mod/_client/terrain.worker-t5M0-yfM.js +0 -1
- package/dist/xxscreeps-mod/_client/vendor-codemirror-B6f_i0wP.js +0 -34
- package/dist/xxscreeps-mod/_client/vendor-pixi-xYYoQEpf.js +0 -1288
- package/dist/xxscreeps-mod/_client/webworkerAll-DM4LfWqN.js +0 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_client/CodePanel-CHPhho9S.js","_client/vendor-codemirror-Brvxffeo.js","_client/clientStore-X5fpw1Qu.js","_client/vendor-pixi-Dpe0vQ3d.js","_client/rolldown-runtime-Bh1tDfsg.js","_client/src-TPXksuke.js","_client/decompress-CWkNrR0q.js","_client/core-BpboMUoB.js","_client/SegmentsPanel-D5OVxC4l.js","_client/roomDataStore-0NPTJjQf.js","_client/MapViewer-D3H3HyXS.js","_client/MapRenderer-BV1i1L45.js","_client/init-BDelQmvs.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{A as e,B as t,C as n,D as r,E as i,F as a,I as o,M as s,N as c,O as l,P as u,R as d,S as f,T as p,_ as m,b as h,g,h as _,j as v,k as y,v as b,w as x,x as S,y as C,z as w}from"./vendor-codemirror-Brvxffeo.js";import{$ as T,A as E,B as D,C as O,D as k,E as A,F as ee,G as j,H as M,I as te,J as ne,K as re,L as ie,M as ae,N as oe,O as N,P as se,Q as P,R as ce,S as le,T as ue,U as de,V as fe,W as pe,X as me,Y as he,Z as ge,_ as _e,a as ve,at as F,b as ye,c as be,d as xe,et as I,f as Se,h as Ce,i as we,it as Te,j as Ee,k as De,l as Oe,m as ke,n as L,nt as R,o as Ae,ot as z,p as je,q as Me,r as Ne,rt as B,s as V,st as Pe,t as Fe,tt as Ie,u as Le,v as Re,w as ze,x as H,y as Be,z as Ve}from"./clientStore-X5fpw1Qu.js";import{_ as He,a as Ue,b as We,c as Ge,d as Ke,f as qe,g as Je,h as Ye,l as U,m as Xe,o as Ze,p as Qe,u as $e,v as et,x as tt,y as nt}from"./vendor-pixi-Dpe0vQ3d.js";import{a as rt,c as it,d as at,g as ot,h as st,i as ct,k as lt,l as ut,m as dt,n as ft,o as pt,p as mt,s as ht,t as gt,u as _t}from"./src-TPXksuke.js";import{$ as vt,A as yt,At as bt,B as xt,Bt as St,C as Ct,Ct as wt,D as Tt,Dt as W,E as Et,Et as Dt,F as Ot,Ft as kt,G as At,H as jt,I as Mt,It as Nt,J as Pt,K as Ft,L as It,Lt,M as Rt,Mt as zt,N as Bt,Nt as Vt,O as Ht,Ot as Ut,P as Wt,Pt as Gt,Q as Kt,R as qt,Rt as Jt,S as Yt,T as Xt,Tt as Zt,U as Qt,V as $t,W as en,X as tn,Y as nn,Z as rn,_ as an,_t as on,a as sn,at as cn,b as ln,bt as un,c as dn,ct as fn,d as pn,dt as mn,et as hn,f as gn,ft as _n,g as vn,gt as yn,h as bn,ht as xn,i as Sn,it as Cn,j as wn,jt as Tn,k as En,kt as Dn,l as On,lt as kn,m as An,mt as jn,n as Mn,nt as Nn,o as Pn,ot as Fn,p as In,pt as Ln,q as Rn,r as zn,rt as Bn,s as Vn,st as Hn,tt as Un,u as Wn,ut as Gn,vt as Kn,w as qn,wt as Jn,x as Yn,yt as Xn,z as Zn}from"./MapRenderer-BV1i1L45.js";import{_ as Qn,a as $n,c as er,d as tr,f as nr,g as rr,h as ir,i as ar,l as or,m as sr,n as cr,o as lr,p as ur,r as dr,s as fr,t as pr,u as mr,v as hr}from"./roomDataStore-0NPTJjQf.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var gr={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`},_r=x({size:24,color:`currentColor`,strokeWidth:2,absoluteStrokeWidth:!1,class:``}),vr=z(`<svg>`),yr=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},br=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),xr=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),Sr=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),Cr=e=>{let t=xr(e);return t.charAt(0).toUpperCase()+t.slice(1)},G=e=>{let[r,i]=d(e,[`color`,`size`,`strokeWidth`,`children`,`class`,`name`,`iconNode`,`absoluteStrokeWidth`]),a=t(_r);return(()=>{var e=vr();return Te(e,c(gr,{get width(){return r.size??a.size??gr.width},get height(){return r.size??a.size??gr.height},get stroke(){return r.color??a.color??gr.stroke},get"stroke-width"(){return I(()=>(r.absoluteStrokeWidth??a.absoluteStrokeWidth)===!0)()?Number(r.strokeWidth??a.strokeWidth??gr[`stroke-width`])*24/Number(r.size??a.size):Number(r.strokeWidth??a.strokeWidth??gr[`stroke-width`])},get class(){return br(`lucide`,`lucide-icon`,a.class,...r.name==null?[]:[`lucide-${Sr(Cr(r.name))}`,`lucide-${Sr(r.name)}`],r.class)},get"aria-hidden"(){return!r.children&&!yr(i)?`true`:void 0}},i),!0,!0),T(e,n(b,{get each(){return r.iconNode},children:([e,t])=>n(me,c({component:e},t))})),e})()},wr=[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]],Tr=e=>n(G,c(e,{iconNode:wr,name:`arrow-left-right`})),Er=[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`path`,{d:`M20.2 20.2c2.04-2.03.02-7.36-4.5-11.9-4.54-4.52-9.87-6.54-11.9-4.5-2.04 2.03-.02 7.36 4.5 11.9 4.54 4.52 9.87 6.54 11.9 4.5Z`,key:`1l2ple`}],[`path`,{d:`M15.7 15.7c4.52-4.54 6.54-9.87 4.5-11.9-2.03-2.04-7.36-.02-11.9 4.5-4.52 4.54-6.54 9.87-4.5 11.9 2.03 2.04 7.36.02 11.9-4.5Z`,key:`1wam0m`}]],Dr=e=>n(G,c(e,{iconNode:Er,name:`atom`})),Or=[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]],kr=e=>n(G,c(e,{iconNode:Or,name:`ban`})),Ar=[[`path`,{d:`m11 7-3 5h4l-3 5`,key:`b4a64w`}],[`path`,{d:`M14.856 6H16a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.935`,key:`lre1cr`}],[`path`,{d:`M22 14v-4`,key:`14q9d5`}],[`path`,{d:`M5.14 18H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2.936`,key:`13q5k0`}]],jr=e=>n(G,c(e,{iconNode:Ar,name:`battery-charging`})),Mr=[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]],Nr=e=>n(G,c(e,{iconNode:Mr,name:`bell-off`})),Pr=[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]],Fr=e=>n(G,c(e,{iconNode:Pr,name:`bell`})),Ir=[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]],Lr=e=>n(G,c(e,{iconNode:Ir,name:`chart-column`})),Rr=[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]],zr=e=>n(G,c(e,{iconNode:Rr,name:`check`})),Br=[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]],Vr=e=>n(G,c(e,{iconNode:Br,name:`chevron-down`})),Hr=[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]],Ur=e=>n(G,c(e,{iconNode:Hr,name:`chevron-left`})),Wr=[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]],Gr=e=>n(G,c(e,{iconNode:Wr,name:`chevron-right`})),Kr=[[`path`,{d:`m11 17-5-5 5-5`,key:`13zhaf`}],[`path`,{d:`m18 17-5-5 5-5`,key:`h8a8et`}]],qr=e=>n(G,c(e,{iconNode:Kr,name:`chevrons-left`})),Jr=[[`path`,{d:`m6 17 5-5-5-5`,key:`xnjwq`}],[`path`,{d:`m13 17 5-5-5-5`,key:`17xmmf`}]],Yr=e=>n(G,c(e,{iconNode:Jr,name:`chevrons-right`})),Xr=[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]],Zr=e=>n(G,c(e,{iconNode:Xr,name:`circle-slash`})),Qr=[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]],$r=e=>n(G,c(e,{iconNode:Qr,name:`clock`})),ei=[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]],ti=e=>n(G,c(e,{iconNode:ei,name:`code-xml`})),ni=[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`22`,x2:`18`,y1:`12`,y2:`12`,key:`l9bcsi`}],[`line`,{x1:`6`,x2:`2`,y1:`12`,y2:`12`,key:`13hhkx`}],[`line`,{x1:`12`,x2:`12`,y1:`6`,y2:`2`,key:`10w3f3`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`18`,key:`15g9kq`}]],ri=e=>n(G,c(e,{iconNode:ni,name:`crosshair`})),ii=[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]],ai=e=>n(G,c(e,{iconNode:ii,name:`database`})),oi=[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]],si=e=>n(G,c(e,{iconNode:oi,name:`external-link`})),ci=[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M16 16h.01`,key:`1f9h7w`}],[`path`,{d:`M3 19a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8.5a.5.5 0 0 0-.769-.422l-4.462 2.844A.5.5 0 0 1 15 10.5v-2a.5.5 0 0 0-.769-.422L9.77 10.922A.5.5 0 0 1 9 10.5V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z`,key:`1iv0i2`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]],li=e=>n(G,c(e,{iconNode:ci,name:`factory`})),ui=[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]],di=e=>n(G,c(e,{iconNode:ui,name:`eye`})),fi=[[`path`,{d:`M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528`,key:`1jaruq`}]],pi=e=>n(G,c(e,{iconNode:fi,name:`flag`})),mi=[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]],hi=e=>n(G,c(e,{iconNode:mi,name:`flask-conical`})),gi=[[`path`,{d:`M10.5 3 8 9l4 13 4-13-2.5-6`,key:`b3dvk1`}],[`path`,{d:`M17 3a2 2 0 0 1 1.6.8l3 4a2 2 0 0 1 .013 2.382l-7.99 10.986a2 2 0 0 1-3.247 0l-7.99-10.986A2 2 0 0 1 2.4 7.8l2.998-3.997A2 2 0 0 1 7 3z`,key:`7w4byz`}],[`path`,{d:`M2 9h20`,key:`16fsjt`}]],_i=e=>n(G,c(e,{iconNode:gi,name:`gem`})),vi=[[`path`,{d:`m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9`,key:`1hayfq`}],[`path`,{d:`m18 15 4-4`,key:`16gjal`}],[`path`,{d:`m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5`,key:`15ts47`}]],yi=e=>n(G,c(e,{iconNode:vi,name:`hammer`})),bi=[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]],xi=e=>n(G,c(e,{iconNode:bi,name:`key-round`})),Si=[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]],Ci=e=>n(G,c(e,{iconNode:Si,name:`layout-dashboard`})),wi=[[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m16.2 7.8 2.9-2.9`,key:`r700ao`}],[`path`,{d:`M18 12h4`,key:`wj9ykh`}],[`path`,{d:`m16.2 16.2 2.9 2.9`,key:`1bxg5t`}],[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`m4.9 19.1 2.9-2.9`,key:`bwix9q`}],[`path`,{d:`M2 12h4`,key:`j09sii`}],[`path`,{d:`m4.9 4.9 2.9 2.9`,key:`giyufr`}]],Ti=e=>n(G,c(e,{iconNode:wi,name:`loader`})),Ei=[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]],Di=e=>n(G,c(e,{iconNode:Ei,name:`lock`})),Oi=[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]],ki=e=>n(G,c(e,{iconNode:Oi,name:`log-in`})),Ai=[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]],ji=e=>n(G,c(e,{iconNode:Ai,name:`log-out`})),Mi=[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]],Ni=e=>n(G,c(e,{iconNode:Mi,name:`mail`})),Pi=[[`path`,{d:`M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z`,key:`169xi5`}],[`path`,{d:`M15 5.764v15`,key:`1pn4in`}],[`path`,{d:`M9 3.236v15`,key:`1uimfh`}]],Fi=e=>n(G,c(e,{iconNode:Pi,name:`map`})),Ii=[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`m15 19-3 3-3-3`,key:`11eu04`}],[`path`,{d:`m19 9 3 3-3 3`,key:`1mg7y2`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}],[`path`,{d:`m5 9-3 3 3 3`,key:`j64kie`}],[`path`,{d:`m9 5 3-3 3 3`,key:`l8vdw6`}]],Li=e=>n(G,c(e,{iconNode:Ii,name:`move`})),Ri=[[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`path`,{d:`m16.5 14.5 5 5`,key:`ozpm51`}],[`path`,{d:`m16.5 19.5 5-5`,key:`syf6b9`}],[`path`,{d:`M21 10.5V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.729l7 4a2 2 0 0 0 2 .001l.13-.074`,key:`isw6gs`}],[`path`,{d:`M3.29 7 12 12l8.71-5`,key:`19ckod`}],[`path`,{d:`m7.5 4.27 8.997 5.148`,key:`9yrvtv`}]],zi=e=>n(G,c(e,{iconNode:Ri,name:`package-x`})),Bi=[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]],Vi=e=>n(G,c(e,{iconNode:Bi,name:`pause`})),Hi=[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]],Ui=e=>n(G,c(e,{iconNode:Hi,name:`pencil`})),Wi=[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]],Gi=e=>n(G,c(e,{iconNode:Wi,name:`play`})),Ki=[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]],qi=e=>n(G,c(e,{iconNode:Ki,name:`plus`})),Ji=[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]],Yi=e=>n(G,c(e,{iconNode:Ji,name:`refresh-cw`})),Xi=[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]],Zi=e=>n(G,c(e,{iconNode:Xi,name:`rocket`})),Qi=[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]],$i=e=>n(G,c(e,{iconNode:Qi,name:`rotate-ccw`})),ea=[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]],ta=e=>n(G,c(e,{iconNode:ea,name:`send`})),na=[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]],ra=e=>n(G,c(e,{iconNode:na,name:`settings`})),ia=[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]],aa=e=>n(G,c(e,{iconNode:ia,name:`shield-check`})),oa=[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]],sa=e=>n(G,c(e,{iconNode:oa,name:`shield`})),ca=[[`path`,{d:`M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5`,key:`slp6dd`}],[`path`,{d:`M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244`,key:`o0xfot`}],[`path`,{d:`M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05`,key:`wn3emo`}]],la=e=>n(G,c(e,{iconNode:ca,name:`store`})),ua=[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]],da=e=>n(G,c(e,{iconNode:ua,name:`sun`})),fa=[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]],pa=e=>n(G,c(e,{iconNode:fa,name:`terminal`})),ma=[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],ha=e=>n(G,c(e,{iconNode:ma,name:`trash-2`})),ga=[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]],_a=e=>n(G,c(e,{iconNode:ga,name:`trending-up`})),va=[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]],ya=e=>n(G,c(e,{iconNode:va,name:`x`})),ba=[[`path`,{d:`M10.513 4.856 13.12 2.17a.5.5 0 0 1 .86.46l-1.377 4.317`,key:`193nxd`}],[`path`,{d:`M15.656 10H20a1 1 0 0 1 .78 1.63l-1.72 1.773`,key:`27a7lr`}],[`path`,{d:`M16.273 16.273 10.88 21.83a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14H4a1 1 0 0 1-.78-1.63l4.507-4.643`,key:`1e0qe9`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]],xa=e=>n(G,c(e,{iconNode:ba,name:`zap-off`})),Sa=[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]],Ca=e=>n(G,c(e,{iconNode:Sa,name:`zap`}));function wa(t,n){let[r,i]=e(null),[o,s]=e(!1),[c,l]=e(null),u=async(e,t)=>{try{(await ht(e,t))?.username?n({url:e,token:t}):(l(null),i({url:e,token:t}))}catch{n({url:e,token:t})}};return{startLogin:e=>{let n=e.replace(/\/$/,``),r=window.open(`${n}/api/auth/${t}`,`screeps-oauth-${t}`,`width=800,height=600,left=200,top=100`),i=e=>{try{let t=JSON.parse(e.data);t.token&&(s(),u(n,t.token))}catch{}},o=setInterval(()=>{r?.closed&&s()},500),s=()=>{clearInterval(o),window.removeEventListener(`message`,i)};window.addEventListener(`message`,i),a(s)},pending:r,submitting:o,regError:c,completeRegistration:async(e,t)=>{let a=r();if(a){s(!0),l(null);try{let{token:r}=await pt(a.url,a.token,e,t);i(null),n({url:a.url,token:r})}catch(e){l(e instanceof Error?e.message:`Registration failed`)}finally{s(!1)}}},cancelRegistration:()=>{i(null),l(null)}}}function Ta(t){let[n,r]=e(null),[i,o]=e(null),[s,c]=e(null);return p(()=>{let e=t();r(null),o(null),c(null);let n=!1,i=setTimeout(async()=>{try{let t=await ut(e);if(n)return;if(r(t),c(null),at(t)){let t=await it(e);n||o(t)}}catch{n||(c(`Could not reach server`),r(null))}},400);a(()=>{n=!0,clearTimeout(i)})}),{serverVersion:n,authModInfo:i,serverError:s}}var Ea=z(`<span style=font-size:11px;display:inline-flex;align-items:center;gap:3px>`),Da=z(`<form style=display:flex;flex-direction:column;gap:16px><h2 style=margin:0;font-size:20px>Finish creating your account</h2><div style=font-size:13px;color:#8b949e>Signed in with <!> — choose a username to finish setting up your account.</div><label style=display:flex;flex-direction:column;gap:4px><div style=display:flex;align-items:baseline;gap:8px><span style=font-size:12px;color:#8b949e>Username</span></div><input type=text name=username autocomplete=username autofocus></label><label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Email <span style=color:#484f58>(optional)</span></span><input type=email name=email autocomplete=email></label><button type=submit style=padding:10px;border-radius:6px;border:none;background:#238636;color:#fff;font-weight:600></button><button type=button style="padding:8px;border-radius:6px;border:1px solid #30363d;background:transparent;color:#8b949e;font-size:12px;cursor:pointer">Cancel`),Oa=z(`<div style=color:#f85149;font-size:13px>`),ka={padding:`8px 12px`,"border-radius":`6px`,border:`1px solid #30363d`,background:`#0d1117`,color:`#c9d1d9`,width:`100%`,"box-sizing":`border-box`};function Aa(t,n){let[r,i]=e(`idle`);return p(()=>{let e=n();if(!e){i(`idle`);return}i(`checking`);let r=!1,o=setTimeout(async()=>{try{let n=await rt(t(),e);r||i(n.error?`taken`:`available`)}catch{r||i(`error`)}},500);a(()=>{r=!0,clearTimeout(o)})}),r}function ja(e){let t={idle:null,checking:{children:`Checking…`,color:`#8b949e`},available:{children:[n(zr,{size:12}),` Available`],color:`#3fb950`},taken:{children:[n(ya,{size:12}),` Already taken`],color:`#f85149`},error:{children:`Could not verify`,color:`#d29922`}},i=()=>t[e.state];return n(h,{get when(){return i()},get children(){var e=Ea();return T(e,()=>i().children),r(t=>B(e,`color`,i().color)),e}})}function Ma(t){let[i,a]=e(``),[o,s]=e(``),c=Aa(()=>t.url,i),l=()=>!t.submitting&&i()!==``&&c()!==`taken`&&c()!==`checking`,u=e=>{e.preventDefault(),l()&&t.onSubmit(i(),o()||void 0)};return(()=>{var e=Da(),d=e.firstChild.nextSibling,f=d.firstChild.nextSibling;f.nextSibling;var p=d.nextSibling,m=p.firstChild;m.firstChild;var h=m.nextSibling,g=p.nextSibling,_=g.firstChild;_.firstChild.nextSibling;var v=_.nextSibling,y=g.nextSibling,b=y.nextSibling;return e.addEventListener(`submit`,u),T(d,()=>t.providerLabel,f),T(m,n(ja,{get state(){return c()}}),null),h.$$input=e=>a(e.currentTarget.value),v.$$input=e=>s(e.currentTarget.value),T(e,(()=>{var e=I(()=>!!t.error);return()=>e()&&(()=>{var e=Oa();return T(e,()=>t.error),e})()})(),y),T(y,()=>t.submitting?`Creating account…`:`Continue`),b.$$click=()=>t.onCancel(),r(e=>{var n=ka,r=t.submitting,i=ka,a=t.submitting,o=!l(),s=l()?`pointer`:`not-allowed`,c=l()?1:.5;return e.e=F(h,n,e.e),r!==e.t&&(h.disabled=e.t=r),e.a=F(v,i,e.a),a!==e.o&&(v.disabled=e.o=a),o!==e.i&&(y.disabled=e.i=o),s!==e.n&&B(y,`cursor`,e.n=s),c!==e.s&&B(y,`opacity`,e.s=c),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),r(()=>h.value=i()),r(()=>v.value=o()),e})()}P([`input`,`click`]);var Na=z(`<span style=font-size:11px;display:inline-flex;align-items:center;gap:3px>`),Pa=z(`<div style="color:#3fb950;font-size:14px;text-align:center;padding:8px 0">Account created! Logging you in…`),Fa=z(`<label style=display:flex;flex-direction:column;gap:4px><div style=display:flex;align-items:baseline;gap:8px><span style=font-size:12px;color:#8b949e>Username</span></div><input type=text name=username autocomplete=username>`),Ia=z(`<label style=display:flex;flex-direction:column;gap:4px><div style=display:flex;align-items:baseline;gap:8px><span style=font-size:12px;color:#8b949e>Email</span></div><input type=email name=email autocomplete=email>`),La=z(`<label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Password</span><input type=password name=new-password autocomplete=new-password>`),Ra=z(`<span style=font-size:11px;color:#f85149>Passwords don't match`),za=z(`<label style=display:flex;flex-direction:column;gap:4px><div style=display:flex;align-items:baseline;gap:8px><span style=font-size:12px;color:#8b949e>Confirm Password</span></div><input type=password name=confirm-password autocomplete=new-password>`),Ba=z(`<button type=submit style=padding:10px;border-radius:6px;border:none;background:#238636;color:#fff;font-weight:600>`),Va=z(`<button type=button style="padding:8px;border-radius:6px;border:1px solid #30363d;background:transparent;color:#8b949e;font-size:12px;cursor:pointer">Back to Login`),Ha=z(`<form style=display:flex;flex-direction:column;gap:16px><h2 style=margin:0;font-size:20px>Create Account`),Ua=z(`<div style=color:#f85149;font-size:13px>`),Wa=z(`<div style="width:360px;padding:16px 20px;border-radius:8px;background:#161b22;border:1px solid #30363d;color:#c9d1d9;font-size:13px;line-height:1.6">`),Ga=z(`<button type=button style=background:none;border:none;color:#58a6ff;font-size:12px;cursor:pointer;padding:0>Create account`),Ka=z(`<div style=display:flex;gap:8px><button type=button style="flex:1;padding:8px;border-radius:6px;border:1px solid #30363d;color:#fff;cursor:pointer">Password</button><button type=button style="flex:1;padding:8px;border-radius:6px;border:1px solid #30363d;color:#fff;cursor:pointer">Token`),qa=z(`<label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Server URL</span><input type=url name=url autocomplete=url inputmode=url>`),Ja=z(`<div style=color:#8b949e;font-size:12px;margin-top:-8px>`),Ya=z(`<label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Server Password <span style=color:#484f58>(optional)</span></span><input type=password name=server-password autocomplete=off data-1p-ignore data-lpignore=true placeholder="Leave empty if not required">`),Xa=z(`<div style=display:flex;align-items:center;gap:8px;color:#484f58;font-size:12px><div style=flex:1;height:1px;background:#30363d></div>or<div style=flex:1;height:1px;background:#30363d>`),Za=z(`<button type=button style=padding:10px;border-radius:6px;border:none;background:#1b2838;color:#c7d5e0;font-weight:600>Login with Steam`),Qa=z(`<button type=button style=padding:10px;border-radius:6px;border:none;background:#5865F2;color:#fff;font-weight:600>Login with Discord`),$a=z(`<button type=button style="padding:8px;border-radius:6px;border:1px solid #30363d;background:transparent;color:#8b949e;font-size:12px">Connect as Guest (read-only)`),eo=z(`<form style=display:flex;flex-direction:column;gap:16px><div style=display:flex;align-items:baseline;justify-content:space-between><h2 style=margin:0;font-size:20px>Connect to Screeps</h2></div><button type=submit style=padding:10px;border-radius:6px;border:none;background:#238636;color:#fff;font-weight:600>`),to=z(`<div style="width:360px;padding:12px 20px;border-radius:8px;background:#161b22;border:1px solid #30363d"><div style=font-size:11px;color:#484f58;margin-bottom:8px;text-transform:uppercase;letter-spacing:0.05em>Server Mods</div><div style=display:flex;flex-wrap:wrap;gap:6px>`),no=z(`<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px;width:100%;height:100%;overflow:auto;padding:24px 0;box-sizing:border-box"><div style="display:flex;flex-direction:column;gap:16px;width:360px;padding:32px;border-radius:8px;background:#161b22;border:1px solid #30363d">`),ro=z(`<label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Email or Username</span><input type=text id=username name=username autocomplete=username>`),io=z(`<label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Password</span><input type=password id=password name=password autocomplete=current-password>`),ao=z(`<label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Auth Token</span><input type=password name=token autocomplete=off>`),oo=z(`<span style="font-size:11px;padding:2px 8px;border-radius:12px;background:#21262d;border:1px solid #30363d;color:#8b949e;font-family:monospace">`),so={padding:`8px 12px`,"border-radius":`6px`,border:`1px solid #30363d`,background:`#0d1117`,color:`#c9d1d9`};function co(t,n,r){let[i,o]=e(`idle`);return p(()=>{let e=n();if(!e){o(`idle`);return}o(`checking`);let i=!1,s=setTimeout(async()=>{try{let n=await r(t(),e);i||o(n.error?`taken`:`available`)}catch{i||o(`error`)}},500);a(()=>{i=!0,clearTimeout(s)})}),i}function lo(e){let t={idle:null,checking:{children:`Checking…`,color:`#8b949e`},available:{children:[n(zr,{size:12}),` Available`],color:`#3fb950`},taken:{children:[n(ya,{size:12}),` Already taken`],color:`#f85149`},error:{children:`Could not verify`,color:`#d29922`}},i=()=>t[e.state];return n(h,{get when(){return i()},get children(){var e=Na();return T(e,()=>i().children),r(t=>B(e,`color`,i().color)),e}})}function uo(t){let[i,a]=e(``),[o,s]=e(``),[c,l]=e(``),[u,d]=e(``),[f,p]=e(!1),[m,g]=e(null),[_,v]=e(!1),y=co(()=>t.url,i,rt),b=co(()=>t.url,o,ct),x=()=>u()!==``&&c()!==u(),S=()=>!f()&&i()!==``&&o()!==``&&c().length>=4&&c()===u()&&y()!==`taken`&&y()!==`checking`&&b()!==`taken`&&b()!==`checking`,C=async e=>{if(e.preventDefault(),S()){p(!0),g(null);try{let e=await st(t.url,i(),o(),c());if(e.error){g(e.error);return}v(!0),setTimeout(()=>t.onSuccess(o(),c()),1500)}catch(e){g(e instanceof Error?e.message:`Registration failed`)}finally{p(!1)}}};return(()=>{var e=Ha();return e.firstChild,e.addEventListener(`submit`,C),T(e,n(h,{get when(){return _()},get children(){return Pa()}}),null),T(e,n(h,{get when(){return!_()},get children(){return[(()=>{var e=Fa(),t=e.firstChild;t.firstChild;var o=t.nextSibling;return T(t,n(lo,{get state(){return y()}}),null),o.$$input=e=>a(e.currentTarget.value),r(e=>{var t=so,n=f();return e.e=F(o,t,e.e),n!==e.t&&(o.disabled=e.t=n),e},{e:void 0,t:void 0}),r(()=>o.value=i()),e})(),(()=>{var e=Ia(),t=e.firstChild;t.firstChild;var i=t.nextSibling;return T(t,n(lo,{get state(){return b()}}),null),i.$$input=e=>s(e.currentTarget.value),r(e=>{var t=so,n=f();return e.e=F(i,t,e.e),n!==e.t&&(i.disabled=e.t=n),e},{e:void 0,t:void 0}),r(()=>i.value=o()),e})(),(()=>{var e=La(),t=e.firstChild.nextSibling;return t.$$input=e=>l(e.currentTarget.value),r(e=>{var n=so,r=f();return e.e=F(t,n,e.e),r!==e.t&&(t.disabled=e.t=r),e},{e:void 0,t:void 0}),r(()=>t.value=c()),e})(),(()=>{var e=za(),t=e.firstChild;t.firstChild;var i=t.nextSibling;return T(t,n(h,{get when(){return x()},get children(){return Ra()}}),null),i.$$input=e=>d(e.currentTarget.value),r(e=>{var t={...so,border:x()?`1px solid #f85149`:`1px solid #30363d`},n=f();return e.e=F(i,t,e.e),n!==e.t&&(i.disabled=e.t=n),e},{e:void 0,t:void 0}),r(()=>i.value=u()),e})(),I(()=>I(()=>!!m())()&&(()=>{var e=Ua();return T(e,m),e})()),(()=>{var e=Ba();return T(e,()=>f()?`Creating account…`:`Create Account`),r(t=>{var n=!S(),r=S()?`pointer`:`not-allowed`,i=S()?1:.5;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&B(e,`cursor`,t.t=r),i!==t.a&&B(e,`opacity`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e})(),(()=>{var e=Va();return e.$$click=()=>t.onCancel(),e})()]}}),null),e})()}function fo(){let t=de(),i=pe(),[a,o]=e(`login`),[s,c]=e(`password`),[l,u]=e(t?M():window.location.origin),[d,f]=e(``),[m,g]=e(``),[_,v]=e(``),[y,x]=e(``),{serverVersion:S,authModInfo:C,serverError:w}=Ta(l),E=()=>S()?.serverData?.welcomeText??null,D=()=>(S()?.serverData?.features??[]).filter(e=>e.name!==`auth`&&e.version!=null),O=()=>{let e=S();return e?mt(e):void 0},k=()=>{let e=O();if(e)return e.steamLogin;let t=S();return t?at(t)?.authTypes?.includes(`steam`)??!0:!0},A=()=>{let e=S();return e?_t(e)?.discordLogin??!1:!1},ee=()=>{let e=O();return e?e.allowEmailRegistration:C()?.allowRegistration===!0||(S()?.serverData?.features??[]).some(e=>e.name===`official-like`)},j=()=>O()?.allowGuestAccess??!0,te=()=>{let e=S();return e?!dt(e):!0},ne=wa(`steam`,({url:e,token:t})=>{o(`login`),Ne({url:e,auth:`token`,authMethod:`steam`,token:t,serverPassword:y()||void 0,storage:null})});p(()=>{ne.pending()&&o(`steam-username`)});let re=()=>ne.startLogin(l()),ie=wa(`discord`,({url:e,token:t})=>{o(`login`),Ne({url:e,auth:`token`,authMethod:`discord`,token:t,serverPassword:y()||void 0,storage:null})});p(()=>{ie.pending()&&o(`discord-username`)});let ae=()=>ie.startLogin(l()),oe=async e=>{e.preventDefault(),await Ne({url:l(),auth:s(),email:d()||void 0,password:m()||void 0,token:_()||void 0,serverPassword:y()||void 0,storage:null})},N=async e=>{e.preventDefault(),await Ne({url:l(),auth:`guest`,serverPassword:y()||void 0,storage:null})},se=async(e,t)=>{try{await Ne({url:l(),auth:`password`,email:e,password:t,serverPassword:y()||void 0,storage:null})}catch{o(`login`),c(`password`),f(e),g(t)}},P=()=>_e()===`connecting`;return(()=>{var e=no(),p=e.firstChild;return T(e,n(h,{get when(){return E()},get children(){var e=Wa();return r(()=>e.innerHTML=E()),e}}),p),T(p,n(h,{get when(){return a()===`register`},get children(){return n(uo,{get url(){return l()},get serverPassword(){return y()},onSuccess:se,onCancel:()=>o(`login`)})}}),null),T(p,n(h,{get when(){return a()===`steam-username`},get children(){return n(Ma,{get url(){return ne.pending().url},providerLabel:`Steam`,get submitting(){return ne.submitting()},get error(){return ne.regError()},onSubmit:(e,t)=>void ne.completeRegistration(e,t),onCancel:()=>{ne.cancelRegistration(),o(`login`)}})}}),null),T(p,n(h,{get when(){return a()===`discord-username`},get children(){return n(Ma,{get url(){return ie.pending().url},providerLabel:`Discord`,get submitting(){return ie.submitting()},get error(){return ie.regError()},onSubmit:(e,t)=>void ie.completeRegistration(e,t),onCancel:()=>{ie.cancelRegistration(),o(`login`)}})}}),null),T(p,n(h,{get when(){return a()===`login`},get children(){var e=eo(),a=e.firstChild;a.firstChild;var p=a.nextSibling;return e.addEventListener(`submit`,oe),T(a,n(h,{get when(){return ee()},get children(){var e=Ga();return e.$$click=()=>o(`register`),e}}),null),T(e,n(h,{when:!t,get children(){var e=Ka(),t=e.firstChild,n=t.nextSibling;return t.$$click=()=>c(`password`),n.$$click=()=>c(`token`),r(e=>{var r=s()===`password`?`#238636`:`transparent`,i=s()===`token`?`#238636`:`transparent`;return r!==e.e&&B(t,`background`,e.e=r),i!==e.t&&B(n,`background`,e.t=i),e},{e:void 0,t:void 0}),e}}),p),T(e,n(h,{when:!t,get children(){return[(()=>{var e=qa(),t=e.firstChild.nextSibling;return t.$$input=e=>u(e.currentTarget.value),r(e=>F(t,so,e)),r(()=>t.value=l()),e})(),n(h,{get when(){return w()},get children(){var e=Ja();return T(e,w),e}})]}}),p),T(e,(()=>{var e=I(()=>s()===`password`);return()=>e()?[(()=>{var e=ro(),t=e.firstChild.nextSibling;return t.$$input=e=>f(e.currentTarget.value),r(e=>F(t,so,e)),r(()=>t.value=d()),e})(),(()=>{var e=io(),t=e.firstChild.nextSibling;return t.$$input=e=>g(e.currentTarget.value),r(e=>F(t,so,e)),r(()=>t.value=m()),e})()]:(()=>{var e=ao(),t=e.firstChild.nextSibling;return t.$$input=e=>v(e.currentTarget.value),r(e=>F(t,so,e)),r(()=>t.value=_()),e})()})(),p),T(e,n(h,{get when(){return te()},get children(){var e=Ya(),t=e.firstChild;t.firstChild.nextSibling;var n=t.nextSibling;return n.$$input=e=>x(e.currentTarget.value),r(e=>F(n,so,e)),r(()=>n.value=y()),e}}),p),T(e,(()=>{var e=I(()=>!!ve());return()=>e()&&(()=>{var e=Ua();return T(e,ve),e})()})(),p),T(p,()=>P()?`Connecting…`:`Connect`),T(e,n(h,{get when(){return k()||A()},get children(){var e=Xa();return e.firstChild.nextSibling.nextSibling,e}}),null),T(e,n(h,{get when(){return k()},get children(){var e=Za();return e.$$click=re,r(t=>{var n=P(),r=P()?`not-allowed`:`pointer`,i=P()?.6:1;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&B(e,`cursor`,t.t=r),i!==t.a&&B(e,`opacity`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e}}),null),T(e,n(h,{get when(){return A()},get children(){var e=Qa();return e.$$click=ae,r(t=>{var n=P(),r=P()?`not-allowed`:`pointer`,i=P()?.6:1;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&B(e,`cursor`,t.t=r),i!==t.a&&B(e,`opacity`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e}}),null),T(e,n(h,{get when(){return(!t||i)&&j()},get children(){var e=$a();return e.addEventListener(`mouseleave`,e=>{e.currentTarget.style.borderColor=`#30363d`}),e.addEventListener(`mouseenter`,e=>{P()||(e.currentTarget.style.borderColor=`#8b949e`)}),e.$$click=N,r(t=>{var n=P(),r=P()?`not-allowed`:`pointer`,i=P()?.6:1;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&B(e,`cursor`,t.t=r),i!==t.a&&B(e,`opacity`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e}}),null),r(e=>{var t=P(),n=P()?`not-allowed`:`pointer`,r=P()?.6:1;return t!==e.e&&(p.disabled=e.e=t),n!==e.t&&B(p,`cursor`,e.t=n),r!==e.a&&B(p,`opacity`,e.a=r),e},{e:void 0,t:void 0,a:void 0}),e}}),null),T(e,n(h,{get when(){return D().length>0},get children(){var e=to(),t=e.firstChild.nextSibling;return T(t,n(b,{get each(){return D()},children:e=>(()=>{var t=oo();return T(t,()=>e.name,null),T(t,(()=>{var t=I(()=>!!e.version);return()=>t()?` ${e.version}`:``})(),null),t})()})),e}}),null),e})()}P([`input`,`click`]);var po=[{id:`screeps-world`,name:`Screeps World`,url:`https://screeps.com`,forcedAuth:`token`,hasServerPassword:!1,builtin:!0},{id:`screeps-season`,name:`Screeps Season`,url:`https://screeps.com/season`,forcedAuth:`token`,hasServerPassword:!1,builtin:!0}],mo=`screeps:desktop:servers`,ho=`screeps:desktop:selectedServer`;function go(){try{let e=localStorage.getItem(mo);return e?JSON.parse(e):[]}catch{return[]}}function _o(e){localStorage.setItem(mo,JSON.stringify(e))}function vo(){return[...po,...go()]}function yo(e){let t=go(),n={...e,id:crypto.randomUUID()};return _o([...t,n]),n}function bo(e){_o(go().filter(t=>t.id!==e))}function xo(e,t){_o(go().map(n=>n.id===e?{...n,...t}:n))}function So(){return localStorage.getItem(ho)}function Co(e){localStorage.setItem(ho,e)}var wo=z(`<div style=display:flex;flex-direction:column;height:100%;gap:8px><div style=font-size:11px;color:#484f58;text-transform:uppercase;letter-spacing:0.05em;font-weight:600;padding-bottom:4px>Servers</div><div style=flex:1;overflow:auto;display:flex;flex-direction:column;gap:2px></div><button type=button style="display:flex;align-items:center;justify-content:center;gap:6px;padding:8px 10px;border-radius:6px;border:1px dashed #30363d;background:transparent;color:#8b949e;font-size:12px;cursor:pointer;flex-shrink:0"> Add Server`),To=z(`<button type=button title=Edit style=background:none;border:none;cursor:pointer;color:#8b949e;padding:2px;display:flex;align-items:center;border-radius:4px;flex-shrink:0>`),Eo=z(`<button type=button title=Remove style=background:none;border:none;cursor:pointer;color:#f85149;padding:2px;display:flex;align-items:center;border-radius:4px;flex-shrink:0>`),Do=z(`<div style="display:flex;align-items:center;padding:8px 10px;border-radius:6px;cursor:pointer;gap:6px;transition:background 0.1s, border-color 0.1s"><div style=flex:1;min-width:0><div style=font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis></div><div style=font-size:10px;color:#484f58;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:1px>`),Oo=z(`<div style=font-size:12px;color:#d29922;margin-top:4px>`),ko=z(`<div style=display:flex;gap:8px><button type=button style="flex:1;padding:8px;border-radius:6px;border:1px solid #30363d;color:#fff;cursor:pointer;font-size:13px">Password</button><button type=button style="flex:1;padding:8px;border-radius:6px;border:1px solid #30363d;color:#fff;cursor:pointer;font-size:13px">Token`),Ao=z(`<label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Email or Username</span><input type=text name=username autocomplete=username>`),jo=z(`<label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Password</span><input type=password name=password autocomplete=current-password>`),Mo=z(`<label style=display:flex;align-items:center;gap:8px;cursor:pointer><input type=checkbox style=width:14px;height:14px;accent-color:#238636;cursor:pointer;flex-shrink:0><span style=font-size:13px;color:#8b949e>Save <!> in keychain`),No=z(`<label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Server Password <span style=color:#484f58>(optional)</span></span><input type=password name=server-password autocomplete=off data-1p-ignore data-lpignore=true placeholder="Leave empty if not required">`),Po=z(`<div style=color:#f85149;font-size:13px>`),Fo=z(`<div style=display:flex;align-items:center;gap:8px;color:#484f58;font-size:12px><div style=flex:1;height:1px;background:#30363d></div>or<div style=flex:1;height:1px;background:#30363d>`),Io=z(`<button type=button style=padding:10px;border-radius:6px;border:none;background:#1b2838;color:#c7d5e0;font-weight:600>Login with Steam`),Lo=z(`<button type=button style=padding:10px;border-radius:6px;border:none;background:#5865F2;color:#fff;font-weight:600>Login with Discord`),Ro=z(`<form style=display:flex;flex-direction:column;gap:16px><div><h2 style="margin:0 0 4px;font-size:18px;color:#c9d1d9"></h2><div style=font-size:11px;color:#484f58></div></div><button type=submit style=padding:10px;border-radius:6px;border:none;background:#238636;color:#fff;font-weight:600>`),zo=z(`<label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Auth Token</span><input type=password name=token autocomplete=off>`),Bo=z(`<form style=display:flex;flex-direction:column;gap:16px><h2 style=margin:0;font-size:18px;color:#c9d1d9></h2><label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Name</span><input type=text placeholder="My Private Server"required></label><label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Server URL</span><input type=url placeholder=https://example.com required></label><label style=display:flex;flex-direction:column;gap:4px><span style=font-size:12px;color:#8b949e>Auth Method</span><span style=font-size:11px;color:#484f58;margin-bottom:2px>Restrict available login options for this server</span><select style=cursor:pointer><option value>Auto-detect (show all options)</option><option value=token>Token only</option><option value=password>Password only</option><option value=guest>Guest only (read-only)</option></select></label><label style=display:flex;align-items:center;gap:10px;cursor:pointer><input type=checkbox style=width:14px;height:14px;accent-color:#238636;cursor:pointer;flex-shrink:0><span style=font-size:13px;color:#c9d1d9>Server requires a connection password</span></label><div style=display:flex;gap:8px;margin-top:4px><button type=submit style=flex:1;padding:10px;border-radius:6px;border:none;background:#238636;color:#fff;font-weight:600;cursor:pointer></button><button type=button style="flex:1;padding:10px;border-radius:6px;border:1px solid #30363d;background:transparent;color:#8b949e;cursor:pointer">Cancel`),Vo=z(`<div style=color:#484f58;text-align:center;padding-top:60px;font-size:14px>Select a server from the list`),Ho=z(`<div style=display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;height:100%;overflow:auto;padding:24px;box-sizing:border-box><div style="display:flex;width:680px;min-height:420px;border-radius:8px;background:#161b22;border:1px solid #30363d;overflow:hidden;flex-shrink:0"><div style="width:200px;min-width:200px;border-right:1px solid #30363d;padding:24px 16px;box-sizing:border-box;display:flex;flex-direction:column"></div><div style="flex:1;padding:28px 32px;box-sizing:border-box;overflow:auto">`),{log:Uo}=ce(`desktop-login`),Wo={padding:`8px 12px`,"border-radius":`6px`,border:`1px solid #30363d`,background:`#0d1117`,color:`#c9d1d9`,width:`100%`,"box-sizing":`border-box`};function Go(t){let[i,a]=e(null),o=e=>{try{return new URL(e).hostname}catch{return e}};return(()=>{var e=wo(),s=e.firstChild.nextSibling,c=s.nextSibling,l=c.firstChild;return T(s,n(b,{get each(){return t.servers},children:e=>{let s=()=>t.selectedId===e.id,c=()=>i()===e.id;return(()=>{var i=Do(),l=i.firstChild.firstChild,u=l.nextSibling;return i.addEventListener(`mouseleave`,()=>a(null)),i.addEventListener(`mouseenter`,()=>a(e.id)),i.$$click=()=>t.onSelect(e.id),T(l,()=>e.name),T(u,()=>o(e.url)),T(i,n(h,{get when(){return I(()=>!e.builtin)()&&c()},get children(){return[(()=>{var r=To();return r.$$click=n=>{n.stopPropagation(),t.onEdit(e)},T(r,n(Ui,{size:12})),r})(),(()=>{var r=Eo();return r.$$click=n=>{n.stopPropagation(),t.onDelete(e.id)},T(r,n(ha,{size:12})),r})()]}}),null),r(e=>{var t=s()?`#1f6feb20`:c()?`#1c2128`:`transparent`,n=`1px solid ${s()?`#1f6feb60`:`transparent`}`,r=s()?`#58a6ff`:`#c9d1d9`,a=s()?`500`:`normal`;return t!==e.e&&B(i,`background`,e.e=t),n!==e.t&&B(i,`border`,e.t=n),r!==e.a&&B(l,`color`,e.a=r),a!==e.o&&B(l,`font-weight`,e.o=a),e},{e:void 0,t:void 0,a:void 0,o:void 0}),i})()}})),c.$$click=()=>t.onAdd(),T(c,n(qi,{size:12}),l),e})()}function Ko(t){let[i,a]=e(w(()=>t.server.forcedAuth===`token`?`token`:`password`)),[s,c]=e(``),[l,d]=e(``),[f,m]=e(``),[g,_]=e(``),[v,y]=e(!1),[b,x]=e(!1),S=()=>t.server.forcedAuth??i();async function C(e){Uo(`applyLoadedCredential: loading for "${e}"`);let t=await ue(e);if(Uo(`applyLoadedCredential: result for "${e}" →`,t===null?`[not found]`:`[found]`),t!==null){x(!0),y(!0);let e=S();Uo(`applyLoadedCredential: applying to field, effectiveAuth="${e}"`),e===`token`?m(t):d(t)}}o(()=>{Uo(`ServerLoginForm mounted, server="${t.server.url}"`),C(t.server.url)}),p(u(()=>t.server.id,()=>{c(``),d(``),m(``),_(``),x(!1),y(!1),a(t.server.forcedAuth===`token`?`token`:`password`),C(t.server.url)},{defer:!0}));let{serverVersion:E,serverError:D}=Ta(()=>t.server.url),O=()=>!t.server.forcedAuth,k=()=>{if(t.server.hasServerPassword===!1)return!1;let e=E();return e?!dt(e):!0},ee=()=>{if(t.server.forcedAuth)return!1;let e=E();if(!e)return!0;let n=mt(e);return n?n.steamLogin:at(e)?.authTypes?.includes(`steam`)??!0},j=()=>{if(t.server.forcedAuth)return!1;let e=E();return e?_t(e)?.discordLogin??!1:!1},M=()=>_e()===`connecting`,te=async e=>{y(e),!e&&b()&&(await ze(t.server.url),x(!1),S()===`token`?m(``):d(``))},ne=async e=>{e.preventDefault();let n=S(),r=n===`token`?f():n===`password`?l():null,i=v()&&!b()&&r!==null&&r!==``;Uo(`handleSubmit: auth="${n}" saveCredentials=${v()} credentialSaved=${b()} willSave=${i} credential=${r!==null&&r!==``?`[present]`:`[empty]`}`),i&&(Uo(`handleSubmit: saving credential for "${t.server.url}"`),await A(t.server.url,r),x(!0),Uo(`handleSubmit: credential saved`));try{await Ne({url:t.server.url,auth:n,email:s()||void 0,password:l()||void 0,token:f()||void 0,serverPassword:g()||void 0,storage:null})}catch{i&&(Uo(`handleSubmit: connect failed, removing saved credential`),ze(t.server.url),x(!1))}},re=wa(`steam`,({url:e,token:t})=>{Ne({url:e,auth:`token`,authMethod:`steam`,token:t,serverPassword:g()||void 0,storage:null})}),ie=()=>re.startLogin(t.server.url),ae=wa(`discord`,({url:e,token:t})=>{Ne({url:e,auth:`token`,authMethod:`discord`,token:t,serverPassword:g()||void 0,storage:null})}),oe=()=>ae.startLogin(t.server.url),N=()=>re.pending()?{login:re,label:`Steam`}:ae.pending()?{login:ae,label:`Discord`}:void 0;return n(h,{get when(){return!N()},get fallback(){return n(Ma,{get url(){return N().login.pending().url},get providerLabel(){return N().label},get submitting(){return N().login.submitting()},get error(){return N().login.regError()},onSubmit:(e,t)=>void N().login.completeRegistration(e,t),onCancel:()=>N().login.cancelRegistration()})},get children(){var e=Ro(),o=e.firstChild,u=o.firstChild,p=u.nextSibling,y=o.nextSibling;return e.addEventListener(`submit`,ne),T(u,()=>t.server.name),T(p,()=>t.server.url),T(o,n(h,{get when(){return D()},get children(){var e=Oo();return T(e,D),e}}),null),T(e,n(h,{get when(){return O()},get children(){var e=ko(),t=e.firstChild,n=t.nextSibling;return t.$$click=()=>a(`password`),n.$$click=()=>a(`token`),r(e=>{var r=i()===`password`?`#238636`:`transparent`,a=i()===`token`?`#238636`:`transparent`;return r!==e.e&&B(t,`background`,e.e=r),a!==e.t&&B(n,`background`,e.t=a),e},{e:void 0,t:void 0}),e}}),y),T(e,n(h,{get when(){return S()!==`guest`},get children(){return[n(h,{get when(){return S()===`password`},get fallback(){return(()=>{var e=zo(),t=e.firstChild.nextSibling;return t.$$input=e=>m(e.currentTarget.value),r(e=>{var n=b(),r={...Wo,opacity:b()?.5:1,cursor:b()?`not-allowed`:`text`};return n!==e.e&&(t.disabled=e.e=n),e.t=F(t,r,e.t),e},{e:void 0,t:void 0}),r(()=>t.value=f()),e})()},get children(){return[(()=>{var e=Ao(),t=e.firstChild.nextSibling;return t.$$input=e=>c(e.currentTarget.value),r(e=>F(t,Wo,e)),r(()=>t.value=s()),e})(),(()=>{var e=jo(),t=e.firstChild.nextSibling;return t.$$input=e=>d(e.currentTarget.value),r(e=>{var n=b(),r={...Wo,opacity:b()?.5:1,cursor:b()?`not-allowed`:`text`};return n!==e.e&&(t.disabled=e.e=n),e.t=F(t,r,e.t),e},{e:void 0,t:void 0}),r(()=>t.value=l()),e})()]}}),(()=>{var e=Mo(),t=e.firstChild,n=t.nextSibling,i=n.firstChild.nextSibling;return i.nextSibling,t.addEventListener(`change`,e=>{te(e.currentTarget.checked)}),T(n,()=>S()===`token`?`token`:`password`,i),r(()=>t.checked=v()),e})()]}}),y),T(e,n(h,{get when(){return k()},get children(){var e=No(),t=e.firstChild;t.firstChild.nextSibling;var n=t.nextSibling;return n.$$input=e=>_(e.currentTarget.value),r(e=>F(n,Wo,e)),r(()=>n.value=g()),e}}),y),T(e,n(h,{get when(){return ve()},get children(){var e=Po();return T(e,ve),e}}),y),T(y,(()=>{var e=I(()=>!!M());return()=>e()?`Connecting…`:S()===`guest`?`Connect as Guest (read-only)`:`Connect`})()),T(e,n(h,{get when(){return ee()||j()},get children(){var e=Fo();return e.firstChild.nextSibling.nextSibling,e}}),null),T(e,n(h,{get when(){return ee()},get children(){var e=Io();return e.$$click=ie,r(t=>{var n=M(),r=M()?`not-allowed`:`pointer`,i=M()?.6:1;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&B(e,`cursor`,t.t=r),i!==t.a&&B(e,`opacity`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e}}),null),T(e,n(h,{get when(){return j()},get children(){var e=Lo();return e.$$click=oe,r(t=>{var n=M(),r=M()?`not-allowed`:`pointer`,i=M()?.6:1;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&B(e,`cursor`,t.t=r),i!==t.a&&B(e,`opacity`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e}}),null),r(e=>{var t=M(),n=M()?`not-allowed`:`pointer`,r=M()?.6:1;return t!==e.e&&(y.disabled=e.e=t),n!==e.t&&B(y,`cursor`,e.t=n),r!==e.a&&B(y,`opacity`,e.a=r),e},{e:void 0,t:void 0,a:void 0}),e}})}function qo(t){let n=()=>!!t.server,[i,a]=e(w(()=>t.server?.name??``)),[o,s]=e(w(()=>t.server?.url??``)),[c,l]=e(w(()=>t.server?.forcedAuth??``)),[u,d]=e(w(()=>t.server?.hasServerPassword??!0)),f=e=>{e.preventDefault();let r=o().trim().replace(/\/$/,``);if(!i().trim()||!r)return;let a=c(),s={name:i().trim(),url:r,forcedAuth:a===``?void 0:a,hasServerPassword:u()};n()&&t.server?(xo(t.server.id,s),t.onSave({...t.server,...s})):t.onSave(yo(s))};return(()=>{var e=Bo(),p=e.firstChild,m=p.nextSibling,h=m.firstChild.nextSibling,g=m.nextSibling,_=g.firstChild.nextSibling,v=g.nextSibling,y=v.firstChild.nextSibling.nextSibling,b=v.nextSibling,x=b.firstChild;x.nextSibling;var S=b.nextSibling.firstChild,C=S.nextSibling;return e.addEventListener(`submit`,f),T(p,()=>n()?`Edit Server`:`Add Server`),h.$$input=e=>a(e.currentTarget.value),_.$$input=e=>s(e.currentTarget.value),y.addEventListener(`change`,e=>l(e.currentTarget.value)),x.addEventListener(`change`,e=>d(e.currentTarget.checked)),T(S,()=>n()?`Save Changes`:`Add Server`),C.$$click=()=>t.onCancel(),r(e=>{var t=Wo,n=Wo,r={...Wo};return e.e=F(h,t,e.e),e.t=F(_,n,e.t),e.a=F(y,r,e.a),e},{e:void 0,t:void 0,a:void 0}),r(()=>h.value=i()),r(()=>_.value=o()),r(()=>y.value=c()),r(()=>x.checked=u()),e})()}function Jo(){let t=()=>{let e=So();return e&&vo().some(t=>t.id===e)?e:po[0].id},[r,i]=e(vo()),[a,o]=e(t()),[s,c]=e(`login`),[l,u]=e(null),d=()=>r().find(e=>e.id===a())??null,f=()=>i(vo()),p=e=>{o(e),Co(e),c(`login`)},m=()=>{o(null),c(`add`)},h=e=>{u(e),c(`edit`)},g=e=>{bo(e),f(),a()===e&&p(po[0].id)},_=e=>{f(),p(e.id)},v=()=>{s()===`edit`&&l()?o(l().id):o(a()??po[0].id),c(`login`)};return(()=>{var e=Ho(),t=e.firstChild.firstChild,i=t.nextSibling;return T(t,n(Go,{get servers(){return r()},get selectedId(){return a()},onSelect:p,onEdit:h,onDelete:g,onAdd:m})),T(i,n(S,{get children(){return[n(C,{get when(){return s()===`add`},get children(){return n(qo,{onSave:_,onCancel:v})}}),n(C,{get when(){return I(()=>s()===`edit`)()?l():null},children:e=>n(qo,{get server(){return e()},onSave:_,onCancel:v})}),n(C,{get when(){return I(()=>s()===`login`)()?d():null},children:e=>n(Ko,{get server(){return e()}})}),n(C,{when:!0,get children(){return Vo()}})]}})),e})()}P([`click`,`input`]);var Yo=z(`<div style=display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px;width:100%;height:100%><div style="width:32px;height:32px;border:3px solid #30363d;border-top-color:#58a6ff;border-radius:50%;animation:spin 0.8s linear infinite"></div><div style=color:#8b949e;font-size:13px>Connecting…`);function Xo(){return(()=>{var e=Yo();return e.firstChild.nextSibling,e})()}var Zo=z(`<div style=position:fixed;inset:0;background:rgba(0,0,0,0.65);z-index:500;display:flex;align-items:center;justify-content:center><div style="width:min(440px, calc(100% - 48px));background:#161b22;border:1px solid #30363d;border-radius:8px;box-shadow:0 8px 24px rgba(0, 0, 0, 0.5);padding:20px"><div style=font-size:16px;font-weight:600;color:#f85149;margin-bottom:12px>Connection lost</div><p style="font-size:13px;color:#c9d1d9;line-height:1.5;margin:0 0 18px"></p><div style=display:flex;justify-content:flex-end;gap:8px><button style="padding:7px 14px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#c9d1d9;cursor:pointer;font-size:13px">Logout</button><button style="padding:7px 14px;border-radius:4px;border:none;background:#58a6ff;color:#0d1117;cursor:pointer;font-size:13px;font-weight:600">Reload page`);function Qo(){return n(h,{get when(){return je()},get children(){var e=Zo(),t=e.firstChild.firstChild.nextSibling,n=t.nextSibling.firstChild,r=n.nextSibling;return T(t,je),n.$$click=()=>we(),r.$$click=()=>window.location.reload(),e}})}P([`click`]);var $o=z(`<div style=position:fixed;inset:0;background:rgba(0,0,0,0.65);z-index:500;display:flex;align-items:center;justify-content:center><div style="width:min(480px, calc(100% - 48px));background:#161b22;border:1px solid #30363d;border-radius:8px;box-shadow:0 8px 24px rgba(0, 0, 0, 0.5);padding:20px"><div style=font-size:16px;font-weight:600;color:#f85149;margin-bottom:12px>Rate limit exceeded</div><p style="font-size:13px;color:#c9d1d9;line-height:1.5;margin:0 0 18px;word-break:break-word"></p><div style=display:flex;justify-content:flex-end;gap:8px><button style="padding:7px 14px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#c9d1d9;cursor:pointer;font-size:13px">Close`),es=z(`<button style="padding:7px 14px;border-radius:4px;border:none;background:#58a6ff;color:#0d1117;cursor:pointer;font-size:13px;font-weight:600">Disable rate limiting`);function ts(){return n(h,{get when(){return Le()},children:e=>(()=>{var t=$o(),r=t.firstChild.firstChild.nextSibling,i=r.nextSibling,a=i.firstChild;return T(r,()=>e().message),a.$$click=()=>Ce(null),T(i,n(h,{get when(){return e().disableLink},children:e=>(()=>{var t=es();return t.$$click=()=>void he(e()),t})()}),null),t})()})}P([`click`]);var ns=z(`<span style="padding:2px 8px;border-radius:4px;background:#21262d;border:1px solid #30363d;color:#8b949e;font-size:11px;font-weight:600;letter-spacing:0.05em;text-transform:uppercase">Guest`),rs=z(`<div style="display:flex;align-items:center;gap:12px;padding:8px 16px;border-bottom:1px solid #30363d;font-size:13px"><div style=display:flex;align-items:center;gap:6px><span style=width:8px;height:8px;border-radius:50%;display:inline-block></span><span style=color:#8b949e>`);function is(){let e=()=>{switch(_e()){case`connected`:return`#238636`;case`connecting`:return`#d29922`;case`error`:return`#f85149`;default:return`#8b949e`}};return(()=>{var t=rs(),i=t.firstChild.firstChild,a=i.nextSibling;return T(a,(()=>{var e=I(()=>_e()===`connected`);return()=>e()?`Online`:_e()})()),T(t,n(h,{get when(){return be()},get children(){return ns()}}),null),r(t=>B(i,`background-color`,e())),t})()}var as=class{container;hoverGraphics;pendingGraphics;selectionContainer;selectionGraphics=new Map;selectionTypes=new Map;selectionVisuals=new Map;ticker=null;tickerCallback=null;constructor(e){this.container=new He,this.container.label=`hoverHighlight`,this.container.eventMode=`none`,this.hoverGraphics=new U,this.hoverGraphics.eventMode=`none`,this.container.addChild(this.hoverGraphics),this.pendingGraphics=new U,this.pendingGraphics.eventMode=`none`,this.container.addChild(this.pendingGraphics),this.selectionContainer=new He,this.selectionContainer.eventMode=`none`,this.container.addChild(this.selectionContainer),e&&(this.ticker=e,this.tickerCallback=()=>this.trackCreepRings(),e.add(this.tickerCallback))}setHoveredTile(e,t){if(this.hoverGraphics.clear(),e===null||t===null)return;let n=e*12,r=t*12;this.hoverGraphics.rect(n,r,12,12),this.hoverGraphics.stroke({width:1,color:16777215,alpha:.35}),this.hoverGraphics.rect(n,r,12,12),this.hoverGraphics.fill({color:16777215,alpha:.06})}setSelectedObjects(e){this.selectionContainer.removeChildren();for(let e of this.selectionGraphics.values())e.destroy();this.selectionGraphics.clear(),this.selectionTypes.clear(),this.selectionVisuals.clear();for(let{id:t,type:n,visual:r}of e){let e=new U;e.eventMode=`none`,this.selectionContainer.addChild(e),this.selectionGraphics.set(t,e),this.selectionTypes.set(t,n),this.selectionVisuals.set(t,r),n===`creep`?this.drawCreepRing(e,r.x,r.y):this.drawStructureBox(e,r.x,r.y)}}clearSelection(){this.selectionContainer.removeChildren();for(let e of this.selectionGraphics.values())e.destroy();this.selectionGraphics.clear(),this.selectionTypes.clear(),this.selectionVisuals.clear()}setPendingTile(e,t){if(this.pendingGraphics.clear(),e===null||t===null)return;let n=e*12,r=t*12,i=n+12/2,a=r+12/2,o=12*.35;this.pendingGraphics.moveTo(i-o,a),this.pendingGraphics.lineTo(i+o,a),this.pendingGraphics.moveTo(i,a-o),this.pendingGraphics.lineTo(i,a+o),this.pendingGraphics.stroke({width:1.5,color:15763518,alpha:.9}),this.pendingGraphics.rect(n+1,r+1,10,10),this.pendingGraphics.stroke({width:1.5,color:15763518,alpha:.6})}clearPendingTile(){this.pendingGraphics.clear()}drawCreepRing(e,t,n){e.clear();let r=t+12/2,i=n+12/2;e.circle(r,i,5.76),e.stroke({width:1.5,color:16777215,alpha:.9})}drawStructureBox(e,t,n){e.clear(),e.rect(t+1,n+1,10,10),e.stroke({width:1.5,color:16777215,alpha:.9}),e.rect(t+1,n+1,10,10),e.fill({color:16777215,alpha:.04})}trackCreepRings(){for(let[e,t]of this.selectionGraphics){if(this.selectionTypes.get(e)!==`creep`)continue;let n=this.selectionVisuals.get(e);!n||n.destroyed||this.drawCreepRing(t,n.x,n.y)}}destroy(){this.ticker&&this.tickerCallback&&this.ticker.remove(this.tickerCallback),this.ticker=null,this.tickerCallback=null,this.clearSelection(),this.clearPendingTile(),this.pendingGraphics.destroy(),this.hoverGraphics.destroy(),this.container.destroy()}},os=.2,ss=3,cs=class{displaySprite;renderer;rt;scene;gradientTexture;lights=new Map;dirty=!1;destroyed=!1;constructor(e){this.renderer=e,this.gradientTexture=ls(),this.rt=Ue.create({width:600,height:600}),this.scene=new He;let t=new U;t.rect(0,0,600,600),t.fill({color:0,alpha:os}),this.scene.addChild(t),this.displaySprite=new Je(this.rt),this.render()}setLights(e){let t=new Set;for(let{id:n,cx:r,cy:i}of e){t.add(n);let e=this.lights.get(n);e||(e=new Je(this.gradientTexture),e.anchor.set(.5),e.blendMode=`erase`,this.scene.addChild(e),this.lights.set(n,e)),e.position.set(r,i)}for(let[e,n]of this.lights)t.has(e)||(n.destroy(),this.lights.delete(e));this.dirty=!0}setLightPosition(e,t,n){let r=this.lights.get(e);r&&(r.x===t&&r.y===n||(r.position.set(t,n),this.dirty=!0))}render(){this.destroyed||!this.dirty||(this.renderer.render({container:this.scene,target:this.rt,clear:!0}),this.dirty=!1)}clear(){for(let e of this.lights.values())e.destroy();this.lights.clear(),this.dirty=!0,this.render()}destroy(){if(!this.destroyed){this.destroyed=!0;for(let e of this.lights.values())e.destroy();this.lights.clear(),this.scene.destroy({children:!0}),this.rt.destroy(!0),this.gradientTexture.destroy(!0),this.displaySprite.destroy()}}};function ls(){let e=ss*12,t=e*2,n=document.createElement(`canvas`);n.width=t,n.height=t;let r=n.getContext(`2d`),i=r.createRadialGradient(e,e,0,e,e,e);return i.addColorStop(0,`rgba(255,255,255,1)`),i.addColorStop(1,`rgba(255,255,255,0)`),r.fillStyle=i,r.beginPath(),r.arc(e,e,e,0,Math.PI*2),r.fill(),et.from(n)}var us=48,ds=128,fs={terrain:0,objects:10,animations:20,darkOverlay:30,visuals:40,hover:50,nav:60},ps=new Set([`road`,`constructedWall`,`rampart`]),ms=class e{app;world;hoverLayer;darkOverlay;lightLayer;lighting;destroyed=!1;canDrag=!1;container;resizeObserver=null;bounceRaf=null;wheelTimeout=null;navOverlay;lastMouseX=0;lastMouseY=0;onHoverTile=null;onClickTile=null;onRightClick=null;constructor(e,t){this.app=e,this.container=t,this.world=new He({sortableChildren:!0}),this.app.stage.addChild(this.world),this.lighting=new cs(this.app.renderer),this.darkOverlay=this.lighting.displaySprite,this.darkOverlay.label=`darkOverlay`,this.darkOverlay.zIndex=fs.darkOverlay,this.world.addChild(this.darkOverlay),this.lightLayer=new He,this.lightLayer.label=`lightLayer`,this.hoverLayer=new as(e.ticker),this.hoverLayer.container.zIndex=fs.hover,this.world.addChild(this.hoverLayer.container),this.navOverlay=new He,this.navOverlay.zIndex=fs.nav,this.world.addChild(this.navOverlay),this.setupCamera(),this.centerView(),this.clampView(),this.setupResizeObserver()}bringNavOverlayToTop(){this.hoverLayer.container.parent===this.world&&(this.world.removeChild(this.hoverLayer.container),this.world.addChild(this.hoverLayer.container)),this.navOverlay.parent===this.world&&(this.world.removeChild(this.navOverlay),this.world.addChild(this.navOverlay))}static async create(t){let n=new Ye;return await n.init({background:`#0d1117`,antialias:!0,resolution:window.devicePixelRatio||1,autoDensity:!0}),t.appendChild(n.canvas),new e(n,t)}getMinScale(){let e=this.container.clientWidth,t=this.container.clientHeight;return Math.min(e,t)/664}clampView(e=!1){let t=600*this.world.scale.x,n=this.container.clientWidth,r=this.container.clientHeight,i=e?ds:0;if(t<=n){let r=n/2-t/2;e?this.world.x=Math.min(r+ds,Math.max(r-ds,this.world.x)):this.world.x=r}else{let e=n-t-us-i,r=us+i;this.world.x=Math.min(r,Math.max(e,this.world.x))}if(t<=r){let n=r/2-t/2;e?this.world.y=Math.min(n+ds,Math.max(n-ds,this.world.y)):this.world.y=n}else{let e=r-t-us-i,n=us+i;this.world.y=Math.min(n,Math.max(e,this.world.y))}this.canDrag=!0}getTargetPosition(){let e=600*this.world.scale.x,t=this.container.clientWidth,n=this.container.clientHeight,r=null,i=null;if(e<=t)r=t/2-e/2;else{let n=t-e-us,i=us;this.world.x<n?r=n:this.world.x>i&&(r=i)}if(e<=n)i=n/2-e/2;else{let t=n-e-us,r=us;this.world.y<t?i=t:this.world.y>r&&(i=r)}return r===null&&i===null?null:{x:r??this.world.x,y:i??this.world.y}}springBack(){let e=this.getTargetPosition(),t=this.getTargetScale();if(!e&&t===null)return;let n=this.world.x,r=this.world.y,i=this.world.scale.x,a=performance.now(),o=this.container.clientWidth/2,s=this.container.clientHeight/2,c=(o-n)/i,l=(s-r)/i,u=d=>{let f=d-a,p=Math.min(1,f/300),m=1-(1-p)**3;if(t!==null){let e=i+(t-i)*m;this.world.scale.set(e),this.world.x=o-c*e,this.world.y=s-l*e}e&&t===null&&(this.world.x=n+(e.x-n)*m,this.world.y=r+(e.y-r)*m),p<1?this.bounceRaf=requestAnimationFrame(u):(this.bounceRaf=null,this.clampView())};this.cancelBounce(),this.bounceRaf=requestAnimationFrame(u)}cancelBounce(){this.bounceRaf!==null&&(cancelAnimationFrame(this.bounceRaf),this.bounceRaf=null)}cancelWheelTimeout(){this.wheelTimeout!==null&&(clearTimeout(this.wheelTimeout),this.wheelTimeout=null)}getTargetScale(){let e=this.getMinScale();return this.world.scale.x<e?e:this.world.scale.x>5?5:null}setupCamera(){let e=!1,t=new We(0,0),n=new We(0,0),r=this.app.canvas;r.style.touchAction=`none`,r.style.userSelect=`none`;let i=new Map,a=!1,o=0,s=0,c=0,l=0;r.addEventListener(`pointerdown`,u=>{if(this.cancelBounce(),this.cancelWheelTimeout(),i.set(u.pointerId,{x:u.clientX,y:u.clientY}),r.setPointerCapture(u.pointerId),i.size>=2){e=!1,a=!0;let t=[...i.values()],n=r.getBoundingClientRect(),u=(t[0].x+t[1].x)/2-n.left,d=(t[0].y+t[1].y)/2-n.top;c=Math.hypot(t[1].x-t[0].x,t[1].y-t[0].y),l=this.world.scale.x,o=(u-this.world.x)/l,s=(d-this.world.y)/l}else a=!1,e=this.canDrag,t=new We(u.clientX,u.clientY),n=new We(u.clientX,u.clientY)}),r.addEventListener(`pointermove`,n=>{let u=r.getBoundingClientRect();if(this.lastMouseX=n.clientX-u.left,this.lastMouseY=n.clientY-u.top,i.has(n.pointerId)&&i.set(n.pointerId,{x:n.clientX,y:n.clientY}),a&&i.size===2){let e=[...i.values()],t=(e[0].x+e[1].x)/2-u.left,n=(e[0].y+e[1].y)/2-u.top,r=Math.hypot(e[1].x-e[0].x,e[1].y-e[0].y),a=this.getMinScale(),d=.6,f=r/c*l;f<a&&(f=a+(f-a)*d),f>5&&(f=5+(f-5)*d),this.cancelBounce(),this.world.scale.set(f),this.world.x=t-o*f,this.world.y=n-s*f,this.clampView(!0);return}if(!a){let e=this.screenToTile(this.lastMouseX,this.lastMouseY);this.hoverLayer.setHoveredTile(e?.tx??null,e?.ty??null),this.onHoverTile?.(e?.tx??null,e?.ty??null)}if(!e||!this.canDrag)return;let d=n.clientX-t.x,f=n.clientY-t.y;this.world.x+=d,this.world.y+=f,t=new We(n.clientX,n.clientY),this.clampView(!0)});let u=t=>{if(r.releasePointerCapture(t.pointerId),i.delete(t.pointerId),a){i.size<2&&(a=!1,e=!1,this.springBack());return}e=!1;let o=t.clientX-n.x,s=t.clientY-n.y;if(Math.sqrt(o*o+s*s)<4){let e=r.getBoundingClientRect(),n=t.clientX-e.left,i=t.clientY-e.top,a=this.screenToTile(n,i);a&&this.onClickTile?.(a.tx,a.ty,t.ctrlKey||t.metaKey)}this.springBack()};r.addEventListener(`pointerup`,u),r.addEventListener(`pointercancel`,u),r.addEventListener(`contextmenu`,e=>{e.preventDefault(),e.button===2&&this.onRightClick?.()}),r.addEventListener(`pointerleave`,()=>{this.hoverLayer.setHoveredTile(null,null),this.onHoverTile?.(null,null)}),r.addEventListener(`wheel`,e=>{e.preventDefault();let t=e.deltaY>0?.9:1.1,n=this.getMinScale(),i=this.world.scale.x*t,a=.6;i<n&&(i=n+(i-n)*a),i>5&&(i=5+(i-5)*a);let o=r.getBoundingClientRect(),s=e.clientX-o.left,c=e.clientY-o.top;if(this.cancelBounce(),i<n){let e=this.container.clientWidth/2,t=this.container.clientHeight/2,n=(e-this.world.x)/this.world.scale.x,r=(t-this.world.y)/this.world.scale.y;this.world.scale.set(i),this.world.x=e-n*i,this.world.y=t-r*i}else{let e=(s-this.world.x)/this.world.scale.x,t=(c-this.world.y)/this.world.scale.y;this.world.scale.set(i),this.world.x=s-e*i,this.world.y=c-t*i}this.clampView(),this.cancelWheelTimeout(),this.wheelTimeout=window.setTimeout(()=>{this.wheelTimeout=null,this.springBack()},80)},{passive:!1})}setTileHandlers(e,t,n){this.onHoverTile=e,this.onClickTile=t,this.onRightClick=n??null}screenToTile(e,t){let n=(e-this.world.x)/this.world.scale.x,r=(t-this.world.y)/this.world.scale.y,i=Math.floor(n/12),a=Math.floor(r/12);return i<0||i>=50||a<0||a>=50?null:{tx:i,ty:a}}centerView(){let e=this.container.clientWidth/2,t=this.container.clientHeight/2,n=this.world.scale.x;this.world.x=e-600*n/2,this.world.y=t-600*n/2}resetView(){this.cancelBounce(),this.cancelWheelTimeout(),this.world.scale.set(this.getMinScale()),this.centerView(),this.clampView()}setupResizeObserver(){let{width:e,height:t}=this.container.getBoundingClientRect();this.app.renderer.resize(e,t),this.resizeObserver=new ResizeObserver(e=>{let{width:t,height:n}=e[0].contentRect;this.app.renderer.resize(t,n),this.clampView()}),this.resizeObserver.observe(this.container)}setupNavigationZones(e){this.navOverlay.removeChildren();let t=(e,t,n,r,i,a)=>{if(!a)return;let o=new U;o.x=e,o.y=t,o.hitArea=new nt(0,0,n,r),o.fill({color:16777215,alpha:.12}),o.poly(i),o.fill(),o.eventMode=`static`,o.cursor=`pointer`,o.alpha=1,o.on(`pointerover`,()=>{o.clear(),o.fill({color:16777215,alpha:.06}),o.rect(0,0,n,r),o.fill(),o.fill({color:16777215,alpha:.35}),o.poly(i),o.fill()}),o.on(`pointerout`,()=>{o.clear(),o.fill({color:16777215,alpha:.12}),o.poly(i),o.fill()}),o.on(`pointerdown`,a),this.navOverlay.addChild(o)};t(-48,0,us,600,[18,300,us-6,282,us-6,318],e.west),t(600,0,us,600,[us-18,300,6,282,6,318],e.east),t(0,-48,600,us,[300,18,282,us-6,318,us-6],e.north),t(0,600,600,us,[300,us-18,282,6,318,6],e.south);for(let e of this.navOverlay.children){let t=e,n=t.hitArea,r=this.world.x+t.x*this.world.scale.x,i=this.world.y+t.y*this.world.scale.y,a=n.width*this.world.scale.x,o=n.height*this.world.scale.y;this.lastMouseX>=r&&this.lastMouseX<=r+a&&this.lastMouseY>=i&&this.lastMouseY<=i+o&&t.emit(`pointerover`,new Event(`pointerover`))}}clear(){for(let e=this.world.children.length-1;e>=0;e--){let t=this.world.children[e];t!==this.navOverlay&&t!==this.hoverLayer.container&&t!==this.darkOverlay&&this.world.removeChild(t)}this.navOverlay.removeChildren(),this.hoverLayer.clearSelection(),this.hoverLayer.setHoveredTile(null,null),this.clearLighting(),this.world.scale.set(1),this.cancelBounce(),this.cancelWheelTimeout(),this.clampView()}clearLighting(){this.lighting.clear()}updateLighting(e){let t=[];for(let n in e){let r=e[n];r&&(typeof r.type==`string`&&ps.has(r.type)||typeof r.x!=`number`||typeof r.y!=`number`||t.push({id:n,cx:(r.x+.5)*12,cy:(r.y+.5)*12}))}this.lighting.setLights(t),this.lighting.render()}destroy(){this.destroyed||(this.destroyed=!0,this.cancelBounce(),this.cancelWheelTimeout(),this.resizeObserver?.disconnect(),this.resizeObserver=null,this.hoverLayer.destroy(),this.lighting.destroy(),this.app.destroy(!0,{children:!0}))}};function hs(e){return e}function gs(e){return{floorColor:e?.floorColor??3421243,swampFillColor:e?.swampFillColor??2632986,swampBorderColor:e?.swampBorderColor??2500383,swampBorderWidth:e?.swampBorderWidth??.2,swampGlowColor:e?.swampGlowColor??2771488,wallFillColor:e?.wallFillColor??1579032,wallBorderColor:e?.wallBorderColor??0,wallBorderWidth:e?.wallBorderWidth??.05,wallNoiseColor:e?.wallNoiseColor??2631720}}function _s(e,t,n,r){let i=!1;for(let r=0;r<50;r++)for(let a=0;a<50;a++){let o=t.get(a,r)===n,s=r>0&&t.get(a,r-1)===n,c=r<49&&t.get(a,r+1)===n,l=a>0&&t.get(a-1,r)===n,u=a<49&&t.get(a+1,r)===n,d=a*12+6,f=r*12+6;o?(i=!0,!s&&!l&&r>0&&a>0?(e.moveTo(d,r*12),e.arc(d,f,6,-Math.PI/2,Math.PI,!0),e.lineTo(d,f),e.closePath()):e.rect(a*12,r*12,6,6)):s&&l&&t.get(a-1,r-1)===n&&(i=!0,e.moveTo(d,r*12),e.lineTo(a*12,r*12),e.lineTo(a*12,f),e.arc(d,f,6,Math.PI,-Math.PI/2,!1),e.closePath()),o?!s&&!u&&r>0&&a<49?(e.moveTo(d,r*12),e.arc(d,f,6,-Math.PI/2,0,!1),e.lineTo(d,f),e.closePath()):e.rect(d,r*12,6,6):s&&u&&t.get(a+1,r-1)===n&&(i=!0,e.moveTo(d,r*12),e.lineTo(a*12+12,r*12),e.lineTo(a*12+12,f),e.arc(d,f,6,0,-Math.PI/2,!0),e.closePath()),o?!c&&!l&&r<49&&a>0?(e.moveTo(a*12,f),e.arc(d,f,6,Math.PI,Math.PI/2,!0),e.lineTo(d,f),e.closePath()):e.rect(a*12,f,6,6):c&&l&&t.get(a-1,r+1)===n&&(i=!0,e.moveTo(a*12,f),e.lineTo(a*12,r*12+12),e.lineTo(d,r*12+12),e.arc(d,f,6,Math.PI/2,Math.PI,!1),e.closePath()),o?!c&&!u&&r<49&&a<49?(e.moveTo(d,r*12+12),e.arc(d,f,6,Math.PI/2,0,!0),e.lineTo(d,f),e.closePath()):e.rect(d,f,6,6):c&&u&&t.get(a+1,r+1)===n&&(i=!0,e.moveTo(d,r*12+12),e.lineTo(a*12+12,r*12+12),e.lineTo(a*12+12,f),e.arc(d,f,6,0,Math.PI/2,!1),e.closePath())}i&&r(e)}function vs(e,t){let n=St,r=(t,r,i)=>{let a=t*12+12/2,o=r*12+12/2,s=12*.3;i===`up`?(e.moveTo(a,o-s),e.lineTo(a+s,o+s),e.lineTo(a-s,o+s)):i===`down`?(e.moveTo(a,o+s),e.lineTo(a+s,o-s),e.lineTo(a-s,o-s)):i===`left`?(e.moveTo(a-s,o),e.lineTo(a+s,o-s),e.lineTo(a+s,o+s)):i===`right`&&(e.moveTo(a+s,o),e.lineTo(a-s,o-s),e.lineTo(a-s,o+s)),e.fill(n)};for(let e=0;e<50;e++)t.get(e,0)!==lt.Wall&&r(e,0,`up`),t.get(e,49)!==lt.Wall&&r(e,49,`down`);for(let e=0;e<50;e++)t.get(0,e)!==lt.Wall&&r(0,e,`left`),t.get(49,e)!==lt.Wall&&r(49,e,`right`)}function ys(e){let t=new U;return t.rect(0,0,600,600),t.fill(e.floorColor),t}function bs(e,t){let n=new U;return _s(n,e,lt.Swamp,e=>e.fill(t.swampFillColor)),n.alpha=.4,n}function xs(e,t){let n=new U,r={color:t.wallBorderColor,width:12*t.wallBorderWidth,alignment:0,cap:`round`,join:`round`};return _s(n,e,lt.Wall,e=>e.stroke(r)),_s(n,e,lt.Wall,e=>e.fill(t.wallFillColor)),vs(n,e),n.rect(0,0,600,600),n.stroke({width:1,color:Jt}),n}function Ss(e,t){let n=new U;return n.label=`swampGlow`,_s(n,e,lt.Swamp,e=>e.fill(t.swampGlowColor)),n.alpha=.45,n.filters=[new Ke({strength:5,quality:3})],n}function Cs(e,t,n){let r=new U;_s(r,e,lt.Wall,e=>e.fill(n.wallNoiseColor)),r.alpha=.5,r.filters=[new $e({noise:.12,seed:1})],r.filterArea=new nt(0,0,600,600);let i=t.generateTexture({target:r,frame:r.filterArea});r.filters=null,r.destroy();let a=new Je(i);return a.label=`wallNoise`,a}function ws(e,t,n){let r=gs(n),i=new He,a=Cs(e,t,r),o=i.destroy.bind(i);if(i.destroy=e=>{a.destroyed||(a.removeFromParent(),a.destroy({texture:!0,textureSource:!0})),o(e)},i.addChild(ys(r)),i.addChild(bs(e,r)),i.addChild(xs(e,r)),i.addChild(Ss(e,r)),i.addChild(a),n?.wallTextureUrl&&(a.visible=!1),n?.floorTextureUrl){let{floorTextureUrl:e,floorTextureTint:t=16777215,floorTextureAlpha:r=1,floorTextureTileScale:a=1}=n;qe.load(hs(e)).then(e=>{if(i.destroyed)return;let n=new Ge({texture:e,width:600,height:600});n.tint=t,n.alpha=r,n.tileScale.set(a*.8),i.addChildAt(n,1)}).catch(()=>{})}if(n?.wallTextureUrl){let{wallTextureUrl:t,wallTextureTint:r=16777215,wallTextureAlpha:a=1,wallTextureTileScale:o=1}=n;qe.load(hs(t)).then(t=>{if(i.destroyed)return;let n=new Ge({texture:t,width:600,height:600});n.tint=r,n.alpha=a,n.tileScale.set(o);let s=new U;_s(s,e,lt.Wall,e=>e.fill(16777215)),i.addChild(s),n.mask=s,i.addChild(n)}).catch(()=>{})}return i}function Ts(e,t){e.getChildByLabel(`swampGlow`).visible=t,e.getChildByLabel(`wallNoise`).visible=t}function Es(e,t){let n=parseInt(e.replace(`#`,``),16),r=Math.min(255,Math.round((n>>16&255)*t)),i=Math.min(255,Math.round((n>>8&255)*t)),a=Math.min(255,Math.round((n&255)*t));return r<<16|i<<8|a}function Ds(e){return parseInt(e.replace(`#`,``),16)}function Os(e,t){if(e==null)return t;let n=Number(e);return isNaN(n)?t:n}function ks(e,t,n){let r=n.terrain??{};e.floorBackgroundColor&&(r.floorColor=Es(e.floorBackgroundColor,Os(e.floorBackgroundBrightness,1))),e.swampColor&&(r.swampFillColor=Ds(e.swampColor)),e.swampStrokeColor&&(r.swampBorderColor=Ds(e.swampStrokeColor)),e.swampStrokeWidth!=null&&(r.swampBorderWidth=Os(e.swampStrokeWidth,50)/250),e.roadsColor&&(n.roadColor=Es(e.roadsColor,Os(e.roadsBrightness,1))),t.floorForegroundUrl&&(r.floorTextureUrl=t.floorForegroundUrl,e.floorForegroundColor&&(r.floorTextureTint=Es(e.floorForegroundColor,Os(e.floorForegroundBrightness,1))),r.floorTextureAlpha=Os(e.floorForegroundAlpha,1),r.floorTextureTileScale=Os(e.tileScale??t.tileScale,1)),n.terrain=r}function As(e,t,n){let r=n.terrain??{};e.backgroundColor&&(r.wallFillColor=Es(e.backgroundColor,Os(e.backgroundBrightness,1))),e.strokeColor&&(r.wallBorderColor=Es(e.strokeColor,Os(e.strokeBrightness,1))),e.strokeWidth!=null&&(r.wallBorderWidth=Os(e.strokeWidth,10)/250),t.foregroundUrl&&(r.wallTextureUrl=t.foregroundUrl,e.foregroundColor&&(r.wallTextureTint=Es(e.foregroundColor,Os(e.foregroundBrightness,1))),r.wallTextureAlpha=Os(e.foregroundAlpha,1),r.wallTextureTileScale=Os(e.tileScale??t.tileScale,1)),n.terrain=r}function js(e){let t={};for(let n of e.decorations){let e=n.decoration.type;e===`floorLandscape`?ks(n.active,n.decoration,t):e===`wallLandscape`&&As(n.active,n.decoration,t)}return t}var Ms={1:200,2:45e3,3:135e3,4:405e3,5:1215e3,6:3645e3,7:10935e3},Ns={1:2e4,2:1e4,3:2e4,4:4e4,5:8e4,6:12e4,7:15e4,8:2e5},Ps=new Ft,Fs=12*.44,Is=12*.28,Ls=50,Rs=32,zs=12/Rs,Bs=12/2-12*.44,Vs=2,Hs=12*1.2/Rs,Us=5,Ws=2.5,Gs=2,Ks=2.6,qs=2,Js=12,Ys=15790320,Xs=1710618,Zs=12*.42,Qs=12*.3,$s=1,ec={H:2236962,O:2236962},tc=.2,nc=12*.42,rc=32,ic=9/rc,ac=8,oc=1600,sc=16776428,cc=4473924,lc=1.7999999999999998;function uc(e,t){return t<=0?ac:ac*Math.max(0,Math.min(1,e/t))}function dc(e){let t=e%oc/oc;return .5-.5*Math.cos(t*Math.PI*2)}function fc(e){return xc(Ut,sc,dc(e))}function pc(e,t,n){e.clear();let r=t<=0,i=ac/2,a=ac*.25;if(e.roundRect(6-i,6-i,ac,ac,a),e.fill(W),r)e.roundRect(6-i,6-i,ac,ac,a),e.stroke({width:lc,color:xc(W,cc,dc(n))});else{let r=t/2;e.roundRect(6-r,6-r,t,t,t*.25),e.fill(fc(n))}}function mc(e,t){let n=e.__sourceGraphics;n&&(e.__sourceSize=t,pc(n,t,performance.now()))}function hc(e){return{energy:typeof e.energy==`number`?e.energy:0,capacity:typeof e.energyCapacity==`number`?e.energyCapacity:3e3}}var gc=12*.3,_c=1.44,vc=gc-_c/2,yc=12*.42,bc=1500;function xc(e,t,n){let r=e>>16&255,i=e>>8&255,a=e&255,o=t>>16&255,s=t>>8&255,c=t&255,l=Math.round(r+(o-r)*n),u=Math.round(i+(s-i)*n),d=Math.round(a+(c-a)*n);return l<<16|u<<8|d}function Sc(e,t){e.clear(),e.circle(12/2,12/2,gc),e.stroke({width:_c,color:t,alpha:.95})}var Cc=12*.975,wc=2.16,Tc=Math.PI/3,Ec=1;function Dc(e,t){e.clear();for(let n=0;n<3;n++){let r=n*(2*Math.PI/3)+Tc/2,i=r+2*Math.PI/3-Tc;e.arc(0,0,Cc,r,i),e.stroke({width:wc,color:t,cap:`round`})}}function Oc(e,t,n,r,i,a,o){if(e.clear(),a<=0||i<=0)return;let s=Math.min(1,i/a);if(s>=1){e.circle(t,n,r),e.fill({color:o,alpha:.55});return}let c=-Math.PI/2,l=c+s*Math.PI*2;e.moveTo(t,n),e.lineTo(t+r*Math.cos(c),n+r*Math.sin(c)),e.arc(t,n,r,c,l),e.closePath(),e.fill({color:o,alpha:.55})}var kc=12*.5,Ac=1.2000000000000002,jc=12*.4;function Mc(e,t){let n=e.spawning;if(!n||typeof n!=`object`)return null;let r=typeof n.needTime==`number`&&n.needTime>0?n.needTime:null;return r===null?null:typeof n.remainingTime==`number`?{needTime:r,endTime:t+n.remainingTime}:typeof n.spawnTime==`number`?{needTime:r,endTime:n.spawnTime>t?n.spawnTime:n.spawnTime+r}:{needTime:r,endTime:t+r}}function Nc(e){let t=e.spawning;return!t||typeof t!=`object`?null:`${String(t.name)}:${String(t.needTime)}:${String(t.remainingTime)}:${String(t.spawnTime)}`}function Pc(e,t,n){return Math.max(0,Math.min(1,1-(t-n)/e))}function Fc(e,t){if(e.clear(),t===null||(e.circle(6,6,kc),e.stroke({width:Ac,color:16777215,alpha:.12}),t<=0))return;let n=-Math.PI/2,r=n+Math.min(1,t)*Math.PI*2;e.moveTo(6+kc*Math.cos(n),6+kc*Math.sin(n)),e.arc(6,6,kc,n,r),e.stroke({width:Ac,color:Ut,alpha:.95,cap:`round`})}function Ic(e,t,n){return n.flatMap(([n,r])=>[e+n*12,t+r*12])}function Lc(e,t,n,r){n-t<.001||(e.moveTo(Fs*Math.cos(t),Fs*Math.sin(t)),e.arc(0,0,Fs,t,n),e.lineTo(Is*Math.cos(n),Is*Math.sin(n)),e.arc(0,0,Is,n,t,!0),e.closePath(),e.fill(r))}var Rc=[[0,-.3],[.22,.05],[.15,.2],[-.15,.2],[-.22,.05]],zc=12*.073,Bc=null;function Vc(){if(Bc)return Bc;let e=Ic(12/2,12/2,Rc),t=new Xe({type:`linear`,start:{x:.5,y:0},end:{x:.5,y:1},colorStops:[{offset:0,color:Xn},{offset:1,color:Kn}]});return Bc=new Qe().poly(e).fill(t).poly(e).stroke({width:zc,color:on,alignment:.5,join:`miter`,miterLimit:6}),Bc}function Hc(e){e.addChild(new U({context:Vc()}))}function Uc(e){let t=0;if(typeof e.storeCapacity==`number`)t=e.storeCapacity;else{let n=e.body;n&&(t=n.filter(e=>e.type===`carry`).length*50)}if(t===0)return{used:0,capacity:0};let n=0;if(e.store&&typeof e.store==`object`){let t=e.store;for(let e in t){let r=t[e];typeof r==`number`&&(n+=r)}}else typeof e.energy==`number`&&(n=e.energy);return{used:n,capacity:t}}function Wc(e,t){return t<=0||e<=0?0:Is*.8*Math.min(1,e/t)}function Gc(e,t){let n=e.__creepFillGraphics;n&&(n.clear(),t>0&&(n.circle(0,0,t),n.fill(xn)))}function Kc(e){return un[e]??13226457}function qc(e){let t=50;typeof e.energyCapacity==`number`?t=e.energyCapacity:typeof e.storeCapacity==`number`?t=e.storeCapacity:e.storeCapacityResource&&typeof e.storeCapacityResource==`object`&&(t=e.storeCapacityResource.energy??50);let n=0;return typeof e.energy==`number`?n=e.energy:e.store&&typeof e.store==`object`&&(n=e.store.energy??0),{energy:n,capacity:t}}function Jc(e){return e>=200?1.15:e>=100?.85:.7}function Yc(e,t){return t<=0||e<=0?0:Qs*Jc(t)*Math.min(1,e/t)}var Xc=12*.25,Zc=12*.3;function Qc(e,t){return t<=0||e<=0?0:Math.min(1,e/t)}function $c(e,t){let n=e.__linkFillGraphics;if(!n||(n.clear(),t<=0))return;let r=Xc*t,i=Zc*t;n.poly([6,6-i,6+r,6,6,6+i,6-r,6]),n.fill(Ut)}function el(e,t,n,r){let i=Jc(n),a=new U;a.circle(6,6,Zs*i),a.fill(W),a.circle(6,6,Zs*i),a.stroke({width:$s*i,color:r}),a.circle(6,6,Qs*i),a.fill(bt),e.addChild(a);let o=new U,s=Yc(t,n);s>0&&(o.circle(6,6,s),o.fill(Ut)),e.addChild(o),e.__fillGraphics=o}function tl(e,t){let n=e.__fillGraphics;n&&(n.clear(),t>0&&(n.circle(6,6,t),n.fill(Ut)))}var nl=-12*.4,rl=-12*.3,il=12*.8,al=12*.6,ol=.4,sl=.3,cl=Math.PI/2,ll=Math.PI/2;function ul(e,t,n){let r=(t-e)%(Math.PI*2);return r>Math.PI?r-=Math.PI*2:r<-Math.PI&&(r+=Math.PI*2),e+r*n}var dl=12*.45,fl=12*.6,pl=12*.275,ml=12*.2,hl=.5;function gl(e,t){return t<=0||e<=0?0:Math.min(1,e/t)}function _l(e,t){let n=e.__towerFillGraphics;if(!n||(n.clear(),t<=0))return;let r=e.__towerFillRect;if(r){let e=r.heightMax*t,i=r.yMin+r.heightMax-e,a=Math.min(r.rx,r.width/2,e/2);n.roundRect(r.x,i,r.width,e,a),n.fill(Ut);return}let i=.5,a=al*t;n.rect(nl+i,rl+al-a+i,il-i*2,a-i*2),n.fill(Ut)}var vl=0,yl=-12*.1,bl=12,xl=12*1.2,Sl=[`energy`,`power`];function Cl(e){let t=typeof e.storeCapacity==`number`?e.storeCapacity:0;if(t===0||!e.store||typeof e.store!=`object`)return{bands:[],used:0,capacity:0,dominant:null};let n=e.store,r=[],i=null,a=0;for(let e in n){let t=n[e];typeof t==`number`&&t>0&&(r.push([e,t]),t>a&&(a=t,i=e))}r.sort(([e],[t])=>{let n=Sl.indexOf(e),r=Sl.indexOf(t);return(n===-1?99:n)-(r===-1?99:r)||(e<t?-1:+(e>t))});let o=0;return{bands:r.map(([e,t])=>(o+=t,{color:Dt[e]??7105644,amount:t})),used:o,capacity:t,dominant:i}}function wl(e,t,n,r,i,a,o,s=0){if(i<=0||o<=0)return;let c=t+s,l=r-s*2,u=i-s*2,d=n-s;if(u<=0)return;if(!a||a.length===0){e.rect(c,d-u,l,u),e.fill(Ut);return}let f=d;for(let t of a){let n=u*(t.amount/o);n>0&&(e.rect(c,f-n,l,n),e.fill(t.color)),f-=n}}function Tl(e,t){if(!e||e.length!==t.length)return!1;for(let n=0;n<t.length;n++)if(e[n].color!==t[n].color||e[n].amount!==t[n].amount)return!1;return!0}function El(e,t){return t<=0||e<=0?0:fl*Math.min(1,e/t)}function Dl(e,t){let n=e.__containerFillG;n&&(n.clear(),wl(n,pl,ml+fl,dl,t,e.__containerBands,e.__containerUsed??0,hl))}function Ol(e,t){return t<=0||e<=0?0:xl*Math.min(1,e/t)}function kl(e,t){let n=e.__storageFillG;n&&(n.clear(),wl(n,vl,yl+xl,bl,t,e.__storageBands,e.__storageUsed??0))}function Al(e){return Dt[e]??7105644}function K(e,t){return t<=0||e<=0?0:Math.min(1,e/t)}function jl(e,t){return jc*K(e,t)}var Ml=12*.35;function Nl(e,t){let n=e.__terminalFillG;if(n&&(n.clear(),t>0)){let r=Ml*t;n.rect(6-r,6-r,r*2,r*2),n.fill(e.__terminalFillColor??16771195)}}var Pl=16777215,Fl=.55,Il=[[[0,-.65],[-.45,-.45],[.45,-.45]],[[.65,0],[.45,-.45],[.45,.45]],[[0,.65],[.45,.45],[-.45,.45]],[[-.65,0],[-.45,.45],[-.45,-.45]]];function Ll(e,t,n){for(let r of Il)e.poly(Ic(t,n,r)),e.fill({color:Pl,alpha:Fl})}var Rl=12*.025,zl=12*.36,Bl=12*.05,Vl=12*.8,Hl=12*.9,Ul=12*.25,Wl=2e3,Gl=3e3,Kl=16777215,ql=12*.55,Jl=12*.16,Yl=12*.07,Xl=.22,Zl=.5;function Ql(e,t,n){e.circle(t,n,ql),e.stroke({width:Jl,color:Kl,alpha:Xl}),e.circle(t,n,ql),e.stroke({width:Yl,color:Kl,alpha:Zl})}var $l=12*.45,eu=919304,tu=2758168,nu=12*.06,ru=14830150,iu=12*.17,au=12*.085,ou=2600,su=12*.1,cu=12*.42,lu=.6,uu=null;function du(){if(uu)return uu;let e=document.createElement(`canvas`);e.width=e.height=128;let t=e.getContext(`2d`),n=t.createRadialGradient(64,64,0,64,64,64);return n.addColorStop(0,`rgba(255,255,255,1)`),n.addColorStop(.45,`rgba(255,255,255,0.72)`),n.addColorStop(.75,`rgba(255,255,255,0.22)`),n.addColorStop(1,`rgba(255,255,255,0)`),t.fillStyle=n,t.fillRect(0,0,128,128),uu=et.from(e),uu}function fu(e){return typeof e.cooldownTime==`number`?e.cooldownTime:0}function pu(e){let t=e.store&&typeof e.store==`object`?e.store:{},n=e.storeCapacityResource&&typeof e.storeCapacityResource==`object`?e.storeCapacityResource:{},r=typeof t.energy==`number`?t.energy:0,i=typeof n.energy==`number`?n.energy:Wl,a=null,o=0;for(let e in t){if(e===`energy`)continue;let n=t[e];typeof n==`number`&&n>o&&(o=n,a=e)}let s=a&&typeof n[a]==`number`?n[a]:Gl;return{energy:r,energyCap:i,mineralType:a,mineral:o,mineralCap:s}}function mu(e,t,n){let r=e.__labMineralG;r&&(r.clear(),n>0)&&(r.circle(6,6-Rl,zl*n),r.fill(e.__labMineralColor??7105644));let i=e.__labEnergyG;if(i&&(i.clear(),t>0)){let e=.5;i.rect(Bl+e,Vl+e,(Hl-e*2)*t,Ul-e*2),i.fill(Ut)}}var hu=3e5,gu=5e3,_u=-.8,vu=.2,yu=.4,bu=-.34,xu=.34,Su=.27,Cu=.45;function wu(e){let t=e.store&&typeof e.store==`object`?e.store:{},n=e.storeCapacityResource&&typeof e.storeCapacityResource==`object`?e.storeCapacityResource:{};return{energy:typeof t.energy==`number`?t.energy:0,energyCap:typeof n.energy==`number`?n.energy:typeof e.storeCapacity==`number`?e.storeCapacity:hu,ghodium:typeof t.G==`number`?t.G:0,ghodiumCap:typeof n.G==`number`?n.G:gu}}function Tu(e,t,n){let r=e.__nukerEnergyG;if(r&&(r.clear(),t>0)){let e=vu-_u,n=vu-e*t,i=yu*(n-_u)/e;r.poly([6+i*12,6+n*12,6+yu*12,6+vu*12,6-yu*12,6+vu*12,6-i*12,6+n*12]),r.fill(Ut)}let i=e.__nukerGhodiumG;if(i&&(i.clear(),n>0)){let e=6+bu*12,t=6+Su*12,r=(xu-bu)*12,a=(Cu-Su)*12;i.rect(e,t,r*n,a),i.fill(Al(`G`))}}var Eu=100,Du=12*.51,Ou=12*.12;function ku(e){let t=e.store&&typeof e.store==`object`?e.store:{},n=e.storeCapacityResource&&typeof e.storeCapacityResource==`object`?e.storeCapacityResource:{};return{power:typeof t.power==`number`?t.power:0,powerCap:typeof n.power==`number`?n.power:Eu}}function Au(e,t){if(e.clear(),!(t<=0)){if(t>=1)e.circle(6,6,Du);else{let n=-Math.PI/2,r=n+t*Math.PI*2;e.moveTo(6+Du*Math.cos(n),6+Du*Math.sin(n)),e.arc(6,6,Du,n,r)}e.stroke({width:Ou,color:zt})}}function ju(e,t){e.__powerSpawnPowerG&&Au(e.__powerSpawnPowerG,t)}var Mu=5e3,Nu=12/100,Pu=1.2000000000000002,Fu=3346705,Iu=6710886,Lu=2e3,Ru=15998771,zu=13832226,Bu=9240589,Vu=[-45,-75,45,-75,75,-45,75,45,45,75,-45,75,-75,45,-75,-45];function Hu(e){if(typeof e.power==`number`)return e.power;let t=e.store&&typeof e.store==`object`?e.store:{};return typeof t.power==`number`?t.power:0}function Uu(e){return Math.sqrt(Math.max(0,e)/Mu*3e3/Math.PI)*1.5*Nu}function Wu(e){let t=e%Lu/Lu;return t<1/3?xc(Ru,zu,t*3):t<2/3?xc(zu,Bu,(t-1/3)*3):xc(Bu,Ru,(t-2/3)*3)}function Gu(e,t,n){if(e.clear(),t<=0)return;let r=t*(.8+.2*Math.cos(n%Lu/Lu*2*Math.PI));e.circle(6,6,r),e.fill(Wu(n)),e.circle(6,6,r),e.stroke({width:Pu,color:Bu})}var Ku=8,qu=12*.4,Ju=12*.5,Yu=.22,Xu=12*.25,Zu=12*.32,Qu=12*.24,$u=12*.28,ed=12*.38,td=12*.36,nd=5,rd=16777215;function id(){let e=2*Math.PI/Ku,t=[];for(let n=0;n<Ku;n++){let r=-Math.PI/2+n*e,i=r-Yu,a=r+Yu,o=r-e+Yu;for(let e=0;e<=3;e++){let n=o+(i-o)*(e/3);t.push(6+qu*Math.cos(n),6+qu*Math.sin(n))}for(let e=0;e<=3;e++){let n=i+(a-i)*(e/3);t.push(6+Ju*Math.cos(n),6+Ju*Math.sin(n))}}return t}var ad=id();function od(e){return typeof e.cooldown==`number`&&e.cooldown>0}function sd(e,t){e.clear(),e.poly(ad),e.fill(W),e.poly(ad),e.stroke({width:12*.06,color:t})}function cd(e,t){e.clear();let n=.14,r=2*Math.PI/nd-n;for(let i=0;i<nd;i++){let a=-Math.PI/2+i*(2*Math.PI/nd)+n/2,o=a+r;e.moveTo(6+Xu*Math.cos(a),6+Xu*Math.sin(a)),e.arc(6,6,Zu,a,o),e.arc(6,6,Xu,o,a,!0),e.closePath(),e.fill(i<t?bt:Dn)}}function ld(e,t){return t<=0||e<=0?0:$u*Math.min(1,e/t)}function ud(e,t){let n=e.__factoryFillG;n&&(n.clear(),wl(n,ed,td+$u,Qu,t,e.__factoryBands,e.__factoryUsed??0,.5))}var dd=12*.65,fd=dd,pd=12*.42;function md(e,t,n,r,i,a,o,s){e.clear();let c=.1,l=2*Math.PI/8-c;for(let u=0;u<8;u++){let d=-Math.PI/2+u*(2*Math.PI/8)+c/2,f=d+l,p=t+i*Math.cos(d),m=n+i*Math.sin(d);if(u<a)e.moveTo(p,m),e.arc(t,n,r,d,f),e.arc(t,n,i,f,d,!0),e.closePath(),e.fill({color:14540253,alpha:.9});else if(u===a&&s>0){if(e.moveTo(p,m),e.arc(t,n,r,d,f),e.arc(t,n,i,f,d,!0),e.closePath(),e.fill({color:1973790,alpha:.85}),o>0){let a=d+l*Math.min(1,o/s);e.moveTo(p,m),e.arc(t,n,r,d,a),e.arc(t,n,i,a,d,!0),e.closePath(),e.fill({color:14540253,alpha:.9})}}else e.moveTo(p,m),e.arc(t,n,r,d,f),e.arc(t,n,i,f,d,!0),e.closePath(),e.fill({color:1973790,alpha:.6})}}function hd(e,t,n,r){let i=e.__ctrlSegSprites;if(i)for(let e=0;e<i.length;e++)e<t?i[e].alpha=1:e===t&&r>0?i[e].alpha=Math.max(.15,n/r):i[e].alpha=.15}function gd(e,t){let n=e.user;return typeof n!=`string`||!t?!1:n!==t}var _d=`2`,vd=`3`;function yd(e,t){let n=typeof e.user==`string`?e.user:void 0;return n?n===_d||t?.[n]?.username===`Invader`?`Invader`:n===vd||t?.[n]?.username===`Source Keeper`?`Source Keeper`:null:null}function bd(e,t){return(e.type===`creep`?e.spawning?-1:100:e.type===`flag`?200:0)+(e.type===`flag`?t?.flag?.zIndex??0:e.type===`controller`?t?.controller?.zIndex??0:e.type===`tombstone`?t?.tombstone?.zIndex??0:e.type===`mineral`?t?.mineral?.zIndex??0:e.type===`extractor`?Ec:t?.sprites[e.type]?.zIndex??0)}function xd(e,t=!0,n,r,i,a,o,s){let c=new He,l=new U,u=Kc(e.type),d=typeof e.user==`string`?e.user:void 0,f=d!==void 0&&n!==void 0&&d!==n?wt:Tn;switch(e.type){case`creep`:{if(yd(e,a)){Hc(c);break}let t=2*Math.PI,r=new He;r.position.set(6,6),r.rotation=-Math.PI/2;let o=gd(e,n);if(o){let e=new U;e.circle(0,0,Fs+.75),e.stroke({width:1.5,color:wt}),r.addChild(e)}let s=new U;s.circle(0,0,Fs),s.fill(Cn),r.addChild(s);let l=e.body??[],u=0,d=0,f=0,p=[],m={};for(let e of l)e.type===`work`?u++:e.type===`move`?d++:(m[e.type]===void 0&&(p.push(e.type),m[e.type]=0),m[e.type]++,f++);let h=u/Ls*t,g=d/Ls*t,_=f/Ls*t,v=h/2,y=v+_/2,b=Math.PI-g/2,x=Math.PI+g/2,S=t-h/2-_/2,C=t-h/2,w=new U;h>0&&Lc(w,-h/2,v,cn.work??16770413);let T=v;for(let e of p){let n=(m[e]??0)/Ls*t/2;Lc(w,T,T+n,cn[e]??7829367),T+=n}Lc(w,y,b,Hn),g>0&&Lc(w,b,x,cn.move??11122630),Lc(w,x,S,Hn);let E=C;for(let e of p){let n=(m[e]??0)/Ls*t/2;Lc(w,E-n,E,cn[e]??7829367),E-=n}r.addChild(w);let D=new U;D.circle(0,0,Is),D.fill(Bn),r.addChild(D);let O=typeof e.user==`string`?e.user:void 0,k=O?a?.[O]?.badge:void 0;if(k&&i){let e=new Je;e.anchor.set(.5,.5);let t=Is*2;e.width=t,e.height=t,e.rotation=Math.PI/2,r.addChild(e),c.__creepBadgeSprite=e,i.getOrCreate(k).then(t=>{e.destroyed||(e.texture=t)}).catch(()=>{})}else if(o){let e=new U;e.circle(0,0,Is*.82),e.fill({color:wt,alpha:.9}),r.addChild(e),c.__creepForeignMark=e}let{used:A,capacity:ee}=Uc(e),j=Wc(A,ee),M=new U;j>0&&(M.circle(0,0,j),M.fill(xn)),r.addChild(M),c.__creepFillGraphics=M,c.__creepUsed=A,c.__creepCapacity=ee;let te=(Fs+Is)/2,ne=(Fs-Is)*.45,re=new U;re.moveTo(Fs,0),re.lineTo(te,-ne),re.lineTo(te,ne),re.closePath(),re.fill(Fn),r.addChild(re),c.addChild(r),c.__bodyContainer=r;break}case`extension`:{let{energy:t,capacity:n}=qc(e);el(c,t,n,f),c.__extEnergy=t,c.__extCapacity=n;break}case`spawn`:{let t=12*.65;l.circle(6,6,t),l.fill(W),c.sortableChildren=!0;let n=c,r=typeof e.user==`string`?e.user:void 0,o=r?a?.[r]?.badge:void 0;if(o&&i){let e=new Je;e.anchor.set(.5,.5),e.width=t*2,e.height=t*2,e.position.set(6,6),e.zIndex=1;let r=new U;r.circle(6,6,t),r.fill(16777215),e.mask=r,c.addChild(e),c.addChild(r),n.__spawnBadgeSprite=e,i.getOrCreate(o).then(t=>{e.destroyed||(e.texture=t)}).catch(()=>{})}let{energy:s,capacity:u}=qc(e),d=new U;d.zIndex=2,c.addChild(d),n.__fillGraphics=d,tl(n,jl(s,u)),n.__spawnEnergy=s,n.__spawnCapacity=u;let f=new U;f.circle(6,6,t),f.stroke({width:12*.1,color:13421772}),f.zIndex=3,c.addChild(f);let p=new U;p.zIndex=4;let m=Mc(e,0),h=m?Pc(m.needTime,m.endTime,0):null;Fc(p,h),c.addChild(p),n.__spawnRing=p,n.__spawnRatio=h,m&&(n.__spawnNeedTime=m.needTime,n.__spawnEndTime=m.endTime),n.__spawnSig=Nc(e);break}case`powerSpawn`:{l.circle(6,6,12*.65),l.fill(W),l.circle(6,6,12*.65),l.stroke({width:12*.1,color:zt}),l.circle(6,6,12*.4),l.fill(Ut),c.sortableChildren=!0;let t=new U;t.zIndex=1;let{power:n,powerCap:r}=ku(e);Au(t,K(n,r)),c.addChild(t);let i=c;i.__powerSpawnPowerG=t,i.__powerSpawnPower=n,i.__powerSpawnPowerCap=r;break}case`source`:{let{energy:t,capacity:n}=hc(e),r=uc(t,n),i=new U;pc(i,r,performance.now()),c.addChild(i),c.__sourceGraphics=i,c.__sourceEnergy=t,c.__sourceCapacity=n,c.__sourceSize=r;break}case`constructionSite`:{let t=typeof e.user==`string`?e.user:void 0,r=t!==void 0&&t===n,i=r?mn:fn,a=r?_n:kn,o=r?Ln:Gn,s=typeof e.progress==`number`?e.progress:0,l=typeof e.progressTotal==`number`?e.progressTotal:1,u=new U;c.addChild(u),c.__csBuildGlow=u;let d=new U;Oc(d,6,6,vc,s,l,i),c.addChild(d),c.__csFillGraphics=d;let f=new U;Sc(f,i),c.addChild(f),c.__csRingGraphics=f,c.__csProgress=s,c.__csProgressTotal=l,c.__csUser=t,c.__csColor=i,c.__csColorDark=a,c.__csColorLight=o;break}case`mineral`:{let t=typeof e.mineralType==`string`?e.mineralType:`?`,n=o?.mineral;if(n&&s){let e=`mineral/${t}`,r=12*n.tileScale,i=(e,t)=>{e.texture=t,e.width=r,e.height=r},a=new Je;a.anchor.set(.5,.5),a.x=6,a.y=6,c.addChild(a);let l=s.getTexture(o.atlasUrl,e);l?i(a,l):s.getOrLoad(o.atlasUrl).then(t=>{a.destroyed||i(a,t.textures[e]??et.EMPTY)}).catch(()=>{})}else{let e=Dt[t]??7979263,n=ec[t]??16777215,r=new U;r.circle(6,6,nc),r.fill(e),c.addChild(r);let i=new Ze({text:t,style:{fontSize:rc,fill:n,fontWeight:`bold`}});i.anchor.set(.5,.5),i.scale.set(ic),i.position.set(6,6),c.addChild(i)}break}case`deposit`:{let t=typeof e.depositType==`string`?e.depositType:void 0,n=o?.deposit;if(t&&n&&s){let e=12*n.tileScale,r=(t,n)=>{t.texture=n,t.width=e,t.height=e},i=jn[t];for(let e of[`deposit/${t}/shape`,`deposit/${t}/fill`]){let t=e.endsWith(`/fill`),n=new Je;n.anchor.set(.5,.5),n.x=6,n.y=6,i!==void 0&&(n.tint=i),t&&(n.alpha=tc),c.addChild(n);let a=s.getTexture(o.atlasUrl,e);a?r(n,a):s.getOrLoad(o.atlasUrl).then(t=>{n.destroyed||r(n,t.textures[e]??et.EMPTY)}).catch(()=>{})}break}l.rect(2,2,8,8),l.fill(u),c.addChild(l);break}case`controller`:{let t=typeof e.level==`number`?e.level:0,n=typeof e.progress==`number`?e.progress:0,r=typeof e.progressTotal==`number`?e.progressTotal:0,l=e.reservation,u=typeof e.user==`string`?e.user:typeof l?.user==`string`?l.user:void 0,d=u?a?.[u]?.badge:void 0,f=o?.controller;if(f&&s){let e=12*f.tileScale,i=e/600,a=new Je;a.anchor.set(.5,.5),a.x=6,a.y=6,a.width=e,a.height=e,c.addChild(a);let l=[];for(let e=0;e<8;e++){let t=new Je;t.anchor.set(.5,.5),t.x=6,t.y=6,t.scale.set(i),t.rotation=Math.PI/4*e,c.addChild(t),l.push(t)}c.__ctrlSegSprites=l,hd(c,t,n,r);let u=()=>s.getOrLoad(o.atlasUrl),d=s.getTexture(o.atlasUrl,f.backgroundFrame);d?a.texture=d:u().then(e=>{a.destroyed||(a.texture=e.textures[f.backgroundFrame]??et.EMPTY)}).catch(()=>{});let p=s.getTexture(o.atlasUrl,f.segmentFrame);if(p)for(let e of l)e.texture=p;else u().then(e=>{let t=e.textures[f.segmentFrame]??et.EMPTY;for(let e of l)e.destroyed||(e.texture=t)}).catch(()=>{})}else{let e=new U,i=[];for(let e=0;e<8;e++){let t=-Math.PI/2+e*Math.PI/4;i.push(6+dd*Math.cos(t),6+dd*Math.sin(t))}e.poly(i),e.fill(2238513),e.poly(i),e.stroke({width:12*.07,color:8027781}),c.addChild(e);let a=new U;md(a,6,6,fd,pd,t,n,r),c.addChild(a),c.__ctrlSegGraphics=a}c.__ctrlLevel=t,c.__ctrlProgress=n,c.__ctrlProgressTotal=r,c.__ctrlDowngradeTime=typeof e.downgradeTime==`number`?e.downgradeTime:void 0,c.__ctrlUserId=u;let p=new U;if(d?(p.circle(6,6,pd),p.fill(W)):(p.circle(6,6,pd),p.fill(3028031),p.circle(6,6,pd),p.stroke({width:12*.04,color:8027781}),p.circle(6,6,12*.16),p.fill(10133672)),c.addChild(p),d&&i){let e=new Je;e.anchor.set(.5,.5),e.width=pd*2,e.height=pd*2,e.position.set(6,6);let t=new U;t.circle(6,6,pd),t.fill(16777215),c.addChild(e),e.mask=t,c.addChild(t),i.getOrCreate(d).then(t=>{e.destroyed||(e.texture=t)}).catch(()=>{})}break}case`energy`:l.circle(6,6,12*.2),l.fill(Ut);break;case`road`:break;case`constructedWall`:break;case`rampart`:break;case`tower`:{let{energy:t,capacity:n}=qc(e),r=o?.tower;if(r&&s){let e=12*r.tileScale,i=new Je;i.anchor.set(.5,.5),i.position.set(6,6),i.tint=f,c.addChild(i);let a=new He;a.position.set(6,6),c.addChild(a);let l=new Je;l.anchor.set(.5,.5),a.addChild(l);let u=new U;a.addChild(u),c.__barrelContainer=a,c.__towerFillGraphics=u,c.__towerEnergy=t,c.__towerCapacity=n;let d=a=>{let o=a.orig?.width||a.width,s=o>0?e/o:1;i.scale.set(s),l.scale.set(s),c.__towerFillRect={x:r.fill.x*s,yMin:r.fill.yMin*s,width:r.fill.width*s,heightMax:r.fill.heightMax*s,rx:r.fill.rx*s,ry:r.fill.ry*s},_l(c,gl(t,n))},p=s.getTexture(o.atlasUrl,r.ringFrame),m=s.getTexture(o.atlasUrl,r.bodyFrame);p&&m?(i.texture=p,l.texture=m,d(m)):s.getOrLoad(o.atlasUrl).then(e=>{if(i.destroyed||(i.texture=e.textures[r.ringFrame]??et.EMPTY),!l.destroyed){let t=e.textures[r.bodyFrame]??et.EMPTY;l.texture=t,c.destroyed||d(t)}}).catch(()=>{});break}let i=new U;i.circle(6,6,12*.6),i.fill(W),i.circle(6,6,12*.6),i.stroke({width:12*.05,color:f}),c.addChild(i);let a=new He;a.position.set(6,6);let l=new U;l.rect(nl,rl,il,al),l.fill(W),a.addChild(l);let u=new U;a.addChild(u),c.__towerFillGraphics=u,c.__towerEnergy=t,c.__towerCapacity=n,_l(c,gl(t,n));let d=new U;d.rect(nl,rl,il,al),d.stroke({width:1,color:Dn}),a.addChild(d);let p=new U;p.rect(-12*.2,-12*.9,12*.4,12*.5),p.fill(bt),p.rect(-12*.2,-12*.9,12*.4,12*.5),p.stroke({width:12*.07,color:W}),a.addChild(p),c.addChild(a),c.__barrelContainer=a;break}case`storage`:{let t=o?.sprites.storage;if(t&&s){let{bands:n,used:r,capacity:i}=Cl(e),a=12*t.tileScale,l=(e,t)=>{e.texture=t,e.width=a,e.height=a};for(let e of t.layers){let t=new Je;t.anchor.set(.5,.5),t.x=6,t.y=6,e.tint===`owner`&&(t.tint=f),c.addChild(t);let n=s.getTexture(o.atlasUrl,e.frame);n?l(t,n):s.getOrLoad(o.atlasUrl).then(n=>{t.destroyed||l(t,n.textures[e.frame]??et.EMPTY)}).catch(()=>{})}let u=new U;c.addChild(u),c.__storageFillG=u,c.__storageBands=n,c.__storageUsed=r,c.__storageCapacity=i,kl(c,Ol(r,i));break}let{bands:n,used:r,capacity:i}=Cl(e),a=Ic(6,6,[[-.6,-.7],[0,-.8],[.6,-.7],[.65,0],[.6,.7],[0,.8],[-.6,.7],[-.65,0],[-.6,-.7]]);l.poly(a),l.fill(W),l.poly(a),l.stroke({width:12*.05,color:f}),l.rect(6-12*.5,6-12*.6,12,12*1.2),l.fill(Dn),c.addChild(l);let u=new U;c.addChild(u),c.__storageFillG=u,c.__storageBands=n,c.__storageUsed=r,c.__storageCapacity=i,kl(c,Ol(r,i));let d=new U;d.rect(6-12*.5,6-12*.6,12,12*1.2),d.stroke({width:12*.1,color:W}),c.addChild(d);break}case`terminal`:{let t=Ic(6,6,[[0,-.8],[.55,-.55],[.8,0],[.55,.55],[0,.8],[-.55,.55],[-.8,0],[-.55,-.55],[0,-.8]]),n=Ic(6,6,[[0,-.65],[.45,-.45],[.65,0],[.45,.45],[0,.65],[-.45,.45],[-.65,0],[-.45,-.45],[0,-.65]]);l.poly(t),l.fill(W),l.poly(t),l.stroke({width:12*.05,color:f}),l.poly(n),l.fill(bt),l.rect(6-12*.45,6-12*.45,12*.9,12*.9),l.fill(Dn),l.rect(6-12*.45,6-12*.45,12*.9,12*.9),l.stroke({width:12*.1,color:W}),c.addChild(l);let{used:r,capacity:i,dominant:a}=Cl(e),o=new U;c.addChild(o);let s=c;s.__terminalFillG=o,s.__terminalDominant=a??void 0,s.__terminalFillColor=a?Al(a):Ut,s.__terminalUsed=r,s.__terminalCapacity=i,Nl(s,K(r,i));let u=new U;Ll(u,6,6),u.alpha=0,c.addChild(u),s.__terminalCooldownG=u,s.__terminalCooldownTime=fu(e);break}case`link`:{let t=Ic(6,6,[[0,-.5],[.4,0],[0,.5],[-.4,0],[0,-.5]]),n=Ic(6,6,[[0,-.3],[.25,0],[0,.3],[-.25,0],[0,-.3]]);l.poly(t),l.fill(W),l.poly(t),l.stroke({width:12*.05,color:f}),l.poly(n),l.fill(Dn),c.addChild(l);let{energy:r,capacity:i}=qc(e),a=new U;c.addChild(a);let o=c;o.__linkFillGraphics=a,o.__linkEnergy=r,o.__linkCapacity=i,$c(o,Qc(r,i));break}case`lab`:{let t=6-12*.025;l.circle(6,t,12*.55),l.fill(W),l.circle(6,t,12*.55),l.stroke({width:12*.05,color:f}),l.circle(6,t,12*.4),l.fill(Dn),c.addChild(l);let{energy:n,energyCap:r,mineralType:i,mineral:a,mineralCap:o}=pu(e),s=new U;c.addChild(s);let u=new U;u.rect(6-12*.45,9.6,12*.9,12*.25),u.fill(W),u.poly(Ic(6,6,[[-.45,.3],[-.45,.55],[.45,.55],[.45,.3]])),u.stroke({width:12*.05,color:f}),c.addChild(u);let d=new U;c.addChild(d);let p=c;p.__labMineralG=s,p.__labEnergyG=d,p.__labMineralType=i??void 0,p.__labMineralColor=i?Al(i):void 0,p.__labEnergy=n,p.__labEnergyCap=r,p.__labMineral=a,p.__labMineralCap=o,mu(p,K(n,r),K(a,o));let m=new U;Ql(m,6,t),m.alpha=0,c.addChild(m),p.__labCooldownG=m,p.__labCooldownTime=fu(e);break}case`container`:{let{bands:t,used:n,capacity:r}=Cl(e);l.rect(pl,ml,dl,fl),l.fill(W),l.rect(pl+hl,ml+hl,dl-hl*2,fl-hl*2),l.fill(Dn),c.addChild(l);let i=new U;c.addChild(i),c.__containerFillG=i,c.__containerBands=t,c.__containerUsed=n,c.__containerCapacity=r,Dl(c,El(n,r));let a=new U;a.rect(pl,ml,dl,fl),a.stroke({width:12*.1,color:W}),c.addChild(a);break}case`observer`:l.circle(6,6,12*.45),l.fill(W),l.circle(6,6,12*.45),l.stroke({width:12*.05,color:f}),l.circle(8.7,6,12*.2),l.fill(f);break;case`nuker`:{let t=Ic(6,6,[[0,-1],[-.47,.2],[-.5,.5],[.5,.5],[.47,.2],[0,-1]]),n=Ic(6,6,[[0,-.8],[-.4,.2],[.4,.2],[0,-.8]]);l.poly(t),l.fill(W),l.poly(t),l.stroke({width:12*.05,color:f}),l.poly(n),l.fill(Dn),l.poly(n),l.stroke({width:12*.01,color:f}),c.addChild(l);let{energy:r,energyCap:i,ghodium:a,ghodiumCap:o}=wu(e),s=new U;c.addChild(s);let u=new U;c.addChild(u);let d=c;d.__nukerEnergyG=s,d.__nukerGhodiumG=u,d.__nukerEnergy=r,d.__nukerEnergyCap=i,d.__nukerGhodium=a,d.__nukerGhodiumCap=o,Tu(d,K(r,i),K(a,o));break}case`factory`:{let t=typeof e.level==`number`?e.level:0,{bands:n,used:r,capacity:i}=Cl(e),a=new U;sd(a,f),c.addChild(a),l.rect(ed,td,Qu,$u),l.fill(Dn),c.addChild(l);let o=new U;cd(o,t),c.addChild(o);let s=new U;c.addChild(s);let u=c;u.__factoryGearG=a,u.__factoryRingG=o,u.__factoryFillG=s,u.__factoryBands=n,u.__factoryUsed=r,u.__factoryCapacity=i,u.__factoryLevel=t,u.__factoryCooldownEnd=fu(e),u.__factoryGlowColor=f,ud(u,ld(r,i));break}case`extractor`:{let t=new U;t.position.set(6,6),Dc(t,d===void 0?Jn:f),c.addChild(t);let n=c;n.__extractorRing=t,n.__extractorActive=od(e);break}case`invaderCore`:l.circle(6,6,12*.45),l.fill(W),l.circle(6,6,12*.45),l.stroke({width:12*.05,color:f}),l.circle(6,6,12*.35),l.fill(Dn);break;case`flag`:{let n=typeof e.color==`number`?e.color:0,r=typeof e.secondaryColor==`number`?e.secondaryColor:0,i=yn[n]??yn[0],a=yn[r]??yn[0],u=o?.flag;if(u&&s){let e=12*u.tileScale,t=()=>s.getOrLoad(o.atlasUrl),l=(t,n)=>{t.texture=n,t.width=e,t.height=e},d=new Je;d.anchor.set(.5,.5),d.x=6,d.y=6,d.tint=i,c.addChild(d);let f=s.getTexture(o.atlasUrl,u.mainFrame);if(f?l(d,f):t().then(e=>{d.destroyed||l(d,e.textures[u.mainFrame]??et.EMPTY)}).catch(()=>{}),r!==n){let e=new Je;e.anchor.set(.5,.5),e.x=6,e.y=6,e.tint=a,c.addChild(e);let n=s.getTexture(o.atlasUrl,u.secondFrame);n?l(e,n):t().then(t=>{e.destroyed||l(e,t.textures[u.secondFrame]??et.EMPTY)}).catch(()=>{})}}else{l.rect(5.28,1.5,1.44,12.599999999999998),l.fill(8947848);let e=6.720000000000001,t=14.820000000000002,n=10.92/2,r=n;l.moveTo(e,1.5),l.lineTo(t,n),l.lineTo(e,r),l.closePath(),l.fill(i),l.moveTo(e,r),l.lineTo(t,n),l.lineTo(e,9.42),l.closePath(),l.fill(a),c.addChild(l)}if(c.__flagColor=n,c.__flagSecondaryColor=r,typeof e.name==`string`){let n=new Ze({text:e.name,style:{fontSize:Rs,fill:16777215}});n.scale.set(zs),n.anchor.set(.5,0),n.x=6,n.y=12.600000000000001,n.visible=t,c.__nameLabel=n,c.addChild(n)}break}case`ruin`:{let t=typeof e.user==`string`?e.user:void 0,r=t!==void 0&&t===n?mn:wt,i=12*.42,a=Math.PI/5,o=new U;for(let e=0;e<6;e++){let t=e*Math.PI*2/6,n=t-a/2,s=t+a/2,c=6+i*Math.cos(n),l=6+i*Math.sin(n);o.moveTo(c,l),o.arc(6,6,i,n,s),o.stroke({width:12*.09,color:r,alpha:.75,cap:`round`})}c.addChild(o);let s=12*.18,l=new U;l.moveTo(6-s,6-s),l.lineTo(8.16,8.16),l.moveTo(8.16,6-s),l.lineTo(6-s,8.16),l.stroke({width:12*.11,color:r,cap:`round`}),c.addChild(l);break}case`tombstone`:{let t=typeof e.user==`string`?e.user:void 0,r=t!==void 0&&t===n?mn:wt,i=o?.tombstone;if(i&&s){let e=12*i.tileScale,t=()=>s.getOrLoad(o.atlasUrl),n=new Je;n.anchor.set(.5,.5),n.x=6,n.y=6,n.width=e,n.height=e,c.addChild(n);let a=new Je;a.anchor.set(.5,.5),a.x=6,a.y=6,a.width=e,a.height=e,a.tint=r,c.addChild(a);let l=s.getTexture(o.atlasUrl,i.shellFrame);l?n.texture=l:t().then(e=>{n.destroyed||(n.texture=e.textures[i.shellFrame]??et.EMPTY)}).catch(()=>{});let u=s.getTexture(o.atlasUrl,i.crossFrame);u?a.texture=u:t().then(e=>{a.destroyed||(a.texture=e.textures[i.crossFrame]??et.EMPTY)}).catch(()=>{})}else{let e=12*.62,t=6-e/2,n=e/2,i=new U;i.moveTo(t,4.8),i.arc(6,4.8,n,Math.PI,0,!1),i.lineTo(9.719999999999999,10.92),i.lineTo(t,10.92),i.closePath(),i.fill(W),i.moveTo(t,4.8),i.arc(6,4.8,n,Math.PI,0,!1),i.lineTo(9.719999999999999,10.92),i.lineTo(t,10.92),i.closePath(),i.stroke({width:12*.07,color:r,alpha:.9}),c.addChild(i);let a=12*.18,o=new U;o.moveTo(6-a,6-a*.6),o.lineTo(8.16,7.296),o.moveTo(8.16,6-a*.6),o.lineTo(6-a,7.296),o.stroke({width:12*.09,color:r,cap:`round`}),c.addChild(o)}break}case`powerBank`:{let t=new U,n=[];for(let e=0;e<Vu.length;e+=2)n.push(6+Vu[e]*Nu,6+Vu[e+1]*Nu);t.poly(n),t.fill(Fu),t.poly(n),t.stroke({width:Pu,color:Iu}),c.addChild(t);let r=Hu(e),i=Uu(r),a=new U;Gu(a,i,performance.now()),c.addChild(a);let o=c;o.__powerBankEllipseG=a,o.__powerBankPower=r,o.__powerBankRadius=i;break}case`keeperLair`:{l.circle(6,6,$l),l.fill(eu),l.circle(6,6,$l),l.stroke({width:nu,color:tu}),c.addChild(l);let t=new Je(du());t.anchor.set(.5),t.position.set(6,6),t.tint=ru,t.alpha=0,t.width=t.height=su*2,c.addChild(t);let n=new U;n.circle(6,6,iu),n.fill(ru),n.circle(6,6,au),n.fill(eu),c.addChild(n);let r=c;r.__keeperGlow=t,r.__keeperPhase=(e.x*31+e.y*17)%97/97;break}default:l.rect(1,1,10,10),l.fill(u)}if(e.type!==`extension`&&e.type!==`road`&&e.type!==`creep`&&e.type!==`tower`&&e.type!==`controller`&&e.type!==`flag`&&e.type!==`source`&&e.type!==`constructionSite`&&e.type!==`mineral`&&e.type!==`tombstone`&&e.type!==`ruin`&&e.type!==`storage`&&e.type!==`constructedWall`&&e.type!==`rampart`&&e.type!==`container`&&e.type!==`deposit`&&e.type!==`link`&&e.type!==`terminal`&&e.type!==`lab`&&e.type!==`nuker`&&e.type!==`factory`&&e.type!==`powerBank`&&e.type!==`keeperLair`&&c.addChild(l),e.type===`creep`&&typeof e.name==`string`){let r=gd(e,n),i;if(r){let t=typeof e.user==`string`?e.user:void 0;i=yd(e,a)??(t?a?.[t]?.username??t:`Hostile`)}else i=e.name;let o=new Ze({text:i,style:{fontSize:Rs,fill:r?wt:16777215}});o.scale.set(zs),o.anchor.set(.5,1),o.x=6,o.y=Bs-Vs,o.visible=t,c.__nameLabel=o,c.addChild(o)}return c.zIndex=bd(e,o),c.position.set(e.x*12,e.y*12),c}function Sd(e){e.destroy({children:!0})}function Cd(e){let t=new Ze({text:e.length>Js?e.slice(0,Js):e,style:{fontSize:Rs,fill:Xs,fontWeight:`600`}});t.scale.set(Hs),t.anchor.set(.5,.5);let n=t.width,r=t.height,i=n+Us*2,a=r+Ws*2,o=a/2,s=new U;s.roundRect(-i/2,-a/2,i,a,o),s.fill(Ys),s.roundRect(-i/2,-a/2,i,a,o),s.stroke({width:.4,color:1118481,alpha:.55}),s.moveTo(-2,a/2-.1),s.lineTo(0,a/2+Ks),s.lineTo(Gs,a/2-.1),s.closePath(),s.fill(Ys),s.moveTo(-2,a/2-.1),s.lineTo(0,a/2+Ks),s.lineTo(Gs,a/2-.1),s.stroke({width:.4,color:1118481,alpha:.55});let c=new He;return c.addChild(s),c.addChild(t),c.pivot.set(0,a/2+Ks),c}var wd=class{container;objects=new Map;rawObjects=new Map;roadGraphics;rampartGraphics;rampartGlowGraphics;wallGraphics;wallMarkGraphics;ticker=null;tickerCallback=null;fillAnimations=new Map;buildGlowAnimations=new Map;ctrlFlashAnimations=new Map;currentGameTime=0;sayBubbles=new Set;moveDuration=600;tickMs=2e3;lastTickAt=0;EXT_ANIM_DURATION=300;instantMode=!1;lastWorldScale=1;showLabels;currentUserId;badge;badgeCache=Ps;users;activeTheme=null;atlasCache=null;roadColor=Zt;wallColor=W;lighting=null;constructor(e,t=!0,n,r,i){this.showLabels=t,this.currentUserId=n,this.badge=r,this.users=i,this.container=new He,this.container.sortableChildren=!0,this.wallGraphics=new U,this.wallGraphics.zIndex=-3,this.container.addChild(this.wallGraphics),this.wallMarkGraphics=new U,this.wallMarkGraphics.zIndex=-2,this.container.addChild(this.wallMarkGraphics),this.rampartGraphics=new U,this.rampartGraphics.zIndex=150,this.container.addChild(this.rampartGraphics),this.rampartGlowGraphics=new U,this.rampartGlowGraphics.zIndex=149,this.rampartGlowGraphics.filters=[new Ke({strength:3,quality:3})],this.container.addChild(this.rampartGlowGraphics),this.roadGraphics=new U,this.container.addChild(this.roadGraphics),e&&(this.ticker=e,this.tickerCallback=()=>this.tick(),e.add(this.tickerCallback))}setTheme(e,t){this.activeTheme=e,this.atlasCache=t}setRoadColor(e){this.roadColor=e,this.redrawRoads()}setWallColor(e){this.wallColor=e,this.redrawWalls()}setLightingLayer(e){this.lighting=e}tick(){let e=performance.now(),t=this.lighting;for(let[n,r]of this.objects){if(r.__targetX===void 0||r.__targetY===void 0)continue;let i=r.__moveDur??0,a=e-(r.__moveStartT??e);if(i<=0||a>=i){r.position.set(r.__targetX,r.__targetY),r.__targetX=void 0,r.__targetY=void 0,r.__moveStartX=void 0,r.__moveStartY=void 0,r.__moveStartT=void 0,r.__moveDur=void 0,t?.setLightPosition(n,r.x+12/2,r.y+12/2);continue}let o=a/i,s=r.__moveStartX??r.x,c=r.__moveStartY??r.y;r.x=s+(r.__targetX-s)*o,r.y=c+(r.__targetY-c)*o,t?.setLightPosition(n,r.x+12/2,r.y+12/2)}let n=this.container.parent?.scale.x??1;if(n!==this.lastWorldScale){this.lastWorldScale=n;for(let e of this.objects.values())this.applyLabelScale(e)}let r=performance.now(),i=r/1e3,a=.5+.5*Math.sin(r*2*Math.PI/bc),o=Math.min(1,(r-this.lastTickAt)/this.tickMs),s=Math.sin(o*Math.PI);for(let e of this.objects.values()){if(e.__barrelContainer){let t=e.__barrelContainer;e.__towerAimUntil!==void 0&&r<e.__towerAimUntil&&e.__towerAimAngle!==void 0?t.rotation=ul(t.rotation,e.__towerAimAngle,sl):(e.__towerAimUntil!==void 0&&(e.__towerIdlePhase=t.rotation-i*ol,e.__towerAimUntil=void 0,e.__towerAimAngle=void 0),t.rotation=i*ol+(e.__towerIdlePhase??0))}if(e.__extractorRing){let t=e.__extractorActive===!0;t&&!e.__extractorWasActive&&(e.__extractorPhase=e.__extractorRing.rotation-i*cl),t&&(e.__extractorRing.rotation=i*cl+(e.__extractorPhase??0)),e.__extractorWasActive=t}if(e.__csRingGraphics&&e.__csColorDark!==void 0&&e.__csColorLight!==void 0&&Sc(e.__csRingGraphics,xc(e.__csColorDark,e.__csColorLight,a)),e.__factoryGearG){let t=(e.__factoryCooldownEnd??0)>this.currentGameTime;t?sd(e.__factoryGearG,xc(e.__factoryGlowColor??9419667,rd,.5*a)):e.__factoryWasOnCd&&sd(e.__factoryGearG,e.__factoryGlowColor??9419667),e.__factoryWasOnCd=t}if(e.__labCooldownG){let t=(e.__labCooldownTime??0)>this.currentGameTime;e.__labCooldownG.alpha=t?s:0}if(e.__terminalCooldownG){let t=(e.__terminalCooldownTime??0)>this.currentGameTime;e.__terminalCooldownG.alpha=t?s:0}if(e.__keeperGlow){let t=(r/ou+(e.__keeperPhase??0))%1,n=su+(1-(1-t)*(1-t))*(cu-su);e.__keeperGlow.width=e.__keeperGlow.height=n*2,e.__keeperGlow.alpha=lu*Math.sin(Math.PI*t)}}for(let[e,t]of this.fillAnimations){let n=Math.min(1,(r-t.startTime)/this.EXT_ANIM_DURATION),i=n<.5?2*n*n:1-(-2*n+2)**2/2;t.apply(t.visual,t.fromA+(t.toA-t.fromA)*i,t.fromB+(t.toB-t.fromB)*i),n>=1&&this.fillAnimations.delete(e)}for(let e of this.objects.values()){let t=e.__sourceGraphics;t&&pc(t,e.__sourceSize??ac,r)}for(let e of this.objects.values()){let t=e.__powerBankEllipseG;t&&Gu(t,e.__powerBankRadius??0,r)}for(let[e,t]of this.buildGlowAnimations){let n=this.objects.get(e),i=n?.__csBuildGlow;if(!n||!i){this.buildGlowAnimations.delete(e);continue}let a=(r-t.startTime)/t.duration,o;o=a<=0?0:a<.5?a/.5:a<.7?1:a<1?1-(a-.7)/.3:0,i.clear(),o>0&&(i.circle(12/2,12/2,yc),i.fill({color:Ut,alpha:o*.75})),a>=1&&this.buildGlowAnimations.delete(e)}for(let[e,t]of this.ctrlFlashAnimations){let n=this.objects.get(e),i=n?.__ctrlSegSprites;if(!n||!i){this.ctrlFlashAnimations.delete(e);continue}let a=Math.min(1,(r-t.startTime)/t.duration),o=1-(1-a)*(1-a),s=i[t.segIndex];s&&!s.destroyed&&(s.alpha=1-.85*o),a>=1&&(s&&!s.destroyed&&(s.alpha=.15),this.ctrlFlashAnimations.delete(e))}for(let e of this.objects.values()){let t=e.__ctrlLevel,n=e.__ctrlSegSprites;if(!t||!n)continue;let i=e.__ctrlDowngradeTime;if(!i){for(let e=0;e<t;e++){let t=n[e];t&&!t.destroyed&&(t.tint=16777215)}continue}let a=Ns[t]??2e4,o=1-Math.max(0,i-this.currentGameTime)/a;if(o<=.2){for(let e=0;e<t;e++){let t=n[e];t&&!t.destroyed&&(t.tint=16777215)}continue}let s=(o-.2)/.8,c=.3+s*1.5,l=.5+.5*Math.sin(2*Math.PI*c*r/1e3),u=xc(16777215,xc(16768477,16720418,s),s*l);for(let e=0;e<t;e++){let t=n[e];t&&!t.destroyed&&(t.tint=u)}}this.lighting?.render()}startFill(e,t,n,r,i,a=0,o=0){if(this.instantMode){n(t,i,o);return}r===i&&a===o||this.fillAnimations.set(e,{visual:t,fromA:r,toA:i,fromB:a,toB:o,apply:n,startTime:performance.now()})}startExtAnimation(e,t,n,r,i,a){this.startFill(e,t,tl,Yc(n,r),Yc(i,a))}startLinkAnimation(e,t,n,r,i,a){this.startFill(e,t,$c,Qc(n,r),Qc(i,a))}startCreepFillAnimation(e,t,n,r,i,a){this.startFill(e,t,Gc,Wc(n,r),Wc(i,a))}startTowerFillAnimation(e,t,n,r,i,a){this.startFill(e,t,_l,gl(n,r),gl(i,a))}startStorageFillAnimation(e,t,n,r,i,a){this.startFill(e,t,kl,Ol(n,r),Ol(i,a))}startContainerFillAnimation(e,t,n,r,i,a){this.startFill(e,t,Dl,El(n,r),El(i,a))}startTerminalFillAnimation(e,t,n,r,i,a){this.startFill(e,t,Nl,K(n,r),K(i,a))}startFactoryFillAnimation(e,t,n,r,i,a){this.startFill(e,t,ud,ld(n,r),ld(i,a))}startLabFillAnimation(e,t,n,r,i,a,o,s,c,l){this.startFill(e,t,mu,K(n,r),K(o,s),K(i,a),K(c,l))}startNukerFillAnimation(e,t,n,r,i,a,o,s,c,l){this.startFill(e,t,Tu,K(n,r),K(o,s),K(i,a),K(c,l))}startSourceAnimation(e,t,n,r,i,a){this.startFill(e,t,mc,uc(n,r),uc(i,a))}startPowerSpawnPowerAnimation(e,t,n,r,i,a){this.startFill(e,t,ju,K(n,r),K(i,a))}startSpawnFillAnimation(e,t,n,r,i,a){this.startFill(e,t,tl,jl(n,r),jl(i,a))}update(e,t,n,r){n&&(this.users=n),r!==void 0&&(r!==this.currentGameTime&&(this.lastTickAt=performance.now()),this.currentGameTime=r);let i=!1,a=!1,o=!1;if(t)for(let n in t)if(t[n]===null){let e=this.rawObjects.get(n);e&&e.type===`road`&&(i=!0),e&&e.type===`constructedWall`&&(a=!0),e&&e.type===`rampart`&&(o=!0);let t=this.objects.get(n);t&&(this.container.removeChild(t),Sd(t),this.objects.delete(n),this.rawObjects.delete(n),this.fillAnimations.delete(n),this.buildGlowAnimations.delete(n),this.ctrlFlashAnimations.delete(n),this.sayBubbles.delete(n))}else{let t=e[n];if(!t)continue;if(t.type===`road`){let e=this.rawObjects.get(n);(!e||e.x!==t.x||e.y!==t.y)&&(i=!0)}else if(t.type===`constructedWall`){let e=this.rawObjects.get(n);(!e||e.x!==t.x||e.y!==t.y)&&(a=!0)}else if(t.type===`rampart`){let e=this.rawObjects.get(n);(!e||e.x!==t.x||e.y!==t.y||e.user!==t.user)&&(o=!0)}this.rawObjects.set(n,t);let r=this.objects.get(n);if(r){let e=t.x*12,i=t.y*12;if(t.type===`creep`){let a=t.x-(r.__tileX??t.x),o=t.y-(r.__tileY??t.y);(a!==0||o!==0)&&(r.__angle=Math.atan2(o,a),r.__bodyContainer&&(r.__bodyContainer.rotation=r.__angle)),r.__tileX=t.x,r.__tileY=t.y,this.instantMode?(r.position.set(e,i),r.__targetX=void 0,r.__targetY=void 0,r.__moveStartX=void 0,r.__moveStartY=void 0,r.__moveStartT=void 0,r.__moveDur=void 0):(r.x!==e||r.y!==i)&&(r.__targetX=e,r.__targetY=i,r.__moveStartX=r.x,r.__moveStartY=r.y,r.__moveStartT=performance.now(),r.__moveDur=this.moveDuration);let{used:s,capacity:c}=Uc(t);(r.__creepUsed!==s||r.__creepCapacity!==c)&&(this.startCreepFillAnimation(n,r,r.__creepUsed??0,r.__creepCapacity??c,s,c),r.__creepUsed=s,r.__creepCapacity=c);let l=bd(t,this.activeTheme);r.zIndex!==l&&(r.zIndex=l)}else if(t.type===`flag`){let a=typeof t.color==`number`?t.color:0,o=typeof t.secondaryColor==`number`?t.secondaryColor:0;if(r.__flagColor!==a||r.__flagSecondaryColor!==o){this.container.removeChild(r),Sd(r),this.objects.delete(n);let e=xd(t,this.showLabels,this.currentUserId,this.badge,this.badgeCache,this.users,this.activeTheme,this.atlasCache);e.__tileX=t.x,e.__tileY=t.y,this.applyLabelScale(e),this.objects.set(n,e),this.container.addChild(e)}else r.position.set(e,i)}else r.position.set(e,i);if(t.type===`extension`){let{energy:e,capacity:i}=qc(t),a=r;(a.__extEnergy!==e||a.__extCapacity!==i)&&(this.startExtAnimation(n,r,a.__extEnergy??0,a.__extCapacity??i,e,i),a.__extEnergy=e,a.__extCapacity=i)}if(t.type===`link`){let{energy:e,capacity:i}=qc(t);(r.__linkEnergy!==e||r.__linkCapacity!==i)&&(this.startLinkAnimation(n,r,r.__linkEnergy??0,r.__linkCapacity??i,e,i),r.__linkEnergy=e,r.__linkCapacity=i)}if(t.type===`tower`){let{energy:e,capacity:i}=qc(t);(r.__towerEnergy!==e||r.__towerCapacity!==i)&&(this.startTowerFillAnimation(n,r,r.__towerEnergy??0,r.__towerCapacity??i,e,i),r.__towerEnergy=e,r.__towerCapacity=i)}if(t.type===`storage`){let{bands:e,used:i,capacity:a}=Cl(t);if(r.__storageUsed!==i||r.__storageCapacity!==a){let t=r.__storageUsed??0,o=r.__storageCapacity??a;r.__storageBands=e,r.__storageUsed=i,r.__storageCapacity=a,this.startStorageFillAnimation(n,r,t,o,i,a)}else Tl(r.__storageBands,e)||(r.__storageBands=e,kl(r,Ol(i,a)))}if(t.type===`container`){let{bands:e,used:i,capacity:a}=Cl(t);if(r.__containerUsed!==i||r.__containerCapacity!==a){let t=r.__containerUsed??0,o=r.__containerCapacity??a;r.__containerBands=e,r.__containerUsed=i,r.__containerCapacity=a,this.startContainerFillAnimation(n,r,t,o,i,a)}else Tl(r.__containerBands,e)||(r.__containerBands=e,Dl(r,El(i,a)))}if(t.type===`terminal`){let{used:e,capacity:i,dominant:a}=Cl(t),o=a??void 0;if(r.__terminalDominant!==o&&(r.__terminalDominant=o,r.__terminalFillColor=o?Al(o):Ut,Nl(r,K(e,i))),r.__terminalUsed!==e||r.__terminalCapacity!==i){let t=r.__terminalUsed??0,a=r.__terminalCapacity??i;r.__terminalUsed=e,r.__terminalCapacity=i,this.startTerminalFillAnimation(n,r,t,a,e,i)}r.__terminalCooldownTime=fu(t)}if(t.type===`lab`){let{energy:e,energyCap:i,mineralType:a,mineral:o,mineralCap:s}=pu(t),c=a??void 0;if(r.__labMineralType!==c&&(r.__labMineralType=c,r.__labMineralColor=a?Al(a):void 0,mu(r,K(e,i),K(o,s))),r.__labEnergy!==e||r.__labEnergyCap!==i||r.__labMineral!==o||r.__labMineralCap!==s){let t=r.__labEnergy??0,a=r.__labEnergyCap??i,c=r.__labMineral??0,l=r.__labMineralCap??s;r.__labEnergy=e,r.__labEnergyCap=i,r.__labMineral=o,r.__labMineralCap=s,this.startLabFillAnimation(n,r,t,a,c,l,e,i,o,s)}r.__labCooldownTime=fu(t)}if(t.type===`nuker`){let{energy:e,energyCap:i,ghodium:a,ghodiumCap:o}=wu(t);if(r.__nukerEnergy!==e||r.__nukerEnergyCap!==i||r.__nukerGhodium!==a||r.__nukerGhodiumCap!==o){let t=r.__nukerEnergy??0,s=r.__nukerEnergyCap??i,c=r.__nukerGhodium??0,l=r.__nukerGhodiumCap??o;r.__nukerEnergy=e,r.__nukerEnergyCap=i,r.__nukerGhodium=a,r.__nukerGhodiumCap=o,this.startNukerFillAnimation(n,r,t,s,c,l,e,i,a,o)}}if(t.type===`powerSpawn`){let{power:e,powerCap:i}=ku(t);if(r.__powerSpawnPower!==e||r.__powerSpawnPowerCap!==i){let t=r.__powerSpawnPower??0,a=r.__powerSpawnPowerCap??i;r.__powerSpawnPower=e,r.__powerSpawnPowerCap=i,this.startPowerSpawnPowerAnimation(n,r,t,a,e,i)}}if(t.type===`extractor`&&(r.__extractorActive=od(t)),t.type===`factory`){let{bands:e,used:i,capacity:a}=Cl(t),o=typeof t.level==`number`?t.level:0;if(r.__factoryLevel!==o&&r.__factoryRingG&&(r.__factoryLevel=o,cd(r.__factoryRingG,o)),r.__factoryCooldownEnd=fu(t),r.__factoryUsed!==i||r.__factoryCapacity!==a){let t=r.__factoryUsed??0,o=r.__factoryCapacity??a;r.__factoryBands=e,r.__factoryUsed=i,r.__factoryCapacity=a,this.startFactoryFillAnimation(n,r,t,o,i,a)}else Tl(r.__factoryBands,e)||(r.__factoryBands=e,ud(r,ld(i,a)))}if(t.type===`controller`){let e=typeof t.level==`number`?t.level:0,i=typeof t.progress==`number`?t.progress:0,a=typeof t.progressTotal==`number`?t.progressTotal:0,o=t.reservation,s=typeof t.user==`string`?t.user:typeof o?.user==`string`?o.user:void 0;if(r.__ctrlUserId!==s){this.container.removeChild(r),Sd(r),this.objects.delete(n);let e=xd(t,this.showLabels,this.currentUserId,this.badge,this.badgeCache,this.users,this.activeTheme,this.atlasCache);e.__tileX=t.x,e.__tileY=t.y,this.applyLabelScale(e),this.objects.set(n,e),this.container.addChild(e);continue}(r.__ctrlLevel!==e||r.__ctrlProgress!==i||r.__ctrlProgressTotal!==a)&&(r.__ctrlSegSprites?(!this.instantMode&&e<8&&i>(r.__ctrlProgress??0)&&this.ctrlFlashAnimations.set(n,{segIndex:e,startTime:performance.now(),duration:400}),hd(r,e,i,a)):r.__ctrlSegGraphics&&md(r.__ctrlSegGraphics,12/2,12/2,fd,pd,e,i,a),r.__ctrlLevel=e,r.__ctrlProgress=i,r.__ctrlProgressTotal=a);let c=typeof t.downgradeTime==`number`?t.downgradeTime:void 0;r.__ctrlDowngradeTime!==c&&(r.__ctrlDowngradeTime=c)}if(t.type===`source`){let{energy:e,capacity:i}=hc(t);(r.__sourceEnergy!==e||r.__sourceCapacity!==i)&&(this.startSourceAnimation(n,r,r.__sourceEnergy??0,r.__sourceCapacity??i,e,i),r.__sourceEnergy=e,r.__sourceCapacity=i)}if(t.type===`constructionSite`){let e=typeof t.progress==`number`?t.progress:0,n=typeof t.progressTotal==`number`?t.progressTotal:1;(r.__csProgress!==e||r.__csProgressTotal!==n)&&(r.__csFillGraphics&&Oc(r.__csFillGraphics,12/2,12/2,vc,e,n,r.__csColor??9419667),r.__csProgress=e,r.__csProgressTotal=n)}if(t.type===`powerBank`){let e=Hu(t);r.__powerBankPower!==e&&(r.__powerBankPower=e,r.__powerBankRadius=Uu(e))}}else{let e=xd(t,this.showLabels,this.currentUserId,this.badge,this.badgeCache,this.users,this.activeTheme,this.atlasCache);e.__tileX=t.x,e.__tileY=t.y,this.applyLabelScale(e),this.objects.set(n,e),this.container.addChild(e)}}else{let t=new Set;for(let n in e){let r=e[n];if(!r)continue;t.add(n),this.rawObjects.set(n,r);let i=this.objects.get(n);if(i){let e=r.x*12,t=r.y*12;if(r.type===`creep`){let a=r.x-(i.__tileX??r.x),o=r.y-(i.__tileY??r.y);(a!==0||o!==0)&&(i.__angle=Math.atan2(o,a),i.__bodyContainer&&(i.__bodyContainer.rotation=i.__angle)),i.__tileX=r.x,i.__tileY=r.y,this.instantMode?(i.position.set(e,t),i.__targetX=void 0,i.__targetY=void 0,i.__moveStartX=void 0,i.__moveStartY=void 0,i.__moveStartT=void 0,i.__moveDur=void 0):(i.x!==e||i.y!==t)&&(i.__targetX=e,i.__targetY=t,i.__moveStartX=i.x,i.__moveStartY=i.y,i.__moveStartT=performance.now(),i.__moveDur=this.moveDuration);let{used:s,capacity:c}=Uc(r);(i.__creepUsed!==s||i.__creepCapacity!==c)&&(this.startCreepFillAnimation(n,i,i.__creepUsed??0,i.__creepCapacity??c,s,c),i.__creepUsed=s,i.__creepCapacity=c);let l=bd(r,this.activeTheme);i.zIndex!==l&&(i.zIndex=l)}else if(r.type===`flag`){let a=typeof r.color==`number`?r.color:0,o=typeof r.secondaryColor==`number`?r.secondaryColor:0;if(i.__flagColor!==a||i.__flagSecondaryColor!==o){this.container.removeChild(i),Sd(i),this.objects.delete(n);let e=xd(r,this.showLabels,this.currentUserId,this.badge,this.badgeCache,this.users,this.activeTheme,this.atlasCache);e.__tileX=r.x,e.__tileY=r.y,this.applyLabelScale(e),this.objects.set(n,e),this.container.addChild(e)}else i.position.set(e,t)}else i.position.set(e,t);if(r.type===`extension`){let{energy:e,capacity:t}=qc(r),a=i;(a.__extEnergy!==e||a.__extCapacity!==t)&&(this.startExtAnimation(n,i,a.__extEnergy??0,a.__extCapacity??t,e,t),a.__extEnergy=e,a.__extCapacity=t)}if(r.type===`link`){let{energy:e,capacity:t}=qc(r);(i.__linkEnergy!==e||i.__linkCapacity!==t)&&(this.startLinkAnimation(n,i,i.__linkEnergy??0,i.__linkCapacity??t,e,t),i.__linkEnergy=e,i.__linkCapacity=t)}if(r.type===`tower`){let{energy:e,capacity:t}=qc(r);(i.__towerEnergy!==e||i.__towerCapacity!==t)&&(this.startTowerFillAnimation(n,i,i.__towerEnergy??0,i.__towerCapacity??t,e,t),i.__towerEnergy=e,i.__towerCapacity=t)}if(r.type===`controller`){let e=typeof r.level==`number`?r.level:0,t=typeof r.progress==`number`?r.progress:0,a=typeof r.progressTotal==`number`?r.progressTotal:0,o=r.reservation,s=typeof r.user==`string`?r.user:typeof o?.user==`string`?o.user:void 0;if(i.__ctrlUserId!==s){this.container.removeChild(i),Sd(i),this.objects.delete(n);let e=xd(r,this.showLabels,this.currentUserId,this.badge,this.badgeCache,this.users,this.activeTheme,this.atlasCache);e.__tileX=r.x,e.__tileY=r.y,this.applyLabelScale(e),this.objects.set(n,e),this.container.addChild(e);continue}(i.__ctrlLevel!==e||i.__ctrlProgress!==t||i.__ctrlProgressTotal!==a)&&(i.__ctrlSegSprites?(!this.instantMode&&e>(i.__ctrlLevel??0)&&e>0&&this.ctrlFlashAnimations.set(n,{segIndex:e-1,startTime:performance.now(),duration:500}),hd(i,e,t,a)):i.__ctrlSegGraphics&&md(i.__ctrlSegGraphics,12/2,12/2,fd,pd,e,t,a),i.__ctrlLevel=e,i.__ctrlProgress=t,i.__ctrlProgressTotal=a);let c=typeof r.downgradeTime==`number`?r.downgradeTime:void 0;i.__ctrlDowngradeTime!==c&&(i.__ctrlDowngradeTime=c)}if(r.type===`source`){let{energy:e,capacity:t}=hc(r);(i.__sourceEnergy!==e||i.__sourceCapacity!==t)&&(this.startSourceAnimation(n,i,i.__sourceEnergy??0,i.__sourceCapacity??t,e,t),i.__sourceEnergy=e,i.__sourceCapacity=t)}if(r.type===`constructionSite`){let e=typeof r.progress==`number`?r.progress:0,t=typeof r.progressTotal==`number`?r.progressTotal:1;(i.__csProgress!==e||i.__csProgressTotal!==t)&&(i.__csFillGraphics&&Oc(i.__csFillGraphics,12/2,12/2,vc,e,t,i.__csColor??9419667),i.__csProgress=e,i.__csProgressTotal=t)}if(r.type===`powerBank`){let e=typeof r.power==`number`?r.power:0;i.__powerBankPower!==e&&(i.__powerBankPower=e,i.__powerBankRadius=Uu(e))}}else{let e=xd(r,this.showLabels,this.currentUserId,this.badge,this.badgeCache,this.users,this.activeTheme,this.atlasCache);e.__tileX=r.x,e.__tileY=r.y,this.applyLabelScale(e),this.objects.set(n,e),this.container.addChild(e)}}for(let[e,n]of this.objects)t.has(e)||(this.container.removeChild(n),Sd(n),this.objects.delete(e),this.rawObjects.delete(e),this.fillAnimations.delete(e),this.buildGlowAnimations.delete(e),this.ctrlFlashAnimations.delete(e),this.sayBubbles.delete(e));i=!0,a=!0,o=!0}a&&this.redrawWalls(),o&&this.redrawRamparts(),i&&this.redrawRoads();for(let[e,t]of this.objects){if(!t.__spawnRing)continue;let n=this.rawObjects.get(e),r=n?Nc(n):null;if(r!==t.__spawnSig){t.__spawnSig=r;let e=n&&r?Mc(n,this.currentGameTime):null;t.__spawnNeedTime=e?.needTime,t.__spawnEndTime=e?.endTime}let i=t.__spawnNeedTime!==void 0&&t.__spawnEndTime!==void 0?Pc(t.__spawnNeedTime,t.__spawnEndTime,this.currentGameTime):null;if(i!==t.__spawnRatio&&(Fc(t.__spawnRing,i),t.__spawnRatio=i),n){let{energy:r,capacity:i}=qc(n);(t.__spawnEnergy!==r||t.__spawnCapacity!==i)&&(this.startSpawnFillAnimation(e,t,t.__spawnEnergy??0,t.__spawnCapacity??i,r,i),t.__spawnEnergy=r,t.__spawnCapacity=i)}}this.refreshForeignCreepLabels(),this.refreshForeignCreepBadges()}redrawWalls(){this.wallGraphics.clear(),this.wallMarkGraphics.clear();let e=Array.from({length:50},()=>Array(50).fill(!1)),t=[];for(let n of this.rawObjects.values())n.type===`constructedWall`&&typeof n.x==`number`&&typeof n.y==`number`&&n.x>=0&&n.x<50&&n.y>=0&&n.y<50&&(e[n.x][n.y]=!0,t.push({x:n.x,y:n.y}));if(t.length===0)return;let n=t=>{let n=!1;for(let r=0;r<50;r++)for(let i=0;i<50;i++){let a=e[i][r],o=r>0&&e[i][r-1],s=r<49&&e[i][r+1],c=i>0&&e[i-1][r],l=i<49&&e[i+1][r],u=i*12+6,d=r*12+6;a?(n=!0,!o&&!c&&r>0&&i>0?(t.moveTo(u,r*12),t.arc(u,d,6,-Math.PI/2,Math.PI,!0),t.lineTo(u,d),t.closePath()):t.rect(i*12,r*12,6,6)):o&&c&&e[i-1][r-1]&&(n=!0,t.moveTo(u,r*12),t.lineTo(i*12,r*12),t.lineTo(i*12,d),t.arc(u,d,6,Math.PI,-Math.PI/2,!1),t.closePath()),a?!o&&!l&&r>0&&i<49?(t.moveTo(u,r*12),t.arc(u,d,6,-Math.PI/2,0,!1),t.lineTo(u,d),t.closePath()):t.rect(u,r*12,6,6):o&&l&&e[i+1][r-1]&&(n=!0,t.moveTo(u,r*12),t.lineTo(i*12+12,r*12),t.lineTo(i*12+12,d),t.arc(u,d,6,0,-Math.PI/2,!0),t.closePath()),a?!s&&!c&&r<49&&i>0?(t.moveTo(i*12,d),t.arc(u,d,6,Math.PI,Math.PI/2,!0),t.lineTo(u,d),t.closePath()):t.rect(i*12,d,6,6):s&&c&&e[i-1][r+1]&&(n=!0,t.moveTo(i*12,d),t.lineTo(i*12,r*12+12),t.lineTo(u,r*12+12),t.arc(u,d,6,Math.PI/2,Math.PI,!1),t.closePath()),a?!s&&!l&&r<49&&i<49?(t.moveTo(u,r*12+12),t.arc(u,d,6,Math.PI/2,0,!0),t.lineTo(u,d),t.closePath()):t.rect(u,d,6,6):s&&l&&e[i+1][r+1]&&(n=!0,t.moveTo(u,r*12+12),t.lineTo(i*12+12,r*12+12),t.lineTo(i*12+12,d),t.arc(u,d,6,0,Math.PI/2,!1),t.closePath())}return n};n(this.wallGraphics)&&this.wallGraphics.stroke({color:0,width:12*.06,alignment:0,cap:`round`,join:`round`}),n(this.wallGraphics),this.wallGraphics.fill(this.wallColor);let r=12*.32,i=12*.09;for(let{x:e,y:n}of t){let t=e*12,a=n*12;this.wallMarkGraphics.rect(t+12*.12,a+12*.3,r,i),this.wallMarkGraphics.rect(t+12*.56,a+12*.58,r,i)}this.wallMarkGraphics.fill({color:4210752})}redrawRoads(){this.roadGraphics.clear();let e=this.roadColor,t=Array.from({length:50},()=>Array(50).fill(!1)),n=[];for(let e of this.rawObjects.values())e.type===`road`&&(n.push(e),e.x>=0&&e.x<50&&e.y>=0&&e.y<50&&(t[e.x][e.y]=!0));if(n.length===0)return;let r=12*.125;for(let e of n)this.roadGraphics.circle(e.x*12+6,e.y*12+6,r);this.roadGraphics.fill(e);let i=[[1,0],[1,1],[0,1],[-1,1]];for(let e of n){let n=e.x*12+6,r=e.y*12+6;for(let[a,o]of i){let i=e.x+a,s=e.y+o;if(i>=0&&i<50&&s>=0&&s<50&&t[i][s]){let e=i*12+6,t=s*12+6;this.roadGraphics.moveTo(n,r),this.roadGraphics.lineTo(e,t)}}}this.roadGraphics.stroke({width:r*2,color:e})}redrawRamparts(){this.rampartGraphics.clear(),this.rampartGlowGraphics.clear();let e=Array.from({length:50},()=>Array(50).fill(void 0));for(let t of this.rawObjects.values())t.type===`rampart`&&t.x>=0&&t.x<50&&t.y>=0&&t.y<50&&(e[t.x][t.y]=typeof t.user==`string`?t.user:void 0);let t=e=>!e||!this.currentUserId||e===this.currentUserId?{color:Vt,alpha:.4}:{color:Gt,alpha:.36},n=Array.from({length:50},()=>Array(50).fill(!1)),r=Array.from({length:50},()=>Array(50).fill(!1));for(let t=0;t<50;t++)for(let i=0;i<50;i++){let a=e[i][t];a!==void 0&&(!this.currentUserId||a===this.currentUserId?n[i][t]=!0:r[i][t]=!0)}let i=(e,t)=>{let n=t=>{let n=!1,r=(e,r,i,a)=>{t.moveTo(e,r),t.lineTo(i,a),n=!0},i=(e,r,i,a,o,s,c)=>{t.moveTo(e,r),t.arc(s,c,6,i,a,o),n=!0};for(let t=0;t<50;t++)for(let n=0;n<50;n++){let a=t>0&&e[n][t-1],o=t<49&&e[n][t+1],s=n>0&&e[n-1][t],c=n<49&&e[n+1][t],l=n>0&&t>0&&e[n-1][t-1],u=n<49&&t>0&&e[n+1][t-1],d=n>0&&t<49&&e[n-1][t+1],f=n<49&&t<49&&e[n+1][t+1],p=n*12+6,m=t*12+6;e[n][t]?(!a&&!s&&t>0&&n>0?i(p,t*12,-Math.PI/2,Math.PI,!0,p,m):(!a&&!(s&&l)&&r(n*12,t*12,p,t*12),!s&&!(a&&l)&&r(n*12,t*12,n*12,m)),!a&&!c&&t>0&&n<49?i(p,t*12,-Math.PI/2,0,!1,p,m):(!a&&!(c&&u)&&r(p,t*12,n*12+12,t*12),!c&&!(a&&u)&&r(n*12+12,t*12,n*12+12,m)),!o&&!s&&t<49&&n>0?i(n*12,m,Math.PI,Math.PI/2,!0,p,m):(!o&&!(s&&d)&&r(n*12,t*12+12,p,t*12+12),!s&&!(o&&d)&&r(n*12,m,n*12,t*12+12)),!o&&!c&&t<49&&n<49?i(p,t*12+12,Math.PI/2,0,!0,p,m):(!o&&!(c&&f)&&r(p,t*12+12,n*12+12,t*12+12),!c&&!(o&&f)&&r(n*12+12,m,n*12+12,t*12+12))):(a&&s&&l&&i(n*12,m,Math.PI,-Math.PI/2,!1,p,m),a&&c&&u&&i(n*12+12,m,0,-Math.PI/2,!0,p,m),o&&s&&d&&i(p,t*12+12,Math.PI/2,Math.PI,!1,p,m),o&&c&&f&&i(n*12+12,m,0,Math.PI/2,!1,p,m))}return n};n(this.rampartGlowGraphics)&&this.rampartGlowGraphics.stroke({color:t,width:12*.3,alpha:.55,alignment:.5,cap:`butt`,join:`round`}),n(this.rampartGraphics)&&this.rampartGraphics.stroke({color:t,width:12*.08,alpha:.9,alignment:.5,cap:`butt`,join:`round`})};for(let n=0;n<50;n++)for(let r=0;r<50;r++){let i=e[r][n],a=i!==void 0,o=n>0&&e[r][n-1]!==void 0,s=n<49&&e[r][n+1]!==void 0,c=r>0&&e[r-1][n]!==void 0,l=r<49&&e[r+1][n]!==void 0,u=r*12+6,d=n*12+6;if(a){let e=t(i);!o&&!c&&n>0&&r>0?(this.rampartGraphics.moveTo(u,n*12),this.rampartGraphics.arc(u,d,6,-Math.PI/2,Math.PI,!0),this.rampartGraphics.lineTo(u,d),this.rampartGraphics.fill(e)):(this.rampartGraphics.rect(r*12,n*12,6,6),this.rampartGraphics.fill(e))}else if(o&&c&&e[r-1][n-1]!==void 0){let i=t(e[r-1][n-1]);this.rampartGraphics.moveTo(u,n*12),this.rampartGraphics.lineTo(r*12,n*12),this.rampartGraphics.lineTo(r*12,d),this.rampartGraphics.arc(u,d,6,Math.PI,-Math.PI/2,!1),this.rampartGraphics.fill(i)}if(a){let e=t(i);!o&&!l&&n>0&&r<49?(this.rampartGraphics.moveTo(u,n*12),this.rampartGraphics.arc(u,d,6,-Math.PI/2,0,!1),this.rampartGraphics.lineTo(u,d),this.rampartGraphics.fill(e)):(this.rampartGraphics.rect(u,n*12,6,6),this.rampartGraphics.fill(e))}else if(o&&l&&e[r+1][n-1]!==void 0){let i=t(e[r+1][n-1]);this.rampartGraphics.moveTo(u,n*12),this.rampartGraphics.lineTo(r*12+12,n*12),this.rampartGraphics.lineTo(r*12+12,d),this.rampartGraphics.arc(u,d,6,0,-Math.PI/2,!0),this.rampartGraphics.fill(i)}if(a){let e=t(i);!s&&!c&&n<49&&r>0?(this.rampartGraphics.moveTo(r*12,d),this.rampartGraphics.arc(u,d,6,Math.PI,Math.PI/2,!0),this.rampartGraphics.lineTo(u,d),this.rampartGraphics.fill(e)):(this.rampartGraphics.rect(r*12,d,6,6),this.rampartGraphics.fill(e))}else if(s&&c&&e[r-1][n+1]!==void 0){let i=t(e[r-1][n+1]);this.rampartGraphics.moveTo(r*12,d),this.rampartGraphics.lineTo(r*12,n*12+12),this.rampartGraphics.lineTo(u,n*12+12),this.rampartGraphics.arc(u,d,6,Math.PI/2,Math.PI,!1),this.rampartGraphics.fill(i)}if(a){let e=t(i);!s&&!l&&n<49&&r<49?(this.rampartGraphics.moveTo(u,n*12+12),this.rampartGraphics.arc(u,d,6,Math.PI/2,0,!0),this.rampartGraphics.lineTo(u,d),this.rampartGraphics.fill(e)):(this.rampartGraphics.rect(u,d,6,6),this.rampartGraphics.fill(e))}else if(s&&l&&e[r+1][n+1]!==void 0){let i=t(e[r+1][n+1]);this.rampartGraphics.moveTo(u,n*12+12),this.rampartGraphics.lineTo(r*12+12,n*12+12),this.rampartGraphics.lineTo(r*12+12,d),this.rampartGraphics.arc(u,d,6,0,Math.PI/2,!1),this.rampartGraphics.fill(i)}}i(n,Nt),i(r,kt)}getObjectsAtTile(e,t){let n=[];for(let[r,i]of this.objects){let a=this.rawObjects.get(r);a&&a.x===e&&a.y===t&&n.push({id:r,obj:a,visual:i})}return n}applyLabelScale(e){let t=this.lastWorldScale||1;e.__nameLabel&&(e.__nameLabel.scale.set(zs/t),e.__nameLabel.anchor.y===0?e.__nameLabel.y=12.600000000000001:e.__nameLabel.y=Bs-Vs/t),e.__sayBubble&&!e.__sayBubble.destroyed&&(e.__sayBubble.scale.set(1/t),e.__sayBubble.position.set(12/2,Bs-qs/t))}refreshForeignCreepLabels(){if(this.currentUserId)for(let[e,t]of this.objects){let n=this.rawObjects.get(e);if(!n||n.type!==`creep`||!t.__nameLabel||!gd(n,this.currentUserId))continue;let r=typeof n.user==`string`?n.user:void 0,i=yd(n,this.users)??(r?this.users?.[r]?.username??r:`Hostile`);t.__nameLabel.text!==i&&(t.__nameLabel.text=i)}}refreshForeignCreepBadges(){if(this.currentUserId)for(let[e,t]of this.objects){let n=this.rawObjects.get(e);if(!n||n.type!==`creep`||!gd(n,this.currentUserId)||t.__creepBadgeSprite)continue;let r=typeof n.user==`string`?n.user:void 0,i=r?this.users?.[r]?.badge:void 0;if(!i)continue;let a=t.__bodyContainer;if(!a)continue;t.__creepForeignMark&&!t.__creepForeignMark.destroyed&&(a.removeChild(t.__creepForeignMark),t.__creepForeignMark.destroy(),t.__creepForeignMark=void 0);let o=new Je;o.anchor.set(.5,.5);let s=Is*2;o.width=s,o.height=s,o.rotation=Math.PI/2,a.addChild(o),t.__creepBadgeSprite=o,this.badgeCache.getOrCreate(i).then(e=>{o.destroyed||(o.texture=e)}).catch(()=>{o.destroyed||(a.removeChild(o),o.destroy()),t.__creepBadgeSprite=void 0})}}triggerBuildAt(e,t,n){if(!this.instantMode)for(let[r,i]of this.objects){let a=this.rawObjects.get(r);if(!(!a||a.type!==`constructionSite`)&&!(a.x!==e||a.y!==t)&&i.__csBuildGlow){this.buildGlowAnimations.set(r,{startTime:performance.now(),duration:n});return}}}triggerTowerAim(e,t,n,r){if(this.instantMode)return;let i=this.objects.get(e);if(!i||!i.__barrelContainer)return;let a=this.rawObjects.get(e);if(!a)return;let o=t-a.x,s=n-a.y;o===0&&s===0||(i.__towerAimAngle=Math.atan2(s,o)+ll,i.__towerAimUntil=performance.now()+r)}triggerSay(e,t){let n=this.objects.get(e);if(!n||n.__sayMessage===t&&n.__sayBubble&&!n.__sayBubble.destroyed)return;n.__sayBubble&&!n.__sayBubble.destroyed&&(n.removeChild(n.__sayBubble),n.__sayBubble.destroy({children:!0}));let r=Cd(t);n.addChild(r),n.__sayBubble=r,n.__sayMessage=t,this.applyLabelScale(n),this.sayBubbles.add(e)}setMoveDuration(e){this.moveDuration=Math.max(0,e)}setTickDuration(e){this.tickMs=Math.max(1,e)}pruneSayBubblesExcept(e){if(this.sayBubbles.size!==0)for(let t of this.sayBubbles){if(e.has(t))continue;let n=this.objects.get(t);n?.__sayBubble&&!n.__sayBubble.destroyed&&(n.removeChild(n.__sayBubble),n.__sayBubble.destroy({children:!0})),n&&(n.__sayBubble=void 0,n.__sayMessage=void 0),this.sayBubbles.delete(t)}}setInstantMode(e){if(this.instantMode=e,e){for(let e of this.objects.values())e.__targetX!==void 0&&(e.position.set(e.__targetX,e.__targetY),e.__targetX=void 0,e.__targetY=void 0,e.__moveStartX=void 0,e.__moveStartY=void 0,e.__moveStartT=void 0,e.__moveDur=void 0),e.__sayBubble&&!e.__sayBubble.destroyed&&(e.removeChild(e.__sayBubble),e.__sayBubble.destroy({children:!0}),e.__sayBubble=void 0,e.__sayMessage=void 0);this.sayBubbles.clear();for(let e of this.fillAnimations.values())e.apply(e.visual,e.toA,e.toB);this.fillAnimations.clear(),this.buildGlowAnimations.clear(),this.ctrlFlashAnimations.clear()}}setShowLabels(e){this.showLabels=e;for(let t of this.objects.values())t.__nameLabel&&(t.__nameLabel.visible=e)}getVisualById(e){return this.objects.get(e)}clear(){for(let e of this.objects.values())Sd(e);this.objects.clear(),this.rawObjects.clear(),this.fillAnimations.clear(),this.buildGlowAnimations.clear(),this.ctrlFlashAnimations.clear(),this.sayBubbles.clear(),this.roadGraphics.clear(),this.rampartGraphics.clear(),this.rampartGlowGraphics.clear(),this.container.removeChildren(),this.container.addChild(this.rampartGraphics),this.container.addChild(this.rampartGlowGraphics),this.container.addChild(this.roadGraphics)}destroy(){this.clear(),this.ticker&&this.tickerCallback&&this.ticker.remove(this.tickerCallback),this.ticker=null,this.tickerCallback=null}},Td=2,Ed=3,Dd=12*.45,Od=.55;function kd(e,t){return{cx:e*12+12/2,cy:t*12+12/2}}var Ad=class{container;graphics;animations=[];ticker=null;tickerCallback=null;constructor(e){this.container=new He,this.graphics=new U,this.container.addChild(this.graphics),e&&(this.ticker=e,this.tickerCallback=()=>this.animate(),e.add(this.tickerCallback))}addHarvest(e,t,n,r,i){let a=kd(e,t),o=kd(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:Pt,width:Td,glowAtSource:!0})}addUpgradeController(e,t,n,r,i){let a=kd(e,t),o=kd(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:Nn,width:Td})}addTransfer(e,t,n,r,i){let a=kd(e,t),o=kd(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:Un,width:Td})}addBuild(e,t,n,r,i){let a=kd(e,t),o=kd(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:Rn,width:Td})}addRepair(e,t,n,r,i){let a=kd(e,t),o=kd(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:rn,width:Td})}addLinkTransfer(e,t,n,r,i){let a=kd(e,t),o=kd(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:tn,width:Td})}addLabReaction(e,t,n,r,i){let a=kd(e,t),o=kd(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:nn,width:Td})}addTowerBeam(e,t,n,r,i,a){let o=kd(e,t),s=kd(n,r);this.animations.push({fromX:o.cx,fromY:o.cy,toX:s.cx,toY:s.cy,startTime:performance.now(),duration:i,color:a,width:Ed})}addTowerAttack(e,t,n,r,i){this.addTowerBeam(e,t,n,r,i,Kt)}addTowerHeal(e,t,n,r,i){this.addTowerBeam(e,t,n,r,i,vt)}addTowerRepair(e,t,n,r,i){this.addTowerBeam(e,t,n,r,i,hn)}animate(){this.graphics.clear();let e=performance.now(),t=!1;for(let n=this.animations.length-1;n>=0;n--){let r=this.animations[n],i=e-r.startTime,a=Math.min(1,i/r.duration),o,s,c,l,u=.5,d=.2;if(a<u){let e=a/u;o=r.fromX,s=r.fromY,c=r.fromX+(r.toX-r.fromX)*e,l=r.fromY+(r.toY-r.fromY)*e}else if(a<.7)o=r.fromX,s=r.fromY,c=r.toX,l=r.toY;else{let e=(a-u-d)/(1-u-d);o=r.fromX+(r.toX-r.fromX)*e,s=r.fromY+(r.toY-r.fromY)*e,c=r.toX,l=r.toY}if(this.graphics.moveTo(o,s),this.graphics.lineTo(c,l),this.graphics.stroke({width:r.width,color:r.color}),a>=u){let e=(a-u)/(1-u),t=(1-e)*Od,n=r.width/Td*Dd*(.7+.5*e),i=r.glowAtSource?r.fromX:r.toX,o=r.glowAtSource?r.fromY:r.toY;this.graphics.circle(i,o,n),this.graphics.fill({color:r.color,alpha:t*.4}),this.graphics.circle(i,o,n*.55),this.graphics.fill({color:r.color,alpha:t})}t=!0,a>=1&&this.animations.splice(n,1)}t||this.graphics.clear()}clear(){this.animations.length=0,this.graphics.clear()}destroy(){this.clear(),this.ticker&&this.tickerCallback&&this.ticker.remove(this.tickerCallback),this.ticker=null,this.tickerCallback=null,this.graphics.destroy(),this.container.destroy()}},jd=e=>(e+.5)*12,Md={dashed:[.3*12,.25*12],dotted:[.1*12,.2*12]},Nd=2400;function Pd(e){if(e==null)return .7;if(typeof e==`number`)return e;let t=e.match(/^([0-9.]+)(px)?/);if(!t)return .7;let n=parseFloat(t[1]);return t[2]?n/12:n}function Fd(e){if(typeof e!=`string`)return`sans-serif`;let t=e.match(/^[0-9.]+(px)?\s+(.+)$/);return t?t[2]:`sans-serif`}var Id=class{container;canvas;ctx;texture;sprite;resolution;world;ticker;lastRaw=``;lastPhysSize=0;prevScaleX=-1;constructor(e,t,n){this.resolution=e.resolution,this.world=t,this.ticker=n,this.canvas=document.createElement(`canvas`),this.ctx=this.canvas.getContext(`2d`);let r=this.idealPhysSize();this.canvas.width=r,this.canvas.height=r,this.texture=et.from(this.canvas,!0),this.lastPhysSize=r,this.sprite=new Je(this.texture),this.sprite.scale.set(600/r),this.container=new He,this.container.label=`visuals`,this.container.addChild(this.sprite),this.ticker.add(this.onTick,this)}idealPhysSize(){return Math.min(Math.ceil(this.world.scale.x*this.resolution*600),Nd)}onTick=()=>{let e=this.world.scale.x,t=this.idealPhysSize();e===this.prevScaleX&&t!==this.lastPhysSize&&this.lastRaw&&(this.resizeTo(t),this.redraw()),this.prevScaleX=e};update(e){this.lastRaw=e;let t=this.idealPhysSize();t!==this.lastPhysSize&&this.resizeTo(t),this.redraw()}resizeTo(e){this.canvas.width=e,this.canvas.height=e;let t=this.texture;this.texture=et.from(this.canvas,!0),this.sprite.texture=this.texture,this.sprite.scale.set(600/e),t.destroy(!0),this.lastPhysSize=e}redraw(){let{ctx:e,canvas:t}=this;if(e.clearRect(0,0,t.width,t.height),!this.lastRaw){this.sprite.visible=!1,this.texture.source.update();return}let n=t.width/600;e.save(),e.scale(n,n);for(let e of this.lastRaw.split(`
|
|
3
|
+
`)){if(!e.trim())continue;let t;try{t=JSON.parse(e)}catch{continue}let n=t.s??{},r=n.opacity??1;switch(t.t){case`l`:this.drawLine(t,n,r);break;case`c`:this.drawCircle(t,n,r);break;case`r`:this.drawRect(t,n,r);break;case`p`:this.drawPoly(t,n,r);break;case`t`:this.drawText(t,n,r);break}}e.restore(),this.texture.source.update(),this.sprite.visible=!0}drawLine(e,t,n){let{ctx:r}=this;r.save(),r.globalAlpha=n,r.strokeStyle=t.color??`#ffffff`,r.lineWidth=(t.width??.1)*12,r.setLineDash(t.lineStyle===`dotted`?Md.dotted:t.lineStyle===`dashed`?Md.dashed:[]),r.beginPath(),r.moveTo(jd(e.x1),jd(e.y1)),r.lineTo(jd(e.x2),jd(e.y2)),r.stroke(),r.restore()}drawCircle(e,t,n){let{ctx:r}=this;r.save(),r.globalAlpha=n,r.setLineDash(t.lineStyle===`dotted`?Md.dotted:t.lineStyle===`dashed`?Md.dashed:[]),r.beginPath(),r.arc(jd(e.x),jd(e.y),(t.radius??.5)*12,0,2*Math.PI),t.fill&&t.fill!==`transparent`&&(r.fillStyle=t.fill,r.fill()),t.stroke&&t.strokeWidth&&(r.strokeStyle=t.stroke,r.lineWidth=t.strokeWidth*12,r.stroke()),r.restore()}drawRect(e,t,n){let{ctx:r}=this;r.save(),r.globalAlpha=n,r.setLineDash(t.lineStyle===`dotted`?Md.dotted:t.lineStyle===`dashed`?Md.dashed:[]),r.beginPath(),r.rect(jd(e.x),jd(e.y),e.w*12,e.h*12),t.fill&&t.fill!==`transparent`&&(r.fillStyle=t.fill,r.fill()),t.stroke&&t.strokeWidth&&(r.strokeStyle=t.stroke,r.lineWidth=t.strokeWidth*12,r.stroke()),r.restore()}drawPoly(e,t,n){if(!e.points?.length)return;let{ctx:r}=this;r.save(),r.globalAlpha=n,r.setLineDash(t.lineStyle===`dotted`?Md.dotted:t.lineStyle===`dashed`?Md.dashed:[]),r.beginPath(),r.moveTo(jd(e.points[0][0]),jd(e.points[0][1]));for(let t=1;t<e.points.length;t++)r.lineTo(jd(e.points[t][0]),jd(e.points[t][1]));t.fill&&t.fill!==`transparent`&&(r.fillStyle=t.fill,r.fill()),t.stroke&&t.strokeWidth&&(r.closePath(),r.strokeStyle=t.stroke,r.lineWidth=t.strokeWidth*12,r.stroke()),r.restore()}drawText(e,t,n){let{ctx:r}=this,i=Pd(t.font)*12,a=Fd(t.font),o=t.align??`left`,s=jd(e.x),c=jd(e.y);if(r.save(),r.globalAlpha=n,r.font=`${i}px ${a}`,r.textAlign=o,r.textBaseline=`middle`,t.backgroundColor&&t.backgroundColor!==`transparent`){let n=r.measureText(e.text).width,a=(t.backgroundPadding??.3)*12,l=o===`center`?.5:+(o===`right`);r.fillStyle=t.backgroundColor,r.fillRect(s-l*n-a,c-i/2-a,n+a*2,i+a*2)}r.fillStyle=t.color??`#ffffff`,t.stroke&&t.strokeWidth&&(r.strokeStyle=t.stroke,r.lineWidth=t.strokeWidth*12,r.lineJoin=`round`,r.strokeText(e.text,s,c)),r.fillText(e.text,s,c),r.restore()}destroy(){this.ticker.remove(this.onTick,this),this.texture.destroy(!0),this.container.destroy({children:!0})}},Ld=Symbol(`store-raw`),Rd=Symbol(`store-node`),zd=Symbol(`store-has`),Bd=Symbol(`store-self`),Vd={onStoreNodeUpdate:null};function Hd(e){let t=e[_];if(!t&&(Object.defineProperty(e,_,{value:t=new Proxy(e,Xd)}),!Array.isArray(e))){let n=Object.keys(e),r=Object.getOwnPropertyDescriptors(e),i=Object.getPrototypeOf(e),a=i!==null&&typeof e==`object`&&!!e&&!Array.isArray(e)&&i!==Object.prototype;if(a){let e=Object.getOwnPropertyDescriptors(i);n.push(...Object.keys(e)),Object.assign(r,e)}for(let i=0,o=n.length;i<o;i++){let o=n[i];a&&o===`constructor`||r[o].get&&Object.defineProperty(e,o,{configurable:!0,enumerable:r[o].enumerable,get:r[o].get.bind(t)})}}return t}function Ud(e){let t;return typeof e==`object`&&!!e&&(e[_]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function Wd(e,t=new Set){let n,r,i,a;if(n=e!=null&&e[Ld])return n;if(!Ud(e)||t.has(e))return e;if(Array.isArray(e)){Object.isFrozen(e)?e=e.slice(0):t.add(e);for(let n=0,a=e.length;n<a;n++)i=e[n],(r=Wd(i,t))!==i&&(e[n]=r)}else{Object.isFrozen(e)?e=Object.assign({},e):t.add(e);let n=Object.keys(e),o=Object.getOwnPropertyDescriptors(e);for(let s=0,c=n.length;s<c;s++)a=n[s],!o[a].get&&(i=e[a],(r=Wd(i,t))!==i&&(e[a]=r))}return e}function Gd(e,t){let n=e[t];return n||Object.defineProperty(e,t,{value:n=Object.create(null)}),n}function Kd(t,n,r){if(t[n])return t[n];let[i,a]=e(r,{equals:!1,internal:!0});return i.$=a,t[n]=i}function qd(e,t){let n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||!n.configurable||t===_||t===Rd?n:(delete n.value,delete n.writable,n.get=()=>e[_][t],n)}function Jd(e){v()&&Kd(Gd(e,Rd),Bd)()}function Yd(e){return Jd(e),Reflect.ownKeys(e)}var Xd={get(e,t,n){if(t===Ld)return e;if(t===_)return n;if(t===g)return Jd(e),n;let r=Gd(e,Rd),i=r[t],a=i?i():e[t];if(t===Rd||t===zd||t===`__proto__`)return a;if(!i){let n=Object.getOwnPropertyDescriptor(e,t);v()&&(typeof a!=`function`||Object.prototype.hasOwnProperty.call(e,t))&&!(n&&n.get)&&(a=Kd(r,t,a)())}return Ud(a)?Hd(a):a},has(e,t){return t===Ld||t===_||t===g||t===Rd||t===zd||t===`__proto__`?!0:(v()&&Kd(Gd(e,zd),t)(),t in e)},set(){return console.warn(`Cannot mutate a Store directly`),!0},deleteProperty(){return console.warn(`Cannot mutate a Store directly`),!0},ownKeys:Yd,getOwnPropertyDescriptor:qd};function Zd(e,t,n,r=!1){if(t===`__proto__`){console.warn(`Refusing to set "__proto__" on a store.`);return}if(!r&&e[t]===n)return;let i=e[t],a=e.length;Vd.onStoreNodeUpdate&&Vd.onStoreNodeUpdate(e,t,n,i),n===void 0?(delete e[t],e[zd]&&e[zd][t]&&i!==void 0&&e[zd][t].$()):(e[t]=n,e[zd]&&e[zd][t]&&i===void 0&&e[zd][t].$());let o=Gd(e,Rd),s;if((s=Kd(o,t,i))&&s.$(()=>n),Array.isArray(e)&&e.length!==a){for(let t=e.length;t<a;t++)(s=o[t])&&s.$();(s=Kd(o,`length`,a))&&s.$(e.length)}(s=o[Bd])&&s.$()}function Qd(e,t){let n=Object.keys(t);for(let r=0;r<n.length;r+=1){let i=n[r];$d(i)||Zd(e,i,t[i])}}function $d(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function ef(e,t){if(typeof t==`function`&&(t=t(e)),t=Wd(t),Array.isArray(t)){if(e===t)return;let n=0,r=t.length;for(;n<r;n++){let r=t[n];e[n]!==r&&Zd(e,n,r)}Zd(e,`length`,r)}else Qd(e,t)}function tf(e,t,n=[]){let r,i=e;if(t.length>1){r=t.shift();let a=typeof r,o=Array.isArray(e);if(a===`string`&&(r===`__proto__`||t.length>1&&$d(r))){console.warn(`Refusing to traverse unsafe key "${r}" on a store.`);return}if(Array.isArray(r)){for(let i=0;i<r.length;i++)tf(e,[r[i]].concat(t),n);return}else if(o&&a===`function`){for(let i=0;i<e.length;i++)r(e[i],i)&&tf(e,[i].concat(t),n);return}else if(o&&a===`object`){let{from:i=0,to:a=e.length-1,by:o=1}=r;for(let r=i;r<=a;r+=o)tf(e,[r].concat(t),n);return}else if(t.length>1){tf(e[r],t,[r].concat(n));return}i=e[r],n=[r].concat(n)}let a=t[0];typeof a==`function`&&(a=a(i,n),a===i)||r===void 0&&a==null||(a=Wd(a),r===void 0||Ud(i)&&Ud(a)&&!Array.isArray(a)?Qd(i,a):Zd(e,r,a))}function nf(...[e,t]){let n=Wd(e||{}),r=Array.isArray(n);if(typeof n!=`object`&&typeof n!=`function`)throw Error(`Unexpected type ${typeof n} received when initializing 'createStore'. Expected an object.`);let i=Hd(n);m.registerGraph({value:n,name:t&&t.name});function a(...e){f(()=>{r&&e.length===1?ef(n,e[0]):tf(n,e)})}return[i,a]}var rf=Symbol(`store-root`);function af(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function of(e,t,n,r,i){if(af(n))return;let a=t[n];if(e===a)return;let o=Array.isArray(e);if(n!==rf&&(!Ud(e)||!Ud(a)||o!==Array.isArray(a)||i&&e[i]!==a[i])){Zd(t,n,e);return}if(o){if(e.length&&a.length&&(!r||i&&e[0]&&e[0][i]!=null)){let t,n,o,s,c,l,u,d;for(o=0,s=Math.min(a.length,e.length);o<s&&(a[o]===e[o]||i&&a[o]&&e[o]&&a[o][i]&&a[o][i]===e[o][i]);o++)of(e[o],a,o,r,i);let f=Array(e.length),p=new Map;for(s=a.length-1,c=e.length-1;s>=o&&c>=o&&(a[s]===e[c]||i&&a[s]&&e[c]&&a[s][i]&&a[s][i]===e[c][i]);s--,c--)f[c]=a[s];if(o>c||o>s){for(n=o;n<=c;n++)Zd(a,n,e[n]);for(;n<e.length;n++)Zd(a,n,f[n]),of(e[n],a,n,r,i);a.length>e.length&&Zd(a,`length`,e.length);return}for(u=Array(c+1),n=c;n>=o;n--)l=e[n],d=i&&l?l[i]:l,t=p.get(d),u[n]=t===void 0?-1:t,p.set(d,n);for(t=o;t<=s;t++)l=a[t],d=i&&l?l[i]:l,n=p.get(d),n!==void 0&&n!==-1&&(f[n]=a[t],n=u[n],p.set(d,n));for(n=o;n<e.length;n++)n in f?(Zd(a,n,f[n]),of(e[n],a,n,r,i)):Zd(a,n,e[n])}else for(let t=0,n=e.length;t<n;t++)of(e[t],a,t,r,i);a.length>e.length&&Zd(a,`length`,e.length);return}let s=Object.keys(e);for(let t=0,n=s.length;t<n;t++)af(s[t])||of(e[s[t]],a,s[t],r,i);let c=Object.keys(a);for(let t=0,n=c.length;t<n;t++)e[c[t]]===void 0&&Zd(a,c[t],void 0)}function sf(e,t={}){let{merge:n,key:r=`id`}=t,i=Wd(e);return e=>{if(!Ud(e)||!Ud(i))return i;let t=of(i,{[rf]:e},rf,n,r);return t===void 0?e:t}}var cf=new WeakMap;function lf(e,t){let[n,r]=nf(t),i={id:e,type:t.type,raw:n};return cf.set(i,e=>r(sf(e,{key:`_id`,merge:!1}))),i}var[uf,df]=e([]);function ff(){df([])}function pf(e){df(t=>t.filter(t=>t.id!==e))}function mf(e,t){let n=uf(),r=!1,i=[];for(let a of n){let n=e[a.id];if(n===null){r=!0;continue}if(n!==void 0){let e=t[a.id];e&&cf.get(a)?.(e)}i.push(a)}r&&df(i)}function hf(e){let t=uf();if(t.length===0)return;let n=!1,r=[];for(let i of t){let t=e[i.id];if(!t){n=!0;continue}cf.get(i)?.(t),r.push(i)}n&&df(r)}var[q,gf]=e(!1),[_f,vf]=e(0),[yf,bf]=e(0),[xf,Sf]=e(0),[Cf,wf]=e(!1),[Tf,Ef]=e(1),[Df,Of]=e(!1),kf=null;function Af(){kf!==null&&(clearInterval(kf),kf=null)}function jf(){Af(),kf=setInterval(()=>{let e=_f()+1;e>xf()?(Af(),wf(!1)):vf(e)},Math.max(50,Math.round(1e3/Tf())))}var Mf=2e5;function Nf(e,t,n){let r=e,i=Math.max(0,r-(t==null?Mf:t===0?r:t)),a=n&&n>0?n:0,o=a>0?Math.max(i,e-e%a-a):e;Sf(r),bf(i),vf(Math.max(i,o)),wf(!1),Af(),gf(!0)}function Pf(){Af(),wf(!1),gf(!1)}function Ff(e){vf(Math.max(yf(),Math.min(xf(),e)))}function If(e){Ff(_f()+e)}function Lf(){Cf()?(Af(),wf(!1)):(wf(!0),jf())}function Rf(){Af(),wf(!1)}function zf(e){Ef(e),Cf()&&jf()}var Bf=class extends Error{constructor(e){super(e),this.name=`HistoryUnavailableError`}};function Vf(e){if(e?.status===404)return!0;let t=e?.message;return typeof t==`string`&&t.includes(`HTTP 404`)}var Hf=class{room;shard;http;chunkSize;chunkCache=new Map;inflight=new Map;constructor(e,t,n,r){this.room=e,this.shard=t,this.http=n,this.chunkSize=r}chunkBase(e){return e-e%this.chunkSize}loadChunk(e){let t=this.chunkCache.get(e);if(t)return Promise.resolve(t);let n=this.inflight.get(e);if(n)return n;let r=this.http.game.roomHistory(this.room,e,this.shard).then(t=>(this.chunkCache.set(e,t),this.inflight.delete(e),t)).catch(t=>{throw this.inflight.delete(e),t});return this.inflight.set(e,r),r}applyDiff(e,t){let n={...e};for(let e in t){let r=t[e];r===null?delete n[e]:n[e]?n[e]={...n[e],...r}:n[e]=r}return n}async getStateAtTick(e){let t=this.chunkBase(e),n,r;try{n=await this.loadChunk(t)}catch(i){let a=t-this.chunkSize;if(a<0)throw Vf(i)?new Bf(`No history data available for tick ${e}`):i;try{n=await this.loadChunk(a)}catch(t){throw Vf(t)?new Bf(`No history data available for tick ${e}`):t}t=a;let o=Object.keys(n.ticks).map(Number).filter(e=>e>=t),s=o.length>0?Math.max(...o):t;r=s,e=s}let i=n.ticks[String(t)]??{},a={};for(let e in i)i[e]!==null&&(a[e]=i[e]);for(let r=t+1;r<=e;r++){let e=n.ticks[String(r)];e&&Object.keys(e).length>0&&(a=this.applyDiff(a,e))}return{objects:a,diff:n.ticks[String(e)]??{},gameTime:e,clampedTo:r}}},Uf=z(`<div style=text-align:center;display:flex;flex-direction:column;align-items:center;gap:6px><div style=font-size:14px;font-weight:600;color:#f85149>You have no rooms!</div><button style="padding:4px 12px;border-radius:4px;border:1px solid #238636;background:#1a3a2a;color:#3fb950;font-size:12px;cursor:pointer">Place Spawn`),Wf=z(`<div style=text-align:center;display:flex;flex-direction:column;align-items:center;gap:6px><div style=font-size:14px;font-weight:600;color:#f85149>You lost all your spawns!</div><button style="padding:4px 12px;border-radius:4px;border:1px solid #da3633;background:#3d1a1a;color:#f85149;font-size:12px;cursor:pointer">Respawn`),Gf=z(`<div style=display:flex;flex-direction:column;gap:2px;text-align:center><span>Moving "<!>" → </span><span style=opacity:0.6;font-size:0.9em>Navigate rooms or change target in sidebar · Right-click to cancel`),Kf=z(`<div style=display:flex;flex-direction:column;gap:2px;text-align:center><span></span><span style=opacity:0.6;font-size:0.9em>Right-click to exit flag mode`),qf=z(`<div style=display:flex;flex-direction:column;gap:2px;text-align:center><span>Select a structure type, then click to build</span><span style=opacity:0.6;font-size:0.9em>Ctrl+click to remove construction sites</span><span style=opacity:0.6;font-size:0.9em>Right-click to exit build mode`),Jf=z(`<div style=display:flex;flex-direction:column;gap:2px;text-align:center><span></span><span style=opacity:0.6;font-size:0.9em>Ctrl+click to remove construction sites</span><span style=opacity:0.6;font-size:0.9em>Right-click to exit build mode`),{log:Yf,warn:Xf,error:Zf}=ce(`build`),Qf={COLOR_RED:1,COLOR_PURPLE:2,COLOR_BLUE:3,COLOR_CYAN:4,COLOR_GREEN:5,COLOR_YELLOW:6,COLOR_ORANGE:7,COLOR_BROWN:8,COLOR_GREY:9,COLOR_WHITE:10},$f={spawn:{0:0,1:1,2:1,3:1,4:1,5:1,6:1,7:2,8:3},extension:{0:0,1:0,2:5,3:10,4:20,5:30,6:40,7:50,8:60},link:{1:0,2:0,3:0,4:0,5:2,6:3,7:4,8:6},road:{0:2500,1:2500,2:2500,3:2500,4:2500,5:2500,6:2500,7:2500,8:2500},constructedWall:{1:0,2:2500,3:2500,4:2500,5:2500,6:2500,7:2500,8:2500},rampart:{1:0,2:2500,3:2500,4:2500,5:2500,6:2500,7:2500,8:2500},storage:{1:0,2:0,3:0,4:1,5:1,6:1,7:1,8:1},tower:{1:0,2:0,3:1,4:1,5:2,6:2,7:3,8:6},observer:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:1},powerSpawn:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:1},extractor:{1:0,2:0,3:0,4:0,5:0,6:1,7:1,8:1},terminal:{1:0,2:0,3:0,4:0,5:0,6:1,7:1,8:1},lab:{1:0,2:0,3:0,4:0,5:0,6:3,7:6,8:10},container:{0:5,1:5,2:5,3:5,4:5,5:5,6:5,7:5,8:5},nuker:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:1},factory:{1:0,2:0,3:0,4:0,5:0,6:0,7:1,8:1}},[ep,tp]=e(`view`),[np,rp]=e({name:``,color:`COLOR_WHITE`,secondaryColor:`COLOR_WHITE`}),[ip,ap]=e(null),[op,sp]=e(null),[cp,lp]=e({structureType:``,structureName:``});y(()=>{p(()=>{let e=cp().structureType;if(!e)return;let t=pr()??0,n=$f[e];if(!n)return;let r=O()===`empty`&&e===`spawn`?Math.max(n[t]??0,1):n[t]??0;r!==2500&&(hr()[e]??0)>=r&&(lp({structureType:``,structureName:``}),up())})});function up(){ap(null)}function dp(){sp(null)}function fp(){lp({structureType:``,structureName:``})}function pp(e,t){let n=L(),r=cp(),i=ip();if(!n||!r.structureType||!i){Xf(`missing requirements`,{hasClient:!!n,structureType:r.structureType,pending:i});return}if(O()===`empty`&&r.structureType===`spawn`){Yf(`placing spawn`,{room:e,x:i.tx,y:i.ty,name:r.structureName||void 0,shard:t??void 0}),n.http.game.placeSpawn(e,i.tx,i.ty,r.structureName||void 0,t??void 0).then(()=>(Yf(`spawn placed`),j(`Spawn placed successfully`,`success`),up(),n.stores.user.refreshWorldStatus())).catch(e=>{Zf(`place spawn failed:`,e),j(`Failed to place spawn: ${e.message}`,`error`)});return}Yf(`creating construction site`,{room:e,x:i.tx,y:i.ty,structureType:r.structureType,name:r.structureName||void 0,shard:t??void 0}),n.http.game.createConstruction(e,i.tx,i.ty,r.structureType,r.structureName||void 0,t??void 0).then(()=>{Yf(`construction site created`),j(`Construction site for ${r.structureType} created`,`success`),up()}).catch(e=>{Zf(`create construction failed:`,e),j(`Failed to create construction site: ${e.message}`,`error`)})}function mp(){tp(`view`),up(),dp(),fp()}function hp(){tp(`view`),up(),w(op)?.type!==`moveFlag`&&dp(),fp()}function gp(){let e=ep(),t=ip(),n=op(),r=O();if(r===`empty`)return(()=>{var e=Uf(),t=e.firstChild.nextSibling;return t.$$click=()=>{tp(`build`),lp({structureType:`spawn`,structureName:``})},e})();if(r===`lost`)return(()=>{var e=Wf(),t=e.firstChild.nextSibling;return t.$$click=()=>{let e=L();e&&e.http.user.respawn().then(()=>{j(`Respawn successful`,`success`),Ae()}).catch(e=>{j(`Respawn failed: ${e.message}`,`error`)})},e})();if(n?.type===`moveFlag`)return(()=>{var e=Gf(),t=e.firstChild,r=t.firstChild.nextSibling;return r.nextSibling,t.nextSibling,T(t,()=>n.name,r),T(t,()=>n.targetRoom,null),e})();if(e===`flag`)return(()=>{var e=Kf(),n=e.firstChild;return n.nextSibling,T(n,t?`Click again to confirm position`:`Click to choose flag position`),e})();if(e===`build`){let e=cp(),t=pr(),n=hr(),r=e.structureType;if(!r)return(()=>{var e=qf();return e.firstChild.nextSibling.nextSibling,e})();let i=$f[r]?.[t??0]??0,a=n[r]??0,o=r.replace(/([A-Z])/g,` $1`).trim(),s=i===2500?`${a}/∞`:`${a}/${i}`;return(()=>{var e=Jf(),t=e.firstChild;return t.nextSibling.nextSibling,T(t,`Click to build ${o} (${s})`),e})()}return null}P([`click`]);var _p=z(`<div style="position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);padding:16px 22px;border-radius:8px;background:rgba(13, 17, 23, 0.9);border:1px solid #30363d;text-align:center;max-width:320px;pointer-events:none;user-select:none;z-index:11"><div style=font-size:14px;font-weight:600;color:#c9d1d9;margin-bottom:4px>No data available for this tick</div><div style=font-size:12px;color:#8b949e>Use the timeline below to choose another tick.`),vp=z(`<div style="position:absolute;bottom:0;left:0;right:0;padding:8px 12px;background:rgba(13, 17, 23, 0.85);border-top:1px solid #30363d;z-index:10"><input type=range step=1 style=width:100%;cursor:pointer><div style=display:flex;justify-content:space-between;font-size:10px;color:#8b949e;margin-top:2px><span></span><span></span><span>`),yp=z(`<div style=width:100%;height:100%;position:relative><div style=width:100%;height:100%>`),bp=z(`<div style="position:absolute;top:12px;left:50%;transform:translateX(-50%);padding:6px 16px;border-radius:6px;background:rgba(13, 17, 23, 0.65);border:1px solid rgba(48, 54, 61, 0.6);font-size:13px;font-weight:500;color:#c9d1d9;user-select:none;z-index:10">`),xp=z(`<div style="position:absolute;top:8px;right:8px;padding:4px 10px;border-radius:4px;background:rgba(13, 17, 23, 0.8);border:1px solid #30363d;font-size:12px;color:#8b949e;z-index:10">Tick `),{log:Sp,error:Cp}=ce(`room`);function wp(e,t,n=4){e.http.game.genUniqueFlagName().then(r=>{if(r.name===t&&n>0){setTimeout(()=>wp(e,t,n-1),200);return}rp(e=>({...e,name:r.name}))}).catch(e=>Cp(`gen unique flag name failed:`,e))}function Tp(t){let i=e=>e==="default"?Ct:null,s,c=null,l=null,u=null,d=null,f=null,[m,g]=e(null),[_,v]=e(null),[y,b]=e(null),[x,S]=e(null),[C,E]=e(``),[D,k]=e(!1),[A,ee]=e(_f());p(()=>ee(_f()));let M=null;return o(async()=>{if(!s)return;let e=await ms.create(s);g(e)}),a(()=>{M!==null&&clearTimeout(M),c?.destroy(),c=null,u?.destroy(),u=null,d?.destroy(),d=null;let e=m();e&&e.destroy()}),p(()=>{let e=L();if(!e)return;let n=t.room,r=t.shard;v(null),b(null),nr(n),ur(r);let i=!1;e.stores.room.terrain(n,r).then(e=>{i||(Sp(`terrain loaded — ${n}`),v({room:n,data:e}))}).catch(e=>{i||Cp(`terrain load failed for ${n}:`,e)}),w(xt)&&e.http.game.roomDecorations(n,r).then(e=>{i||(Sp(`decorations loaded — ${n}: ${e.decorations.length} item(s)`),b({room:n,decoration:js(e)}))}).catch(e=>{i||Sp(`no decorations for ${n}: ${e}`)}),a(()=>{i=!0})}),p(()=>{let e=L();if(!e||q())return;let n=t.room,r=t.shard;Sp(`navigate → ${n} (shard=${r??`default`})`),S(null),E(``),ke(null),ff(),sr(null),ir(null),or(null),mr(null),tr(null),Qn({}),rr(null);let i=new ot;i.add(e.stores.room.subscribe(n,r)),i.add(e.stores.room.on(`room:error`,e=>{j(`Room subscription error (${e.room}): ${e.message}`,`error`,8e3)})),i.add(e.stores.room.on(`room:update`,e=>{let t=0,r={},i=0,a=null,o=null,s=null;for(let n in e.objects){t++;let c=e.objects[n];if(!c)continue;let l=c.type;if(typeof l==`string`)if(l===`constructionSite`){let e=c.structureType;typeof e==`string`&&(r[e]=(r[e]||0)+1)}else r[l]=(r[l]||0)+1;if(l===`controller`){if(typeof c.user==`string`){let t=c.user;o={userId:t,username:e.users?.[t]?.username??t},typeof c.level==`number`&&(i=c.level),typeof c.progress==`number`&&(a=c.progress)}let t=c.reservation;t&&typeof t.user==`string`&&typeof t.endTime==`number`&&(s={user:t.user,endTime:t.endTime})}}e.diff||Sp(`objects loaded — ${n}: ${t} objects, tick=${e.gameTime}`),S({objects:e.objects,diff:e.diff,users:e.users}),E(e.visual),ke(e.gameTime??null),xe(e.gameTime),sr(t),ir(o),or(i||null),mr(a),tr(s),Qn(r),rr(e.users??null)})),a(()=>{Sp(`leaving ${n}`),i.dispose()})}),p(()=>{let e=L();if(!e||!q())return;E(``);let n=t.room,r=t.shard,i=Oe()??!0,o=Se()?.serverData?.historyChunkSize??(i?20:100),s=w(er)??void 0,c=new Hf(n,r,e.http,o);p(()=>{let e=_f(),t=!1;Of(!0),c.getStateAtTick(e).then(e=>{if(t)return;if(Of(!1),k(!1),e.clampedTo!==void 0){Sf(e.clampedTo),Ff(e.clampedTo);return}S({objects:e.objects,diff:void 0,users:s}),ke(e.gameTime);let n=0,r={},i=0,a=null,o=null,c=null;for(let t in e.objects){n++;let l=e.objects[t];if(!l)continue;let u=l.type;if(typeof u==`string`)if(u===`constructionSite`){let e=l.structureType;typeof e==`string`&&(r[e]=(r[e]||0)+1)}else r[u]=(r[u]||0)+1;if(u===`controller`){if(typeof l.user==`string`){let e=l.user;o={userId:e,username:s?.[e]?.username??e},typeof l.level==`number`&&(i=l.level),typeof l.progress==`number`&&(a=l.progress)}let e=l.reservation;e&&typeof e.user==`string`&&typeof e.endTime==`number`&&(c={user:e.user,endTime:e.endTime})}}sr(n),ir(o),or(i||null),mr(a),tr(c),Qn(r)}).catch(n=>{if(!t){if(Of(!1),n instanceof Bf){if(k(!0),Cf()){let t=c.chunkBase(e)+o;t<=xf()?Ff(t):Rf()}return}k(!1),j(`History load failed for tick ${e}: ${n.message}`,`error`,5e3)}}),a(()=>{t=!0})}),a(()=>k(!1))}),p(()=>{let e=m();if(!e)return;t.room,t.shard,hp(),e.hoverLayer.clearPendingTile();let n=w(op);n?.type===`moveFlag`?sp({...n,targetRoom:t.room}):e.resetView(),f?.destroy(),f=null,e.clear(),e.resetView(),c?.destroy(),c=null,u?.destroy(),u=null,d?.destroy(),d=null;let r=w(_);if(r&&r.room===t.room){Sp(`terrain applied immediately (pre-loaded) — ${t.room}`);let n=w(y);f=ws(r.data,e.app.renderer,n?.room===t.room?n.decoration.terrain:void 0),Ts(f,w(en)),f.zIndex=fs.terrain,e.world.addChild(f),e.bringNavOverlayToTop()}let i=t.room,a=t.shard,o=Yn(i),s=w(()=>t.onNavigate),l=w(le);if(o&&s){let t=(e,t)=>!l||ln(e,t,l),n=e=>{Sp(`navigate requested: ${i} → ${e}`),s(e,a)};e.setupNavigationZones({west:t(o.x-1,o.y)?()=>n(an(o.x-1,o.y)):void 0,east:t(o.x+1,o.y)?()=>n(an(o.x+1,o.y)):void 0,north:t(o.x,o.y-1)?()=>n(an(o.x,o.y-1)):void 0,south:t(o.x,o.y+1)?()=>n(an(o.x,o.y+1)):void 0})}}),p(()=>{let e=m();if(!e)return;let n=w(()=>t.room),r=w(()=>t.shard),i=Yn(n);if(i&&t.onNavigate){let a=t.onNavigate,o=le(),s=(e,t)=>!o||ln(e,t,o),c=e=>{Sp(`navigate requested: ${n} → ${e}`),a(e,r)};bn({currentRoom:()=>t.room,worldBounds:le,onMove:(e,t)=>c(an(e,t))}),e.setupNavigationZones({west:s(i.x-1,i.y)?()=>c(an(i.x-1,i.y)):void 0,east:s(i.x+1,i.y)?()=>c(an(i.x+1,i.y)):void 0,north:s(i.x,i.y-1)?()=>c(an(i.x,i.y-1)):void 0,south:s(i.x,i.y+1)?()=>c(an(i.x,i.y+1)):void 0})}}),p(()=>{let e=ep(),t=m();e===`view`&&t&&(up(),t.hoverLayer.clearPendingTile())}),p(()=>{let e=m(),t=ip();e&&(t?e.hoverLayer.setPendingTile(t.tx,t.ty):e.hoverLayer.clearPendingTile())}),p(()=>{let e=m(),n=_();if(!e||!n||n.room!==t.room)return;if(f?.parent){Sp(`terrain already in scene, skipping — ${t.room}`);return}Sp(`terrain applied (async) — ${t.room}`);let r=w(y);f=ws(n.data,e.app.renderer,r?.room===t.room?r.decoration.terrain:void 0),Ts(f,w(en)),e.world.addChildAt(f,0),e.bringNavOverlayToTop()}),p(()=>{if(xt())return;b(null);let e=w(m),n=w(_);!e||!n||n.room!==t.room||f?.parent&&(f.destroy(),f=ws(n.data,e.app.renderer),Ts(f,w(en)),e.world.addChildAt(f,0),e.bringNavOverlayToTop(),c?.setRoadColor(Zt),c?.setWallColor(W))}),p(()=>{let e=m(),n=y(),r=w(_);!e||!n||n.room!==t.room||!r||r.room!==t.room||f?.parent&&(Sp(`decoration arrived, rebuilding terrain layer — ${t.room}`),f.destroy(),f=ws(r.data,e.app.renderer,n.decoration.terrain),Ts(f,w(en)),e.world.addChildAt(f,0),e.bringNavOverlayToTop(),c&&n.decoration.roadColor!=null&&c.setRoadColor(n.decoration.roadColor),c&&n.decoration.terrain?.wallFillColor!=null&&c.setWallColor(n.decoration.terrain.wallFillColor))}),p(()=>{let e=m(),n=x();if(!e)return;if(!n){c?.clear(),u?.clear(),e.clearLighting();return}let{objects:r,diff:a,users:o}=n,s=c?a:void 0;if(!c){Sp(`object layer created — ${t.room}`),c=new wd(e.app.ticker,It(),H()?._id,H()?.badge,o),c.setTheme(i(w(Qt)),Yt),c.setInstantMode(w(q));let n=w(y);n?.room===t.room&&(n.decoration.roadColor!=null&&c.setRoadColor(n.decoration.roadColor),n.decoration.terrain?.wallFillColor!=null&&c.setWallColor(n.decoration.terrain.wallFillColor)),c.setLightingLayer(e.lighting),c.container.label=`objects`,c.container.zIndex=fs.objects,e.world.addChild(c.container),u=new Ad(e.app.ticker),u.container.label=`animations`,u.container.zIndex=fs.animations,e.world.addChild(u.container),d=new Id(e.app.renderer,e.world,e.app.ticker),d.container.zIndex=fs.visuals,e.world.addChild(d.container),e.setTileHandlers((e,t)=>{},(n,r,i)=>{let a=t.room,o=t.shard,s=ep(),l=op();if(l?.type===`moveFlag`){let e=L();if(!e)return;let{name:t,room:i,color:a,secondaryColor:s,targetRoom:c}=l;e.http.game.removeFlag(i,t,o??void 0).then(()=>e.http.game.createFlag(c,n,r,t,a,s,o??void 0)).then(()=>{j(`Flag "${t}" moved`,`success`),dp()}).catch(e=>{Cp(`move flag failed:`,e),j(`Failed to move flag "${t}"`,`error`),dp()});return}if(s===`flag`){let t=ip();if(!t||t.tx!==n||t.ty!==r){ap({tx:n,ty:r}),e.hoverLayer.setPendingTile(n,r);return}let i=L();if(!i)return;let s=np(),c=s.name.trim();if(!c){j(`Flag name is required`,`error`);return}let l=Qf[s.color]??0,u=Qf[s.secondaryColor]??0;i.http.game.createFlag(a,n,r,c,l,u,o??void 0).then(()=>{j(`Flag "${c}" created`,`success`),up(),e.hoverLayer.clearPendingTile(),wp(i,c)}).catch(e=>Cp(`create flag failed:`,e));return}if(s===`build`){if(!i&&!cp().structureType){j(`Select a structure type first`,`error`);return}if(i){if(!c)return;let t=c.getObjectsAtTile(n,r).filter(({obj:e})=>e.type===`constructionSite`);if(t.length===0){j(`No construction sites on this tile`,`error`);return}let i=L();if(!i)return;i.http.game.removeConstructionSite(a,t.map(({id:e})=>e),o??void 0).then(()=>{j(`Removed ${t.length} construction site${t.length>1?`s`:``}`,`success`),up(),e.hoverLayer.clearPendingTile()}).catch(e=>{Cp(`remove construction sites failed:`,e),j(`Failed to remove construction sites: ${e.message}`,`error`)});return}ap({tx:n,ty:r}),e.hoverLayer.setPendingTile(n,r),pp(a,o);return}if(up(),e.hoverLayer.clearPendingTile(),!c)return;let u=c.getObjectsAtTile(n,r);if(u.length===0){i||(df([]),e.hoverLayer.clearSelection());return}let d=[...uf()];if(i){let e=new Set(u.map(e=>e.id));if(d.some(t=>e.has(t.id)))d=d.filter(t=>!e.has(t.id));else{let e=u.filter(({id:e})=>!d.some(t=>t.id===e)).map(({id:e,obj:t})=>lf(e,t));d=[...d,...e]}}else d=u.map(({id:e,obj:t})=>lf(e,t));df(d);let f=d.map(({id:e,type:t})=>({id:e,type:t,visual:c.getVisualById(e)})).filter(e=>e.visual!=null);e.hoverLayer.setSelectedObjects(f)},()=>{let t=ep();(t===`build`||t===`flag`||op()?.type===`moveFlag`)&&(mp(),e.hoverLayer.clearPendingTile())})}s?mf(s,r):hf(r);let f=q()?Math.round(1e3/w(Tf)):Re()??2e3,p=f*.6,h=Math.round(f*.9);c.setMoveDuration(h),c.setTickDuration(f),l={objects:r,users:o},c.update(r,s,o,V()??void 0),c.setShowLabels(w(It));let g=new Set;if(u){u.clear();for(let e in r){let t=r[e];if(!t)continue;let n=t.actionLog;if(!n)continue;if(t.type===`tower`){let r=n.attack,i=n.heal,a=n.repair;r&&u.addTowerAttack(t.x,t.y,r.x,r.y,p),i&&u.addTowerHeal(t.x,t.y,i.x,i.y,p),a&&u.addTowerRepair(t.x,t.y,a.x,a.y,p);let o=r??i??a;o&&c?.triggerTowerAim(e,o.x,o.y,p);continue}if(t.type===`link`){let e=n.transferEnergy;e&&u.addLinkTransfer(t.x,t.y,e.x,e.y,p);continue}if(t.type===`lab`){let e=n.runReaction??n.reverseReaction;e&&(u.addLabReaction(e.x1,e.y1,t.x,t.y,p),u.addLabReaction(e.x2,e.y2,t.x,t.y,p));continue}if(t.type!==`creep`)continue;let i=n.harvest;i&&u.addHarvest(i.x,i.y,t.x,t.y,p);let a=n.upgradeController;a&&u.addUpgradeController(t.x,t.y,a.x,a.y,p);let o=n.build;o&&(u.addBuild(t.x,t.y,o.x,o.y,p),c?.triggerBuildAt(o.x,o.y,p));let s=n.repair;s&&u.addRepair(t.x,t.y,s.x,s.y,p);let l=n.transfer;l&&u.addTransfer(t.x,t.y,l.x,l.y,p);let d=n.say;if(d&&typeof d.message==`string`&&d.message.length>0){let n=H()?._id;(d.isPublic===!0||n!=null&&t.user===n)&&(c?.triggerSay(e,d.message),g.add(e))}}}c.pruneSayBubblesExcept(g),w(Xt)&&e.updateLighting(r)}),p(()=>{let e=C();d?.update($t()?e:``)}),p(()=>{c?.setInstantMode(q())}),p(()=>{let e=en();f&&Ts(f,e)}),p(()=>{let e=m();if(!e)return;let t=Xt();e.darkOverlay.visible=t,e.lightLayer.visible=t,t||e.clearLighting()}),p(()=>{let e=i(Qt());c&&(c.setTheme(e,Yt),l&&(c.clear(),c.update(l.objects,void 0,l.users)))}),(()=>{var e=yp(),t=e.firstChild;return Pe(e=>s=e,t),T(e,(()=>{var e=I(()=>!!gp());return()=>e()&&(()=>{var e=bp();return T(e,gp),r(t=>B(e,`pointer-events`,O()===`empty`||O()===`lost`?`auto`:`none`)),e})()})(),null),T(e,(()=>{var e=I(()=>!q()&&V()!==null);return()=>e()&&(()=>{var e=xp();return e.firstChild,T(e,V,null),e})()})(),null),T(e,n(h,{get when(){return I(()=>!!q())()&&D()},get children(){var e=_p();return e.firstChild.nextSibling,e}}),null),T(e,n(h,{get when(){return q()},get children(){var e=vp(),t=e.firstChild,n=t.nextSibling.firstChild,i=n.nextSibling,a=i.nextSibling;return t.$$input=e=>{let t=parseInt(e.currentTarget.value,10);ee(t),M!==null&&clearTimeout(M),M=setTimeout(()=>{M=null,Ff(t)},150)},T(n,yf),T(i,(()=>{var e=I(()=>!!Df());return()=>e()?`Loading…`:`Tick ${_f()}`})()),T(a,xf),r(e=>{var n=yf(),r=xf(),a=Df()?`#f0883e`:`#8b949e`;return n!==e.e&&R(t,`min`,e.e=n),r!==e.t&&R(t,`max`,e.t=r),a!==e.a&&B(i,`color`,e.a=a),e},{e:void 0,t:void 0,a:void 0}),r(()=>t.value=A()),e}}),null),e})()}P([`input`]);var Ep=z(`<div style=position:fixed;bottom:16px;right:16px;display:flex;flex-direction:column;gap:8px;z-index:9999;pointer-events:none>`),Dp=z(`<div style="padding:10px 16px;border-radius:6px;font-size:13px;color:#fff;box-shadow:0 4px 12px rgba(0,0,0,0.4);max-width:320px;word-break:break-word;pointer-events:auto;animation:toast-in 0.2s ease">`);function Op(){return(()=>{var e=Ep();return T(e,n(b,{get each(){return re()},children:e=>(()=>{var t=Dp();return T(t,()=>e.message),r(n=>B(t,`background`,e.type===`error`?`#da3633`:`#238636`)),t})()})),e})()}var[kp,Ap]=e(!0),[jp,Mp]=e(!0),[Np,Pp]=e(!1),[Fp,Ip]=e(!1),[Lp,Rp]=e(``),zp;function Bp(e){zp=e}function Vp(e){Rp(e),Mp(!0),requestAnimationFrame(()=>{zp?.focus();let t=e.length;zp?.setSelectionRange(t,t)})}function Hp(){Ap(e=>!e)}function Up(){Mp(e=>!e)}function Wp(){Pp(e=>!e)}function Gp(){Ip(e=>!e)}var[Kp,qp]=e(E(k.memoryWatches,[])),[Jp,Yp]=e(null),[Xp,Zp]=nf({});function Qp(e){let t=e.trim();t&&(qp(e=>e.includes(t)?e:[...e,t]),ee(k.memoryWatches,Kp()))}function $p(e){qp(t=>t.filter(t=>t!==e)),ee(k.memoryWatches,Kp())}function em(){Yp(null)}function tm(e,t){Yp({creepId:e,name:t})}function nm(e,t){let n=[...t];if(e){let t=`creeps.${e.name}`;n.includes(t)||n.push(t)}return n}function rm(e){let t=new Map,n=()=>{let n=L();if(!n)return;let r=new Set(nm(Jp(),Kp()));for(let i of r)t.has(i)||t.set(i,n.stores.user.subscribeMemory(i,e));for(let[e,n]of t)r.has(e)||(n.dispose(),t.delete(e))};p(()=>{Kp(),Jp(),n()});let r=L(),i=null;return r?i=r.stores.user.on(`user:memory`,e=>{Zp(e.path,e.value)}):console.warn(`[memoryStore] no client available when initMemorySubscriptions called`),a(()=>{for(let e of t.values())e.dispose();t.clear(),i?.dispose()}),n(),()=>{for(let e of t.values())e.dispose();t.clear(),i?.dispose()}}y(()=>{p(()=>{let e=Jp();e&&(uf().some(t=>t.id===e.creepId)||em())})});var{log:im,warn:am}=ce(`customUi`),om=[`own`,`reserved`,`empty`,`foreign`],sm=`SCUI`,cm=15e3,lm=32,um=40,dm=64,fm=50,pm=128,mm=[`room`,`selection`,`tile`],hm=[`button`,`select`,`status`,`header`],gm=/^[A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*)*$/,[_m,vm]=e(null),[ym,bm]=e(``),[xm,Sm]=e(null),[Cm,wm]=e(null),[Tm,Em]=e(!1);function Dm(){let e=H(),t=fr();if(t)return t.userId===e?._id?`own`:`foreign`;let n=dr();return n?n.user===e?._id?`reserved`:`foreign`:`empty`}function Om(e,t,n){if(!e.obj?.includes(t))return!1;if(e.owner!==void 0){if(n===null)return!1;let t=n===H()?._id;if(e.owner===`own`?!t:t)return!1}let r=e.showIf?.room;return!(r!==void 0&&!r.includes(Dm()))}function km(){return`${k.customUiSegment}:${ae(N.url)??``}`}function Am(){return`${k.customUiShard}:${ae(N.url)??``}`}function jm(){let e=oe(km());if(e===null)return null;let t=Number(e);return Number.isInteger(t)&&t>=0&&t<=99?t:null}function Mm(e){e===null?se(km()):ie(km(),String(e)),vm(e),Im()}function Nm(e){let t=e.trim();t?ie(Am(),t):se(Am()),bm(t),Im()}function Pm(e,t,n={}){let r=n.allowItems??!0;if(e===void 0)return[];if(!Array.isArray(e))throw Error(`"${t}" must be an array`);if(e.length>lm)throw Error(`"${t}" has more than ${lm} elements`);return e.map((e,i)=>{let a=`${t}[${i}]`;if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`${a} must be an object`);let o=e,s=o.type===void 0?`button`:o.type;if(!hm.includes(s))throw Error(`${a}.type may only be ${hm.join(`, `)}`);if(n.objectMode&&s!==`button`&&s!==`select`)throw Error(`${a}: only buttons and selects are allowed in "objects"`);if(s===`header`&&!r)throw Error(`${a}: headers cannot be nested inside items`);if(typeof o.label!=`string`||!o.label.trim())throw Error(`${a}.label is missing`);let c={type:s,label:o.label.trim().slice(0,um),confirm:o.confirm===!0};if(c.type===`button`||c.type===`select`){if(typeof o.cmd!=`string`||!o.cmd.trim())throw Error(`${a}.cmd is missing`);c.cmd=o.cmd.trim().slice(0,dm)}if(c.type===`select`){if(!Array.isArray(o.options)||o.options.length===0||o.options.some(e=>typeof e!=`string`||!e.trim()))throw Error(`${a}.options must be a non-empty array of strings`);if(o.options.length>fm)throw Error(`${a}.options has more than ${fm} entries`);c.options=o.options.map(e=>e.trim().slice(0,um))}if(c.type===`status`){if(typeof o.path!=`string`||!o.path.trim()||o.path.trim().length>pm||/\s/.test(o.path.trim()))throw Error(`${a}.path must be a memory path like "stats.energy"`);c.path=o.path.trim()}if(o.items!==void 0){if(c.type!==`header`)throw Error(`${a}.items is only allowed on headers`);c.items=Pm(o.items,`${a}.items`,{allowItems:!1})}if(n.objectMode){let e=Array.isArray(o.obj)?o.obj:[o.obj];if(o.obj===void 0||e.length===0||e.some(e=>typeof e!=`string`||!e.trim()))throw Error(`${a}.obj must name one or more object types (e.g. "creep")`);if(c.obj=e.map(e=>e.trim()),o.owner!==void 0){if(o.owner!==`own`&&o.owner!==`foreign`)throw Error(`${a}.owner may only be "own" or "foreign"`);c.owner=o.owner}}if(o.needs!==void 0){if(!Array.isArray(o.needs)||o.needs.some(e=>!mm.includes(e)))throw Error(`${a}.needs may only contain ${mm.join(`, `)}`);c.needs=o.needs}if(o.showIf!==void 0){if(typeof o.showIf!=`object`||o.showIf===null||Array.isArray(o.showIf))throw Error(`${a}.showIf must be an object`);let e=o.showIf,t={};if(e.selType!==void 0){if(typeof e.selType!=`string`||!e.selType.trim())throw Error(`${a}.showIf.selType must be a string`);t.selType=e.selType.trim()}if(e.room!==void 0){let n=Array.isArray(e.room)?e.room:[e.room];if(n.length===0||n.some(e=>!om.includes(e)))throw Error(`${a}.showIf.room may only contain ${om.join(`, `)}`);t.room=n}c.showIf=t}return c})}function Fm(e){if(!e||!e.trim())throw Error(`segment is empty`);let t;try{t=JSON.parse(e)}catch{throw Error(`segment is not valid JSON`)}if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`segment must hold a JSON object`);let n=t;if(n.v!==1)throw Error(`unsupported config version (expected "v": 1)`);if(typeof n.handler!=`string`||!gm.test(n.handler))throw Error(`"handler" must be a function name like "uiCommand"`);return{handler:n.handler,map:Pm(n.map,`map`),room:Pm(n.room,`room`),objects:Pm(n.objects,`objects`,{allowItems:!1,objectMode:!0})}}async function Im(){let e=L(),t=_m();if(!e||t===null){Sm(null),wm(null);return}Em(!0);try{Sm(Fm((await e.http.user.memory.segment.get(t,ym()||null)).data)),wm(null),im(`loaded custom UI from segment ${t}`)}catch(e){Sm(null),wm(`Segment ${t}: ${e.message}`),am(`config load failed:`,e)}finally{Em(!1)}}var Lm=new Map,[Rm,zm]=e(new Set);function Bm(){zm(new Set(Lm.keys()))}var Vm=null;function Hm(e){return!e.includes(`<`)&&!e.includes(`&`)?e.trim():(new DOMParser().parseFromString(e,`text/html`).body.textContent??``).trim()}function Um(e){return _m()!==null&&Wm(e)!==null}function Wm(e){if(!e.includes(sm))return null;let t=Hm(e),n=t.indexOf(sm);if(n===-1)return null;let r=t.indexOf(`{`,n),i=t.lastIndexOf(`}`);if(r===-1||i<=r)return null;let a=t.slice(r,i+1);for(let e of[a,a.replace(/\\"/g,`"`)])try{let t=JSON.parse(e);if(typeof t==`object`&&t)return t}catch{}return null}function Gm(e,t){let n=!1;if(typeof e.err==`string`?(j(e.err,`error`),n=!0):typeof e.msg==`string`&&(j(e.msg,`success`),n=!0),typeof e.room==`string`){let r=typeof e.shard==`string`?e.shard:t.shard;L()?.stores.navigation.navigateTo(e.room,r),n=!0}typeof e.console==`string`&&(Vp(e.console),n=!0),e.reload===!0&&(Im(),n=!0),n||j(`${t.cmd}: done`,`success`)}function Km(e){for(let t of[...e.log??[],...e.results??[]]){if(!t.includes(sm))continue;let e=Wm(t);if(!e){am(`marker found but line not parseable:`,t);continue}if(typeof e.id!=`string`){am(`response has no "id":`,t);continue}let n=Lm.get(e.id);if(!n){am(`response id "${e.id}" matches no pending command`);continue}window.clearTimeout(n.timer),Lm.delete(e.id),Bm(),Gm(e,n)}}function qm(e,t,n){let r=L(),i=xm();if(!r||!i||!e.cmd)return null;let a=e.cmd,o=Math.random().toString(36).slice(2,10),s=`${i.handler}(${JSON.stringify({id:o,cmd:a,...n===void 0?{}:{value:n},ctx:t})})`,c=window.setTimeout(()=>{Lm.delete(o),Bm(),j(`${a}: no response`,`error`)},cm);return Lm.set(o,{cmd:a,shard:t.shard,timer:c}),Bm(),im(`dispatch:`,s),r.http.user.console(s,t.shard).catch(e=>{window.clearTimeout(c),Lm.delete(o),Bm(),j(`${a}: ${e.message}`,`error`)}),o}function Jm(){if(be())return;let e=L();e&&(vm(jm()),bm(oe(Am())??``),Vm=new ot,Vm.add(e.stores.user.subscribe(`console`)),Vm.add(e.stores.user.on(`user:console`,e=>{Km(e.messages)})),Im())}function Ym(){Vm?.dispose(),Vm=null;for(let e of Lm.values())window.clearTimeout(e.timer);Lm.clear(),Bm(),Sm(null),wm(null),Em(!1)}var Xm=z(`<button style=color:#8b949e>`),Zm=z(`<span style=width:18px;flex-shrink:0>`),Qm=z(`<span style=color:#484f58;font-style:italic>{…}`),$m=z(`<span style=color:#484f58;font-style:italic>`),eh=z(`<button title=Reload>`),th=z(`<span title="Click to edit"style=cursor:text;flex:1>`),nh=z(`<input type=text autofocus style="background:#161b22;border:1px solid #388bfd;color:#c9d1d9;border-radius:3px;padding:0 4px;font-size:12px;font-family:inherit;flex:1;min-width:60px">`),rh=z(`<button title=Save style=color:#3fb950>`),ih=z(`<button title=Discard style=color:#f85149>`),ah=z(`<div><div style=display:flex;align-items:center;gap:2px;min-height:20px><span style=color:#8b949e;flex-shrink:0></span><span style="color:#484f58;margin:0 2px;flex-shrink:0">:</span><button>`),{error:oh}=ce(`MemoryTree`);function sh(e){return typeof e==`object`&&!!e&&`__screeps_object__`in e}var ch={"font-family":`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,"font-size":`12px`,"line-height":`1.5`},lh={background:`transparent`,border:`none`,color:`#8b949e`,cursor:`pointer`,padding:`2px`,"border-radius":`3px`,display:`inline-flex`,"align-items":`center`,"justify-content":`center`,"flex-shrink":0};function uh(e){return e.replace(/^Memory\.?/,``)}function dh(t){let[i,a]=e((t.depth??0)<2),s=()=>t.depth??0,[c,l]=e(!1),[u,d]=e(``),[f,p]=e(!1),[m,g]=e(void 0),_=()=>sh(t.value)&&m()!==void 0?m():t.value,v=()=>{let e=_();return!sh(e)&&typeof e==`object`&&!!e},y=()=>v()?Object.entries(_()):[],x=()=>y().length,S=async()=>{p(!0);try{let e=L();if(!e)return;let n=uh(t.path),r=await e.http.user.memory.get(n,t.shard),i=r.data===`[object Object]`?{__screeps_object__:!0}:r.data;g(i)}catch(e){oh(`fetch memory failed`,e)}finally{p(!1)}},C=()=>{g(void 0),S()};o(()=>{i()&&sh(t.value)&&m()===void 0&&S()});let w=async()=>{if(sh(t.value)&&m()===void 0){await S(),a(!0);return}i()&&g(void 0),a(e=>!e)},E=async()=>{let e=u().trim(),n;if(e===`null`)n=null;else if(e===`true`)n=!0;else if(e===`false`)n=!1;else{let t=Number(e);if(!Number.isNaN(t)&&e!==``)n=t;else try{n=JSON.parse(e)}catch{n=e}}let r=L();if(!r)return;let i=uh(t.path);try{await r.http.user.memory.set(i,n,t.shard)}catch(e){oh(`set memory failed`,e),l(!1);return}l(!1),t.onRefresh?.()},D=()=>{let e=_();return v()?`#c9d1d9`:typeof e==`string`?`#3fb950`:typeof e==`number`?`#79c0ff`:typeof e==`boolean`?`#a371f7`:`#8b949e`},O=()=>{let e=_();return e===null?`null`:e===void 0?`undefined`:typeof e==`string`?JSON.stringify(e):String(e)};return(()=>{var e=ah(),a=e.firstChild,o=a.firstChild,p=o.nextSibling.nextSibling;return T(a,n(h,{get when(){return v()||sh(_())},get children(){var e=Xm();return e.$$click=()=>void w(),T(e,n(h,{get when(){return f()},get children(){return n(Ti,{size:12,style:{animation:`spin 1s linear infinite`}})}}),null),T(e,n(h,{get when(){return!f()},get children(){return n(h,{get when(){return i()},get fallback(){return n(Gr,{size:12})},get children(){return n(Vr,{size:12})}})}}),null),r(t=>{var n={...lh},r=i()?`Collapse`:`Expand`,a=f();return t.e=F(e,n,t.e),r!==t.t&&R(e,`title`,t.t=r),a!==t.a&&(e.disabled=t.a=a),t},{e:void 0,t:void 0,a:void 0}),e}}),o),T(a,n(h,{get when(){return I(()=>!v())()&&!sh(_())},get children(){return Zm()}}),o),T(o,()=>t.label),T(a,n(h,{get when(){return sh(_())},get children(){return Qm()}}),p),T(a,n(h,{get when(){return v()},get children(){var e=$m();return T(e,(()=>{var e=I(()=>!!Array.isArray(_()));return()=>e()?`[${x()}]`:`{${x()}}`})()),e}}),p),T(a,n(h,{get when(){return I(()=>!!sh(t.value))()&&!f()},get children(){var e=eh();return e.$$click=()=>C(),T(e,n(Yi,{size:11})),r(t=>F(e,lh,t)),e}}),p),T(a,n(h,{get when(){return I(()=>!v())()&&!sh(_())},get children(){return[n(h,{get when(){return!c()},get children(){var e=th();return e.$$click=()=>{d(O()),l(!0)},T(e,O),r(t=>B(e,`color`,D())),e}}),n(h,{get when(){return c()},get children(){return[(()=>{var e=nh();return e.$$keydown=e=>{e.key===`Enter`&&E(),e.key===`Escape`&&l(!1)},e.$$input=e=>d(e.currentTarget.value),r(()=>e.value=u()),e})(),(()=>{var e=rh();return e.$$mousedown=e=>{e.preventDefault(),E()},T(e,n(zr,{size:12})),r(t=>F(e,{...lh},t)),e})(),(()=>{var e=ih();return e.$$mousedown=e=>{e.preventDefault(),l(!1)},T(e,n(ya,{size:12})),r(t=>F(e,{...lh},t)),e})()]}})]}}),p),p.$$click=()=>Vp(`Memory.${uh(t.path)} = `),T(p,n(pa,{size:11})),T(e,n(h,{get when(){return I(()=>!!v())()&&i()},get children(){return n(b,{get each(){return y()},children:([e,r])=>n(dh,{value:r,path:Array.isArray(_())?`${t.path}[${e}]`:`${t.path}.${e}`,label:e,get shard(){return t.shard},get depth(){return s()+1},get onRefresh(){return I(()=>!!sh(t.value))()?C:t.onRefresh}})})}}),null),r(n=>{var r={"padding-left":s()>0?`14px`:`0`,...ch},i=lh,a=`Insert Memory.${uh(t.path)} = into console`;return n.e=F(e,r,n.e),n.t=F(p,i,n.t),a!==n.a&&R(p,`title`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),e})()}function fh(e){return n(dh,{get value(){return e.value},get path(){return e.path},get label(){return e.label},get shard(){return e.shard},depth:0})}P([`click`,`input`,`keydown`,`mousedown`]);var ph=z(`<div style=color:#484f58;font-style:italic>No paths watched — add one below.`),mh=z(`<div style=flex-shrink:0;display:flex;flex-direction:column;overflow:hidden><div class=console-scroll style=flex:1;overflow:auto;padding:8px></div><form style="display:flex;gap:6px;padding:8px;border-top:1px solid #30363d"><input type=text placeholder=creeps.Harvester1.energy style="flex:1;padding:6px 8px;border-radius:4px;border:1px solid #30363d;background:#161b22;color:#c9d1d9;font-size:12px;font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace"><button type=submit title="Add watch"style="padding:6px 8px;border-radius:4px;border:none;background:#238636;color:#fff;font-size:12px;cursor:pointer;display:flex;align-items:center;gap:4px"> Watch`),hh=z(`<div style=margin-bottom:8px><div style="display:flex;align-items:center;gap:4px;border-bottom:1px solid #21262d;padding-bottom:4px;margin-bottom:4px"><span style=color:#f0883e;font-weight:600;flex:1></span><span style=color:#484f58;font-size:10px;font-style:italic>temp</span><button title="Remove temp watch">`),gh=z(`<div style=margin-bottom:8px><div style="display:flex;align-items:center;gap:4px;border-bottom:1px solid #21262d;padding-bottom:4px;margin-bottom:4px"><span style=color:#c9d1d9;font-weight:600;flex:1></span><button title="Remove watch">`),_h=z(`<div style=flex-shrink:0;display:flex;overflow:hidden><div style="width:32px;flex-shrink:0;border-right:1px solid #30363d;display:flex;flex-direction:column;align-items:center;padding:6px 0;gap:6px"><button></button><button title=Clear></button></div><div class=console-scroll style=flex:1;overflow:auto;padding:8px>`),vh=z(`<div style=width:4px;flex-shrink:0;cursor:col-resize>`),yh=z(`<div style=flex-shrink:0;display:flex;flex-direction:column;overflow:hidden><div class=console-scroll style=flex:1;overflow:auto;padding:8px></div><form style="display:flex;gap:6px;padding:8px;border-top:1px solid #30363d"><span style=color:#8b949e;font-size:13px;line-height:28px>></span><input type=text placeholder="Game.creeps.Harvester1.moveTo(10, 10)"style="flex:1;padding:6px 8px;border-radius:4px;border:1px solid #30363d;background:#161b22;color:#c9d1d9;font-size:12px;font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace"><button type=submit style="padding:6px 12px;border-radius:4px;border:none;background:#238636;color:#fff;font-size:12px;cursor:pointer">Run`),bh=z(`<div style=flex:1;display:flex;overflow:hidden>`),xh=z(`<div style=display:flex;flex-direction:column;height:100%;background:#0d1117><div style="height:32px;flex-shrink:0;padding:0 10px;border-bottom:1px solid #30363d;display:flex;align-items:center;gap:6px"><button>Log</button><button>Console</button><button>Memory</button><div style=width:1px;height:16px;background:#30363d></div><button title="View and edit raw memory segments">Segments</button></div><style>
|
|
4
|
+
.console-scroll::-webkit-scrollbar {
|
|
5
|
+
width: 8px;
|
|
6
|
+
height: 8px;
|
|
7
|
+
}
|
|
8
|
+
.console-scroll::-webkit-scrollbar-track {
|
|
9
|
+
background: #161b22;
|
|
10
|
+
}
|
|
11
|
+
.console-scroll::-webkit-scrollbar-thumb {
|
|
12
|
+
background: #484f58;
|
|
13
|
+
border-radius: 4px;
|
|
14
|
+
}
|
|
15
|
+
.console-scroll::-webkit-scrollbar-thumb:hover {
|
|
16
|
+
background: #6e7681;
|
|
17
|
+
}
|
|
18
|
+
`),Sh=z(`<div style=color:#484f58;font-style:italic>No log output yet…`),Ch=z(`<div style=margin-bottom:4px;color:#f85149;white-space:pre-wrap;word-break:break-word>`),wh=z(`<div style=margin-bottom:4px;color:#c9d1d9;white-space:pre-wrap;word-break:break-word>`),Th=z(`<div style=color:#484f58;font-style:italic>No command results yet…`),Eh=z(`<div style=margin-bottom:4px;color:#58a6ff;white-space:pre-wrap;word-break:break-word>`),{error:Dh}=ce(`console`);function Oh(t){let[i,a]=e(``),s=()=>t.shard??$n();o(()=>{rm(s())});let c={"font-family":`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,"font-size":`12px`,"line-height":`1.5`},l={background:`transparent`,border:`none`,color:`#8b949e`,cursor:`pointer`,padding:`4px`,"border-radius":`4px`,display:`flex`,"align-items":`center`,"justify-content":`center`};return(()=>{var e=mh(),o=e.firstChild,u=o.nextSibling,d=u.firstChild,f=d.nextSibling,p=f.firstChild;return T(o,n(h,{get when(){return Jp()},children:e=>{let t=`creeps.${e().name}`;return(()=>{var e=hh(),i=e.firstChild.firstChild,a=i.nextSibling.nextSibling;return T(i,t),ge(a,`click`,em,!0),T(a,n(ya,{size:12})),T(e,n(fh,{get value(){return Xp[t]},path:`Memory.${t}`,label:t,get shard(){return s()}}),null),r(e=>F(a,l,e)),e})()}}),null),T(o,n(b,{get each(){return Kp()},children:e=>(()=>{var t=gh(),i=t.firstChild.firstChild,a=i.nextSibling;return T(i,e),a.$$click=()=>$p(e),T(a,n(ya,{size:12})),T(t,n(fh,{get value(){return Xp[e]},path:`Memory.${e}`,label:e,get shard(){return s()}}),null),r(e=>F(a,l,e)),t})()}),null),T(o,n(h,{get when(){return I(()=>Kp().length===0)()&&!Jp()},get children(){return ph()}}),null),u.addEventListener(`submit`,e=>{e.preventDefault(),Qp(i()),a(``)}),d.$$input=e=>a(e.currentTarget.value),T(f,n(qi,{size:14}),p),r(n=>{var r=`${t.width*100}%`,i={...c};return r!==n.e&&B(e,`width`,n.e=r),n.t=F(o,i,n.t),n},{e:void 0,t:void 0}),r(()=>d.value=i()),e})()}function kh(t){let[i,s]=e([]),[c,l]=e(!0),[u,d]=e(E(k.consoleWeights,[1,1,1])),[f,m]=e(null),g,_,v,y=0;o(()=>{let e=L();if(!e)return;let t=new ot;t.add(e.stores.user.subscribe(`console`)),t.add(e.stores.user.on(`user:console`,e=>{let t=e.messages,n={id:y++,log:t.log??[],results:t.results??[],error:t.error??[]};s(e=>{let t=[...e,n];return t.length>200?t.slice(t.length-200):t})})),a(()=>t.dispose())}),p(()=>{i(),c()&&requestAnimationFrame(()=>{kp()&&g&&(g.scrollTop=g.scrollHeight),jp()&&_&&(_.scrollTop=_.scrollHeight)})});let x=(e,n,r)=>{let i=!e&&!n&&!r;i&&!t.isCollapsed&&t.onToggle?.(),!i&&t.isCollapsed&&t.onToggle?.()};p(()=>{x(kp(),jp(),Np())});let S=()=>{let e=u(),t=[kp(),jp(),Np()],n=t.filter(Boolean).length;if(n===0)return[0,0,0];if(n===1){let e=t.findIndex(Boolean);return[0,0,0].map((t,n)=>+(n===e))}let r=t.map((t,n)=>t?e[n]:0).reduce((e,t)=>e+t,0);if(r===0){let e=1/n;return[0,0,0].map((n,r)=>t[r]?e:0)}return t.map((t,n)=>t?e[n]/r:0)};p(()=>{ee(k.consoleWeights,u())});let C=e=>t=>{t.preventDefault(),t.stopPropagation(),m(e),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,w),window.addEventListener(`pointerup`,D,{once:!0})},w=e=>{let t=f();if(t===null)return;let n=v;if(!n)return;let r=n.getBoundingClientRect(),i=Math.max(.02,Math.min(.98,(e.clientX-r.left)/r.width)),a=[...u()],o=[kp(),jp(),Np()];if(t===0){let e=o[0],t=o[1];if(!e||!t)return;a[0]=i/(1-i),a[1]=1,d(a)}else{let e=o[1],t=o[2];if(!e||!t)return;a[1]=i/(1-i),a[2]=1,d(a)}},D=()=>{m(null),document.body.style.cursor=``,document.body.style.userSelect=``,window.removeEventListener(`pointermove`,w)},[O,A]=e([]),[j,M]=e(null),[te,ne]=e(``),re=e=>{let t=O();if(t.length!==0){if(e.key===`ArrowUp`){e.preventDefault();let n=j();n===null?(ne(Lp()),M(t.length-1),Rp(t[t.length-1])):n>0&&(M(n-1),Rp(t[n-1]))}else if(e.key===`ArrowDown`){e.preventDefault();let n=j();if(n===null)return;n<t.length-1?(M(n+1),Rp(t[n+1])):(M(null),Rp(te()))}}},ie=async e=>{e.preventDefault();let n=L(),r=Lp().trim();if(!(!n||!r))try{await n.http.user.console(r,t.shard??`shard0`),A(e=>[...e,r]),M(null),ne(``),Rp(``)}catch(e){Dh(`command failed:`,e)}},ae=e=>({background:e?`#30363d`:`transparent`,border:`1px solid ${e?`#58a6ff`:`transparent`}`,color:e?`#c9d1d9`:`#8b949e`,"font-size":`12px`,cursor:`pointer`,padding:`2px 10px`,"border-radius":`4px`}),oe=e=>qn()&&Um(e),N=()=>i().flatMap(e=>e.log).filter(e=>!oe(e)),se=()=>i().flatMap(e=>e.error),P=()=>i().flatMap(e=>e.results).filter(e=>!oe(e)),ce={"font-family":`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,"font-size":`12px`,"line-height":`1.5`},le={background:`transparent`,border:`none`,color:`#8b949e`,cursor:`pointer`,padding:`4px`,"border-radius":`4px`,display:`flex`,"align-items":`center`,"justify-content":`center`},ue=()=>{l(!0),requestAnimationFrame(()=>{kp()&&g&&(g.scrollTop=g.scrollHeight),jp()&&_&&(_.scrollTop=_.scrollHeight)})};return(()=>{var e=xh(),i=e.firstChild,a=i.firstChild,o=a.nextSibling,u=o.nextSibling,d=u.nextSibling.nextSibling;return i.nextSibling,ge(a,`click`,Hp,!0),ge(o,`click`,Up,!0),ge(u,`click`,Wp,!0),ge(d,`click`,Gp,!0),T(e,n(h,{get when(){return!t.isCollapsed},get children(){var e=bh();return Pe(e=>v=e,e),T(e,n(h,{get when(){return kp()},get children(){var e=_h(),t=e.firstChild,i=t.firstChild,a=i.nextSibling,o=t.nextSibling;i.$$click=()=>c()?l(!1):ue(),T(i,(()=>{var e=I(()=>!!c());return()=>e()?n(Vi,{size:16}):n(Gi,{size:16})})()),a.$$click=()=>s([]),T(a,n(ha,{size:16})),o.addEventListener(`scroll`,()=>{g&&l(g.scrollHeight-g.scrollTop-g.clientHeight<20)});var u=g;return typeof u==`function`?Pe(u,o):g=o,T(o,(()=>{var e=I(()=>N().length===0&&se().length===0);return()=>e()&&Sh()})(),null),T(o,n(b,{get each(){return se()},children:e=>(()=>{var t=Ch();return t.innerHTML=e,t})()}),null),T(o,n(b,{get each(){return N()},children:e=>(()=>{var t=wh();return t.innerHTML=e,t})()}),null),r(t=>{var n=`${S()[0]*100}%`,r=c()?`Pause scrolling`:`Resume scrolling`,s=le,l=le,u={...ce};return n!==t.e&&B(e,`width`,t.e=n),r!==t.t&&R(i,`title`,t.t=r),t.a=F(i,s,t.a),t.o=F(a,l,t.o),t.i=F(o,u,t.i),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}}),null),T(e,n(h,{get when(){return I(()=>!!kp())()&&jp()},get children(){var e=vh();return ge(e,`pointerdown`,C(0),!0),r(t=>B(e,`background`,f()===0?`#388bfd`:`#21262d`)),e}}),null),T(e,n(h,{get when(){return jp()},get children(){var e=yh(),t=e.firstChild,i=t.nextSibling,a=i.firstChild.nextSibling;a.nextSibling,t.addEventListener(`scroll`,()=>{_&&l(_.scrollHeight-_.scrollTop-_.clientHeight<20)});var o=_;return typeof o==`function`?Pe(o,t):_=t,T(t,(()=>{var e=I(()=>P().length===0);return()=>e()&&Th()})(),null),T(t,n(b,{get each(){return P()},children:e=>(()=>{var t=Eh();return t.innerHTML=e,t})()}),null),i.addEventListener(`submit`,ie),a.$$keydown=re,a.$$input=e=>{M(null),Rp(e.currentTarget.value)},Pe(e=>Bp(e),a),r(n=>{var r=`${S()[1]*100}%`,i={...ce};return r!==n.e&&B(e,`width`,n.e=r),n.t=F(t,i,n.t),n},{e:void 0,t:void 0}),r(()=>a.value=Lp()),e}}),null),T(e,n(h,{get when(){return I(()=>!!jp())()&&Np()},get children(){var e=vh();return ge(e,`pointerdown`,C(1),!0),r(t=>B(e,`background`,f()===1?`#388bfd`:`#21262d`)),e}}),null),T(e,n(h,{get when(){return Np()},get children(){return n(Oh,{get shard(){return t.shard??null},get width(){return S()[2]}})}}),null),r(t=>B(e,`user-select`,f()===null?`auto`:`none`)),e}}),null),r(e=>{var t=ae(kp()),n=ae(jp()),r=ae(Np()),i=ae(Fp());return e.e=F(a,t,e.e),e.t=F(o,n,e.t),e.a=F(u,r,e.a),e.o=F(d,i,e.o),e},{e:void 0,t:void 0,a:void 0,o:void 0}),e})()}P([`input`,`click`,`pointerdown`,`keydown`]);var Ah=z(`<div style=display:flex;gap:5px;flex-wrap:wrap>`),jh=z(`<div style=width:18px;height:18px;border-radius:50%;cursor:pointer;flex-shrink:0>`),Mh=[{label:`Red`,value:1,css:`#ff0000`},{label:`Purple`,value:2,css:`#800080`},{label:`Blue`,value:3,css:`#0000ff`},{label:`Cyan`,value:4,css:`#00ffff`},{label:`Green`,value:5,css:`#008000`},{label:`Yellow`,value:6,css:`#ffff00`},{label:`Orange`,value:7,css:`#ffa500`},{label:`Brown`,value:8,css:`#a52a2a`},{label:`Grey`,value:9,css:`#808080`},{label:`White`,value:10,css:`#ffffff`}];function Nh(e){return(()=>{var t=Ah();return T(t,n(b,{each:Mh,children:t=>(()=>{var n=jh();return n.$$click=()=>e.onChange(t.value),r(r=>{var i=t.label,a=t.css,o=e.value===t.value?`0 0 0 2px #0d1117, 0 0 0 4px #c9d1d9`:`none`;return i!==r.e&&R(n,`title`,r.e=i),a!==r.t&&B(n,`background`,r.t=a),o!==r.a&&B(n,`box-shadow`,r.a=o),r},{e:void 0,t:void 0,a:void 0}),n})()})),t})()}P([`click`]);function Ph(e){return e?`${Ve()}/map/${encodeURIComponent(e)}`:`${Ve()}/map`}function Fh(e,t){return t?`${Ve()}/room/${encodeURIComponent(t)}/${e}`:`${Ve()}/room/${e}`}function Ih(e,t){return t?`${Ve()}/room-overview/${encodeURIComponent(t)}/${e}`:`${Ve()}/room-overview/${e}`}function Lh(){return`${Ve()}/user`}function Rh(){return`${Ve()}/user/`}function zh(){return`${Ve()}/user/power`}function Bh(){return`${Ve()}/user/power/`}function Vh(){return`${Ve()}/messages`}function Hh(){return`${Ve()}/messages/`}function Uh(){return`${Ve()}/profile/`}function Wh(){return`${Ve()}/room-overview/`}function Gh(){return`${Ve()}/market`}function Kh(){return`${Ve()}/market/`}function qh(){return window.location.pathname+window.location.search+window.location.hash}function Jh(){let e=window.location.pathname;return e===Lh()||e.startsWith(Rh())?`user`:e.startsWith(Uh())?`profile`:e===Vh()||e.startsWith(Hh())?`messages`:e===Gh()||e.startsWith(Kh())?`market`:e.startsWith(Wh())?`room-overview`:`game`}function Yh(){let e=window.location.pathname;if(!e.startsWith(Wh()))return null;let t=e.slice(Wh().length).split(`/`).filter(Boolean).map(decodeURIComponent);return t.length>=2?{shard:t[0],room:t[1]}:t.length===1?{shard:null,room:t[0]}:null}function Xh(){let e=window.location.pathname;return e===zh()||e.startsWith(Bh())?`power`:`overview`}function Zh(){let e=window.location.pathname;return e.startsWith(Hh())&&decodeURIComponent(e.slice(Hh().length))||null}function Qh(){let e=window.location.pathname;return e.startsWith(Uh())&&decodeURIComponent(e.slice(Uh().length))||null}function $h(){let e=window.location.pathname;if(e===`${Gh()}/my`)return{view:`my-orders`,resourceType:null};if(e===`${Gh()}/history`)return{view:`history`,resourceType:null};let t=`${Kh()}resource/`;if(e.startsWith(t)){let n=decodeURIComponent(e.slice(t.length));if(n)return{view:`resource`,resourceType:n}}return{view:`all-orders`,resourceType:null}}function eg(){return new URLSearchParams(window.location.search).get(`shard`)}function tg(){return new URLSearchParams(window.location.search).get(`room`)}function ng(){let e=window.location.pathname;if(e===`${zh()}/new`)return{view:`new`,id:null};if(e.startsWith(Bh())){let t=decodeURIComponent(e.slice(Bh().length));if(t)return{view:`detail`,id:t}}return{view:`list`,id:null}}var[J,rg]=e(Jh()),[ig,ag]=e(Xh()),[og,sg]=e(Qh()),[cg,lg]=e(Zh()),[ug,dg]=e($h().view),[fg,pg]=e($h().resourceType),[mg,hg]=e(eg()),[gg,_g]=e(tg()),[vg,yg]=e(ng().view),[bg,xg]=e(ng().id),[Sg,Cg]=e(Yh()),wg=Jh()===`game`?qh():`${Ve()}/map`;function Tg(){Jh()===`game`&&(wg=qh())}function Eg(){Tg(),history.pushState(null,``,Lh()),ag(`overview`),yg(`list`),xg(null),rg(`user`)}function Dg(){Tg(),history.pushState(null,``,Vh()),lg(null),rg(`messages`)}function Og(e){Tg(),history.pushState(null,``,`${Hh()}${encodeURIComponent(e)}`),lg(e),rg(`messages`)}function kg(){Tg(),history.pushState(null,``,zh()),ag(`power`),xg(null),yg(`list`),rg(`user`)}function Ag(){Tg(),history.pushState(null,``,`${zh()}/new`),ag(`power`),xg(null),yg(`new`),rg(`user`)}function jg(e){Tg(),history.pushState(null,``,`${Bh()}${encodeURIComponent(e)}`),ag(`power`),xg(e),yg(`detail`),rg(`user`)}function Mg(e){Tg(),history.pushState(null,``,`${Uh()}${encodeURIComponent(e)}`),sg(e),rg(`profile`)}function Ng(e,t){let n=new URLSearchParams;e&&n.set(`shard`,e),t&&n.set(`room`,t);let r=n.toString();return r?`?${r}`:``}function Pg(e,t){let n=t===void 0?gg():t;Tg(),history.pushState(null,``,`${Gh()}${Ng(e??null,n)}`),pg(null),hg(e??null),_g(n),dg(`all-orders`),rg(`market`)}function Fg(e,t,n){let r=n===void 0?gg():n;Tg(),history.pushState(null,``,`${Kh()}resource/${encodeURIComponent(e)}${Ng(t??null,r)}`),pg(e),hg(t??null),_g(r),dg(`resource`),rg(`market`)}function Ig(){Tg(),history.pushState(null,``,`${Gh()}/my`),pg(null),dg(`my-orders`),rg(`market`)}function Lg(){Tg(),history.pushState(null,``,`${Gh()}/history`),pg(null),dg(`history`),rg(`market`)}function Rg(e,t){Tg(),history.pushState(null,``,Ih(e,t)),Cg({room:e,shard:t}),rg(`room-overview`)}function zg(){history.pushState(null,``,wg),rg(`game`)}function Bg(e,t){let n=Fh(e,t);wg=n,history.pushState(null,``,n),rg(`game`)}typeof window<`u`&&window.addEventListener(`popstate`,()=>{rg(Jh()),ag(Xh()),sg(Qh()),lg(Zh());let e=$h();dg(e.view),pg(e.resourceType),hg(eg()),_g(tg());let t=ng();yg(t.view),xg(t.id),Cg(Yh())});var Vg=z(`<span title="View user profile"style=cursor:pointer>`),Hg=new Set([`Invader`,`Source Keeper`]);function Ug(e){let t=()=>!!e.username&&!Hg.has(e.username);return n(h,{get when(){return t()},get fallback(){return I(()=>e.username??e.fallback)},get children(){var t=Vg();return t.addEventListener(`mouseleave`,t=>t.currentTarget.style.color=e.color??`inherit`),t.addEventListener(`mouseenter`,e=>e.currentTarget.style.color=`#58a6ff`),t.$$click=t=>{t.stopPropagation(),Mg(e.username)},T(t,()=>e.children??e.username),r(n=>F(t,{color:e.color??`inherit`,...e.style},n)),t}})}P([`click`]);var Wg=z(`<div style="display:flex;flex-wrap:wrap;gap:4px;padding:6px 8px;background:#0d1117;border-top:1px solid #21262d">`),Gg=z(`<div style=display:flex;gap:4px><select style="background:#161b22;color:#c9d1d9;border:1px solid #30363d;border-radius:4px;padding:3px 5px;font-size:11px;min-width:0"></select><button>`),Kg=z(`<button>`),qg=z(`<option>`);function Jg(t){let[i,o]=e(null),[s,c]=nf({}),[l,u]=nf({}),d;a(()=>window.clearTimeout(d));let f=()=>{let e=t.item.raw.user;return typeof e==`string`?e:null},p=()=>{let e=xm();return!e||q()?[]:e.objects.map((e,n)=>({el:e,key:`obj:${n}:${t.item.id}`})).filter(({el:e})=>Om(e,t.item.type,f()))},m=e=>{let t=l[e];return!!t&&Rm().has(t)},g=()=>{let e=t.item.raw,n=uf(),r=ip();return{view:`room`,shard:$n(),room:ar()??void 0,selection:n.length>0?n.map(e=>({id:e.id,type:e.type,name:e.raw.name})):void 0,tile:r?{x:r.tx,y:r.ty}:void 0,target:{id:t.item.id,type:t.item.type,name:typeof e.name==`string`?e.name:void 0,x:typeof e.x==`number`?e.x:void 0,y:typeof e.y==`number`?e.y:void 0}}},_=(e,t,n)=>{if(e.confirm&&i()!==t){o(t),window.clearTimeout(d),d=window.setTimeout(()=>o(null),3e3);return}window.clearTimeout(d),o(null);let r=qm(e,g(),n);r&&u(t,r)},v=(e,t)=>({padding:`4px 8px`,"border-radius":`4px`,border:`1px solid ${t?`#da3633`:`#30363d`}`,background:t?`#3d1a1a`:`#21262d`,color:e?`#484f58`:t?`#f85149`:`#c9d1d9`,"font-size":`11px`,cursor:e?`default`:`pointer`});return n(h,{get when(){return p().length>0},get children(){var e=Wg();return T(e,n(b,{get each(){return p()},children:({el:e,key:t})=>{let a=()=>m(t),o=()=>i()===t,l=()=>a()?`${e.label} …`:o()?`${e.label} — confirm?`:e.label;return n(h,{get when(){return e.type===`select`},get fallback(){return(()=>{var n=Kg();return n.$$click=()=>_(e,t),T(n,l),r(t=>{var r=a(),i=e.cmd,s=v(a(),o());return r!==t.e&&(n.disabled=t.e=r),i!==t.t&&R(n,`title`,t.t=i),t.a=F(n,s,t.a),t},{e:void 0,t:void 0,a:void 0}),n})()},get children(){var i=Gg(),l=i.firstChild,u=l.nextSibling;return l.addEventListener(`change`,e=>c(t,e.currentTarget.value)),T(l,n(b,{get each(){return e.options},children:e=>(()=>{var t=qg();return t.value=e,T(t,e),t})()})),u.$$click=()=>_(e,t,s[t]??e.options[0]),T(u,(()=>{var t=I(()=>!!a());return()=>t()?`…`:I(()=>!!o())()?`confirm?`:e.label})()),r(t=>{var n=e.label,r=a(),i=e.cmd,s=v(a(),o());return n!==t.e&&R(l,`title`,t.e=n),r!==t.t&&(u.disabled=t.t=r),i!==t.a&&R(u,`title`,t.a=i),t.o=F(u,s,t.o),t},{e:void 0,t:void 0,a:void 0,o:void 0}),r(()=>l.value=s[t]??e.options[0]),i}})}})),e}})}P([`click`]);var Yg=z(`<div>`),Xg=z(`<div style=font-variant-numeric:tabular-nums>`),Zg=z(`<span style=font-variant-numeric:tabular-nums;font-weight:400> / `),Qg=z(`<div style="background:#21262d;border-top:1px solid #30363d;font-size:10px"><div style="padding:4px 8px;background:#161b22;color:#8b949e;font-weight:600;display:flex;justify-content:space-between"><span>Store Contents</span></div><div style="display:grid;grid-template-columns:1fr 1fr;gap:1px;background:#21262d">`),$g=z(`<div style="padding:3px 8px;background:#0d1117;color:#8b949e">`),e_=z(`<div style="padding:3px 8px;background:#0d1117;color:#c9d1d9;font-variant-numeric:tabular-nums">`),t_=z(`<div>Owner`),n_=z(`<div>Hits`),r_=z(`<div style=font-variant-numeric:tabular-nums> / `),i_=z(`<div>Time to live`),a_=z(`<div>Fatigue`),o_=z(`<div style="background:#21262d;border-top:1px solid #30363d;font-size:10px"><div style="padding:4px 8px;background:#161b22;color:#8b949e;font-weight:600">Body (<!>)</div><div style=display:flex;flex-wrap:wrap;gap:3px;padding:8px;background:#0d1117></div><div style="display:flex;flex-wrap:wrap;gap:2px 10px;padding:0 8px 8px;background:#0d1117">`),s_=z(`<div><div>`),c_=z(`<div style=width:11px;height:11px;border-radius:50%;flex-shrink:0>`),l_=z(`<span style=font-size:10px;font-variant-numeric:tabular-nums><span style=color:#8b949e>×</span><span>`),u_=z(`<div style=display:flex;gap:6px><button style="flex:1;border-radius:4px;padding:5px 8px;font-size:11px;transition:background 150ms ease, color 150ms ease, border-color 150ms ease">Apply color</button><button style="border-radius:4px;padding:5px 8px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background 150ms ease, color 150ms ease">`),d_=z(`<div style=padding:8px;display:flex;flex-direction:column;gap:8px;background:#0d1117><label>Primary color</label><label>Secondary color`),f_=z(`<label>Target room<input style="background:#010409;color:#c9d1d9;border:1px solid #30363d;border-radius:4px;padding:5px 6px;font-size:12px;outline:none"><span style=font-size:10px;color:#484f58>Navigate to target room, then click a tile`),p_=z(`<div>Reserved by`),m_=z(`<div>Reservation`),h_=z(`<div style=font-variant-numeric:tabular-nums> ticks`),g_=z(`<div>Level`),__=z(`<div>Safe modes`),v_=z(`<div>Power`),y_=z(`<div>Downgrade in`),b_=z(`<div>Safe mode active`),x_=z(`<div style="padding:5px 8px;background:#0d1117;border-top:1px solid #21262d"><div style=display:flex;justify-content:space-between;font-size:10px;margin-bottom:4px><span style=color:#8b949e>RCL <!> → </span><span style=color:#c9d1d9;font-variant-numeric:tabular-nums> / <!> (<!>%)</span></div><div style=height:5px;background:#21262d;border-radius:3px;overflow:hidden><div style=height:100%;background:#58a6ff;border-radius:3px>`),S_=z(`<div style=padding:8px;display:flex;flex-direction:column;gap:6px;background:#0d1117><button style="color:#fff;border:none;border-radius:4px;padding:6px 8px;font-size:12px">Activate safe mode</button><button style="color:#fff;border:none;border-radius:4px;padding:6px 8px;font-size:12px;cursor:pointer">`),C_=z(`<div><div><div>Owner</div><div>`),w_=z(`<div>Cooldown`),T_=z(`<div>Notify when attacked`),E_=z(`<div style=display:flex;align-items:center><button style=background:transparent;border:none;cursor:pointer;padding:0;display:flex;align-items:center>`),D_=z(`<div><div>Energy</div><div style=font-variant-numeric:tabular-nums> / `),O_=z(`<div><div>Hits</div><div style=font-variant-numeric:tabular-nums> / `),k_=z(`<div style="padding:5px 8px;background:#0d1117;border-top:1px solid #21262d"><div style=display:flex;justify-content:space-between;font-size:10px;margin-bottom:4px><span style=color:#8b949e>Fill</span><span style=color:#c9d1d9;font-variant-numeric:tabular-nums> / <!> (<!>%)</span></div><div style=height:5px;background:#21262d;border-radius:3px;overflow:hidden><div style=height:100%;background:#ffe87b;border-radius:3px>`),A_=z(`<div style=font-variant-numeric:tabular-nums> `),j_=z(`<div>Decays in`),M_=z(`<div>Decay in`),N_=z(`<div>Energy cap`),P_=z(`<div style="background:#21262d;border-top:1px solid #30363d;font-size:10px"><div style="padding:4px 8px;background:#161b22;color:#8b949e;font-weight:600">Was: </div><div>`),F_=z(`<div style=width:8px;height:8px;border-radius:50%;flex-shrink:0>`),I_=z(`<button style="background:transparent;border:none;cursor:pointer;padding:0 2px;display:flex;align-items:center;justify-content:center;flex-shrink:0">`),L_=z(`<button title="Watch memory"style="background:transparent;border:none;color:#8b949e;cursor:pointer;padding:0 2px;display:flex;align-items:center;justify-content:center;flex-shrink:0">`),R_=z(`<div style="border-radius:6px;margin-bottom:6px;overflow:hidden;transition:border-color 150ms ease"><div style="display:flex;align-items:center;gap:7px;padding:6px 8px;background:#161b22;border-bottom:1px solid #21262d"><span style=font-size:11px;font-weight:600;color:#c9d1d9;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:flex;align-items:center;gap:5px></span><span style=font-size:10px;color:#484f58;flex-shrink:0;margin-right:2px>(<!>,<!>)</span><button title=Deselect style="background:transparent;border:none;color:#8b949e;cursor:pointer;padding:0 4px;font-size:14px;line-height:1;display:flex;align-items:center;justify-content:center">×`),z_=z(`<span style=font-weight:400;color:#8b949e>`),B_=z(`<div style="padding:3px 8px;border-top:1px solid #21262d;font-size:9px;color:#484f58;font-family:monospace;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:pointer">`),V_=z(`<div style=flex:1;overflow:auto;min-height:0;padding:8px>`),H_=z(`<div style=color:#484f58;font-style:italic;font-size:12px>Click a tile to select objects…`),{log:U_,error:W_}=ce(`SelectionList`),G_={creep:`#f0883e`,spawn:`#58a6ff`,extension:`#79c0ff`,tower:`#3fb950`,container:`#8b949e`,storage:`#d29922`,link:`#a371f7`,rampart:`#58a6ff`,road:`#484f58`,wall:`#21262d`,extractor:`#8b949e`,lab:`#f778ba`,terminal:`#d29922`,observer:`#79c0ff`,powerSpawn:`#f0883e`,nuker:`#f85149`,factory:`#8b949e`,invaderCore:`#f85149`,source:`#d29922`,mineral:`#79c0ff`,deposit:`#d29922`,controller:`#58a6ff`,powerBank:`#f0883e`,portal:`#a371f7`,keeperLair:`#f85149`,energy:`#d29922`},K_={creep:`Creep`,spawn:`Spawn`,extension:`Extension`,tower:`Tower`,container:`Container`,storage:`Storage`,link:`Link`,rampart:`Rampart`,road:`Road`,wall:`Wall`,extractor:`Extractor`,lab:`Lab`,terminal:`Terminal`,observer:`Observer`,powerSpawn:`Power Spawn`,nuker:`Nuker`,factory:`Factory`,invaderCore:`Invader Core`,source:`Source`,mineral:`Mineral`,deposit:`Deposit`,controller:`Controller`,powerBank:`Power Bank`,portal:`Portal`,keeperLair:`Keeper Lair`,energy:`Energy`,flag:`Flag`},q_=new Set([`x`,`y`,`type`,`id`,`name`,`user`,`_id`,`room`,`hitsMax`,`energyCapacity`,`body`,`storeCapacity`,`storeCapacityResource`,`invaderHarvested`,`ticksToRegeneration`]),J_=new Set([`hits`,`energy`,`energyCapacity`,`store`,`progress`,`progressTotal`,`nextDecayTime`,`ticksToRegeneration`,`nextRegenerationTime`]),Y_={hits:`Hits`,energy:`Energy`,progress:`Progress`,progressTotal:`Progress total`,ticksToLive:`Ticks to live`,ticksToDecay:`Ticks to decay`,nextDecayTime:`Decays in`,nextRegenerationTime:`Regens in`,fatigue:`Fatigue`,cooldown:`Cooldown`,mineralType:`Mineral type`,mineralAmount:`Mineral amount`,density:`Density`,notifyWhenAttacked:`Notify when attacked`,isPublic:`Public`,structureType:`Structure type`,level:`Level`,power:`Power`,powerCapacity:`Power capacity`,depositType:`Deposit type`,lastCooldown:`Last cooldown`,resourceType:`Resource type`,amount:`Amount`,decay:`Decay in`,mode:`Mode`,actionLog:`Action log`,store:`Store`};function X_(e){return Y_[e]?Y_[e]:e.replace(/([A-Z])/g,` $1`).replace(/^./,e=>e.toUpperCase()).trim()}function Z_(e){return typeof e==`number`?String(e):typeof e==`string`?e:typeof e==`boolean`?e?`Yes`:`No`:null}function Q_(e){if(e>=1e6){let t=e/1e6;return`${parseFloat(t.toFixed(2))}M`}if(e>=1e3){let t=e/1e3;return`${parseFloat(t.toFixed(1))}K`}return String(e)}var Y=(e=!1)=>({padding:`3px 8px`,background:`#0d1117`,color:e?`#8b949e`:`#c9d1d9`,overflow:`hidden`,"text-overflow":`ellipsis`,"white-space":`nowrap`}),$_={display:`grid`,"grid-template-columns":`1fr 1fr`,gap:`1px`,background:`#21262d`,"font-size":`10px`};function ev(e){let t=()=>{let t=e.item.raw,n=[];for(let e in t){if(q_.has(e))continue;let r=t[e],i=Z_(r);if(!(e===`notifyWhenAttacked`&&r===!1)&&!(e===`off`&&r===!1)){if(e===`hits`&&typeof t.hitsMax==`number`&&(i=`${r} / ${t.hitsMax}`),e===`energy`&&typeof t.energyCapacity==`number`&&(i=`${r} / ${t.energyCapacity}`),e===`nextDecayTime`&&typeof r==`number`){let e=V();e!==null&&(i=String(r-e))}if(e===`nextRegenerationTime`&&typeof r==`number`){let e=V();e!==null&&(i=String(r-e))}i!==null&&n.push({key:e,label:X_(e),value:i})}}return n.sort((e,t)=>!J_.has(e.key)-+!J_.has(t.key)),n};return n(h,{get when(){return t().length>0},get children(){var e=Yg();return T(e,n(b,{get each(){return t()},children:e=>[(()=>{var t=Yg();return T(t,()=>e.label),r(e=>F(t,Y(!0),e)),t})(),(()=>{var t=Xg();return T(t,()=>e.value),r(e=>F(t,{...Y()},e)),t})()]})),r(t=>F(e,$_,t)),e}})}function tv(e){let t=()=>{let t=e.store||{},n=[];for(let e in t)n.push([e,t[e]]);return n},r=()=>{let t=e.store||{},n=0;for(let e in t)n+=t[e];return n};return n(h,{get when(){return t().length>0},get children(){var i=Qg(),a=i.firstChild;a.firstChild;var o=a.nextSibling;return T(a,n(h,{get when(){return e.capacity!=null},get children(){var t=Zg(),n=t.firstChild;return T(t,r,n),T(t,()=>e.capacity,null),t}}),null),T(o,n(b,{get each(){return t()},children:([e,t])=>[(()=>{var t=$g();return T(t,e),t})(),(()=>{var e=e_();return T(e,t),e})()]})),i}})}var nv={tough:`#4c4c4c`,move:`#a9b7c6`,work:`#ffe56d`,carry:`#777777`,attack:`#f93842`,ranged_attack:`#5d80b2`,heal:`#65fd62`,claim:`#b99cfb`};function rv(e){let t=()=>e.item.raw,i=()=>typeof t().user==`string`?t().user:null,a=()=>{let e=i();return e?er()?.[e]?.username??null:null},o=()=>{let e=i();return e?a()??e:null},s=()=>typeof t().hits==`number`?t().hits:null,c=()=>typeof t().hitsMax==`number`?t().hitsMax:null,l=()=>{let e=t().ageTime,n=V();return typeof e==`number`&&n!==null?Math.max(0,e-n):null},u=()=>typeof t().fatigue==`number`?t().fatigue:null,d=()=>t().store,f=()=>typeof t().storeCapacity==`number`?t().storeCapacity:null,p=()=>t().body??[],m=()=>{let e=new Map;for(let t of p())e.set(t.type,(e.get(t.type)??0)+1);return[...e.entries()].map(([e,t])=>({type:e,count:t}))};return(()=>{var e=s_(),t=e.firstChild;return T(t,n(h,{get when(){return o()},get children(){return[(()=>{var e=t_();return r(t=>F(e,Y(!0),t)),e})(),(()=>{var e=Yg();return T(e,n(Ug,{get username(){return a()},get fallback(){return o()}})),r(t=>F(e,Y(),t)),e})()]}}),null),T(t,n(h,{get when(){return I(()=>s()!==null)()&&c()!==null},get children(){return[(()=>{var e=n_();return r(t=>F(e,Y(!0),t)),e})(),(()=>{var e=r_(),t=e.firstChild;return T(e,s,t),T(e,c,null),r(t=>F(e,{...Y()},t)),e})()]}}),null),T(t,n(h,{get when(){return l()!==null},get children(){return[(()=>{var e=i_();return r(t=>F(e,Y(!0),t)),e})(),(()=>{var e=Xg();return T(e,l),r(t=>F(e,{...Y()},t)),e})()]}}),null),T(t,n(h,{get when(){return u()!==null},get children(){return[(()=>{var e=a_();return r(t=>F(e,Y(!0),t)),e})(),(()=>{var e=Xg();return T(e,u),r(t=>F(e,{...Y(),color:u()>0?`#e3b341`:void 0},t)),e})()]}}),null),T(e,n(tv,{get store(){return d()},get capacity(){return f()}}),null),T(e,n(h,{get when(){return p().length>0},get children(){var e=o_(),t=e.firstChild,i=t.firstChild.nextSibling;i.nextSibling;var a=t.nextSibling,o=a.nextSibling;return T(t,()=>p().length,i),T(a,n(b,{get each(){return p()},children:e=>(()=>{var t=c_();return r(n=>{var r=e.type.replace(`_`,` `),i=nv[e.type]??`#484f58`,a=e.hits===0?.25:1;return r!==n.e&&R(t,`title`,n.e=r),i!==n.t&&B(t,`background`,n.t=i),a!==n.a&&B(t,`opacity`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),t})()})),T(o,n(b,{get each(){return m()},children:({type:e,count:t})=>(()=>{var n=l_(),i=n.firstChild,a=i.firstChild,o=i.nextSibling;return T(i,t,a),T(o,()=>e.replace(`_`,` `).toUpperCase()),r(t=>B(o,`color`,nv[e]??`#484f58`)),n})()})),e}}),null),r(e=>F(t,$_,e)),e})()}function iv(t){let i=()=>t.item.raw,a=()=>typeof i().name==`string`?i().name:``,o=()=>typeof i().room==`string`?i().room:``,s=()=>typeof i().color==`number`?i().color:1,c=()=>typeof i().secondaryColor==`number`?i().secondaryColor:1,[l,u]=e(s()),[d,f]=e(c());p(()=>{u(s()),f(c())});let m=()=>l()!==s()||d()!==c(),g=()=>{let e=L();if(!e)return;let t=l(),n=d();U_(`changeFlagColor: name="${a()}" room=${o()} primary=${t} secondary=${n}`),e.http.game.changeFlagColor(o(),a(),t,n,$n()??void 0).then(()=>U_(`changeFlagColor OK`)).catch(e=>W_(`changeFlagColor FAILED:`,e))},_=()=>{let e=op();return e?.type===`moveFlag`&&e.id===t.item.id},v=()=>{if(_()){sp(null);return}sp({type:`moveFlag`,id:t.item.id,name:a(),room:o(),color:l(),secondaryColor:d(),targetRoom:ar()??o()})},y=()=>{let e=op();return e?.type===`moveFlag`&&e.id===t.item.id?e:null},b={display:`flex`,"flex-direction":`column`,gap:`5px`,"font-size":`11px`,color:`#8b949e`};return(()=>{var e=d_(),t=e.firstChild;t.firstChild;var i=t.nextSibling;return i.firstChild,T(t,n(Nh,{get value(){return l()},onChange:u}),null),T(i,n(Nh,{get value(){return d()},onChange:f}),null),T(e,n(h,{get when(){return!q()},get children(){return[(()=>{var e=u_(),t=e.firstChild,i=t.nextSibling;return t.addEventListener(`mouseleave`,e=>{m()&&(e.currentTarget.style.background=`#238636`)}),t.addEventListener(`mouseenter`,e=>{m()&&(e.currentTarget.style.background=`#2ea043`)}),t.$$click=g,i.addEventListener(`mouseleave`,e=>{e.currentTarget.style.color=_()?`#c9d1d9`:`#8b949e`}),i.addEventListener(`mouseenter`,e=>{e.currentTarget.style.color=`#c9d1d9`}),i.$$click=v,T(i,(()=>{var e=I(()=>!!_());return()=>e()?n(ya,{size:13}):n(Li,{size:13})})()),r(e=>{var n=!m(),r=m()?`#238636`:`#161b22`,a=m()?`#fff`:`#484f58`,o=`1px solid ${m()?`#238636`:`#30363d`}`,s=m()?`pointer`:`not-allowed`,c=_()?`Abort move`:`Move flag`,l=_()?`#30363d`:`#21262d`,u=_()?`#c9d1d9`:`#8b949e`,d=`1px solid ${_()?`#8b949e`:`#30363d`}`;return n!==e.e&&(t.disabled=e.e=n),r!==e.t&&B(t,`background`,e.t=r),a!==e.a&&B(t,`color`,e.a=a),o!==e.o&&B(t,`border`,e.o=o),s!==e.i&&B(t,`cursor`,e.i=s),c!==e.n&&R(i,`title`,e.n=c),l!==e.s&&B(i,`background`,e.s=l),u!==e.h&&B(i,`color`,e.h=u),d!==e.r&&B(i,`border`,e.r=d),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0}),e})(),n(h,{get when(){return y()},children:e=>(()=>{var t=f_(),n=t.firstChild.nextSibling;return n.nextSibling,n.$$input=t=>sp({...e(),targetRoom:t.currentTarget.value.toUpperCase()}),r(e=>F(t,b,e)),r(()=>n.value=e().targetRoom),t})()})]}}),null),r(e=>{var n=b,r=b;return e.e=F(t,n,e.e),e.t=F(i,r,e.t),e},{e:void 0,t:void 0}),e})()}function av(t){let i=()=>t.item.raw,a=()=>typeof i().level==`number`?i().level:0,o=()=>typeof i().progress==`number`?i().progress:null,s=()=>typeof i().progressTotal==`number`?i().progressTotal:Ms[a()]??null,c=()=>typeof i().downgradeTime==`number`?i().downgradeTime:null,l=()=>typeof i().safeModeAvailable==`number`?i().safeModeAvailable:0,u=()=>typeof i().safeMode==`number`?i().safeMode:null,d=()=>i().isPowerEnabled===!0,f=()=>i().reservation,p=()=>typeof i().user==`string`?i().user:null,m=()=>{let e=p();return e?fr()?.username??e:null},g=()=>{let e=c(),t=V();return e!==null&&t!==null?Math.max(0,e-t):null},_=()=>{let e=g();if(e===null)return`—`;let t=Ns[a()];return t!==void 0&&e>=t?`Max`:String(e)},v=()=>p()!==null&&p()===H()?._id,[y,b]=e(!1),x=null,S=()=>{let e=L();e&&e.http.game.addObjectIntent(t.item.id,ar()??i().room??``,`activateSafeMode`,{id:t.item.id},$n()).catch(e=>W_(`activateSafeMode failed:`,e))},C=()=>{if(!y()){b(!0),x=setTimeout(()=>b(!1),3e3);return}x&&=(clearTimeout(x),null),b(!1);let e=L();e&&e.http.game.addObjectIntent(t.item.id,ar()??i().room??``,`unclaim`,{id:t.item.id},$n()).catch(e=>W_(`unclaim failed:`,e))};return(()=>{var e=C_(),t=e.firstChild,i=t.firstChild,c=i.nextSibling;return T(c,n(Ug,{get username(){return fr()?.username},get fallback(){return m()??`None`}})),T(t,n(h,{get when(){return f()},get children(){return[(()=>{var e=p_();return r(t=>F(e,Y(!0),t)),e})(),(()=>{var e=Yg();return T(e,n(Ug,{get username(){return er()?.[f().user]?.username},get fallback(){return f().user}})),r(t=>F(e,Y(),t)),e})(),(()=>{var e=m_();return r(t=>F(e,Y(!0),t)),e})(),(()=>{var e=h_(),t=e.firstChild;return T(e,(()=>{var e=I(()=>V()!==null);return()=>e()?Math.max(0,f().endTime-V()):f().endTime})(),t),r(t=>F(e,{...Y()},t)),e})()]}}),null),T(t,n(h,{get when(){return a()>0},get children(){return[(()=>{var e=g_();return r(t=>F(e,Y(!0),t)),e})(),(()=>{var e=Yg();return T(e,a),r(t=>F(e,Y(),t)),e})(),(()=>{var e=__();return r(t=>F(e,Y(!0),t)),e})(),(()=>{var e=Yg();return T(e,l),r(t=>F(e,Y(),t)),e})(),(()=>{var e=v_();return r(t=>F(e,Y(!0),t)),e})(),(()=>{var e=Yg();return T(e,()=>d()?`Enabled`:`Disabled`),r(t=>F(e,Y(),t)),e})(),(()=>{var e=y_();return r(t=>F(e,Y(!0),t)),e})(),(()=>{var e=Xg();return T(e,_),r(t=>F(e,{...Y(),color:_()===`Max`?`#3fb950`:void 0},t)),e})()]}}),null),T(t,n(h,{get when(){return u()!==null},get children(){return[(()=>{var e=b_();return r(t=>F(e,Y(!0),t)),e})(),(()=>{var e=h_(),t=e.firstChild;return T(e,u,t),r(t=>F(e,{...Y()},t)),e})()]}}),null),T(e,n(h,{get when(){return I(()=>a()>0&&a()<8&&o()!==null)()&&s()!==null},get children(){var e=x_(),t=e.firstChild,n=t.firstChild,i=n.firstChild.nextSibling;i.nextSibling;var c=n.nextSibling,l=c.firstChild,u=l.nextSibling,d=u.nextSibling.nextSibling;d.nextSibling;var f=t.nextSibling.firstChild;return T(n,a,i),T(n,()=>a()+1,null),T(c,()=>Q_(o()),l),T(c,()=>Q_(s()),u),T(c,()=>(o()/s()*100).toFixed(1),d),r(e=>B(f,`width`,`${Math.min(100,o()/s()*100)}%`)),e}}),null),T(e,n(h,{get when(){return I(()=>!!v())()&&!q()},get children(){var e=S_(),t=e.firstChild,n=t.nextSibling;return t.addEventListener(`mouseleave`,e=>{l()>0&&(e.currentTarget.style.background=`#1f6feb`)}),t.addEventListener(`mouseenter`,e=>{l()>0&&(e.currentTarget.style.background=`#388bfd`)}),t.$$click=S,n.addEventListener(`mouseleave`,e=>{y()||(e.currentTarget.style.background=`#f85149`)}),n.addEventListener(`mouseenter`,e=>{y()||(e.currentTarget.style.background=`#da3633`)}),n.$$click=C,T(n,()=>y()?`Confirm unclaim`:`Unclaim`),r(e=>{var r=l()===0,i=l()>0?`#1f6feb`:`#161b22`,a=l()>0?`pointer`:`not-allowed`,o=l()>0?1:.5,s=y()?`#da3633`:`#f85149`;return r!==e.e&&(t.disabled=e.e=r),i!==e.t&&B(t,`background`,e.t=i),a!==e.a&&B(t,`cursor`,e.a=a),o!==e.o&&B(t,`opacity`,e.o=o),s!==e.i&&B(n,`background`,e.i=s),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}}),null),r(e=>{var n=$_,r=Y(!0),a=Y();return e.e=F(t,n,e.e),e.t=F(i,r,e.t),e.a=F(c,a,e.a),e},{e:void 0,t:void 0,a:void 0}),e})()}function ov(e){let t=()=>e.item.raw,i=()=>t().store?.energy??0,a=()=>t().storeCapacityResource?.energy??0,o=()=>typeof t().hits==`number`?t().hits:null,s=()=>typeof t().hitsMax==`number`?t().hitsMax:null,c=()=>{if(typeof t().cooldown==`number`)return t().cooldown;let e=t().cooldownTime,n=V();return typeof e==`number`&&n!==null?Math.max(0,e-n):null},l=()=>t().notifyWhenAttacked===!0,u=()=>typeof t().user==`string`?t().user:null,d=()=>u()!==null&&u()===H()?._id,f=()=>{let n=L();n&&n.http.game.addObjectIntent(e.item.id,t().room,`notifyWhenAttacked`,{enabled:!l()}).catch(e=>W_(`notifyWhenAttacked failed:`,e))};return(()=>{var e=D_(),t=e.firstChild,u=t.nextSibling,p=u.firstChild;return T(u,i,p),T(u,a,null),T(e,n(h,{get when(){return I(()=>o()!==null)()&&s()!==null},get children(){return[(()=>{var e=n_();return r(t=>F(e,Y(!0),t)),e})(),(()=>{var e=r_(),t=e.firstChild;return T(e,o,t),T(e,s,null),r(t=>F(e,{...Y()},t)),e})()]}}),null),T(e,n(h,{get when(){return c()!==null},get children(){return[(()=>{var e=w_();return r(t=>F(e,Y(!0),t)),e})(),(()=>{var e=Xg();return T(e,c),r(t=>F(e,{...Y()},t)),e})()]}}),null),T(e,n(h,{get when(){return I(()=>!!d())()&&!q()},get children(){return[(()=>{var e=T_();return r(t=>F(e,Y(!0),t)),e})(),(()=>{var e=E_(),t=e.firstChild;return t.addEventListener(`mouseleave`,e=>{e.currentTarget.style.color=l()?`#3fb950`:`#484f58`}),t.addEventListener(`mouseenter`,e=>{e.currentTarget.style.color=l()?`#56d364`:`#8b949e`}),t.$$click=f,T(t,(()=>{var e=I(()=>!!l());return()=>e()?n(Fr,{size:12}):n(Nr,{size:12})})()),r(n=>{var r={...Y()},i=l()?`Notifications on — click to disable`:`Notifications off — click to enable`,a=l()?`#3fb950`:`#484f58`;return n.e=F(e,r,n.e),i!==n.t&&R(t,`title`,n.t=i),a!==n.a&&B(t,`color`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),e})()]}}),null),r(n=>{var r=$_,i=Y(!0),a={...Y()};return n.e=F(e,r,n.e),n.t=F(t,i,n.t),n.a=F(u,a,n.a),n},{e:void 0,t:void 0,a:void 0}),e})()}function sv(e){let t=()=>e.item.raw,i=()=>typeof t().hits==`number`?t().hits:null,a=()=>typeof t().hitsMax==`number`?t().hitsMax:null,o=()=>t().store,s=()=>{if(typeof t().storeCapacity==`number`)return t().storeCapacity;let e=t().storeCapacityResource;if(e){let t=0;for(let n in e)t+=e[n];return t}return null},c=()=>{let e=o();if(!e)return 0;let t=0;for(let n in e)t+=e[n];return t},l=()=>{let e=s();return!e||e===0?0:Math.min(100,c()/e*100)};return(()=>{var e=Yg();return T(e,n(h,{get when(){return I(()=>i()!==null)()&&a()!==null},get children(){var e=O_(),t=e.firstChild,n=t.nextSibling,o=n.firstChild;return T(n,i,o),T(n,a,null),r(r=>{var i=$_,a=Y(!0),o={...Y()};return r.e=F(e,i,r.e),r.t=F(t,a,r.t),r.a=F(n,o,r.a),r},{e:void 0,t:void 0,a:void 0}),e}}),null),T(e,n(h,{get when(){return s()!==null},get children(){var e=k_(),t=e.firstChild,n=t.firstChild.nextSibling,i=n.firstChild,a=i.nextSibling,o=a.nextSibling.nextSibling;o.nextSibling;var u=t.nextSibling.firstChild;return T(n,()=>Q_(c()),i),T(n,()=>Q_(s()),a),T(n,()=>l().toFixed(1),o),r(e=>B(u,`width`,`${l()}%`)),e}}),null),T(e,n(tv,{get store(){return o()},capacity:null}),null),e})()}function cv(e){let t=()=>e.item.raw,i=()=>{let e=t().decayTime;if(typeof e!=`number`)return null;let n=V();return n===null?e:Math.max(0,e-n)},a=()=>{let e=t().power;if(typeof e==`number`)return e;let n=t().store;return typeof n?.power==`number`?n.power:null},o=()=>typeof t().hits==`number`?t().hits:null,s=()=>typeof t().hitsMax==`number`?t().hitsMax:null;return(()=>{var e=Yg();return T(e,n(h,{get when(){return a()!==null},get children(){return[(()=>{var e=v_();return r(t=>F(e,Y(!0),t)),e})(),(()=>{var e=Xg();return T(e,a),r(t=>F(e,{...Y()},t)),e})()]}}),null),T(e,n(h,{get when(){return o()!==null},get children(){return[(()=>{var e=n_();return r(t=>F(e,Y(!0),t)),e})(),(()=>{var e=A_(),t=e.firstChild;return T(e,o,t),T(e,(()=>{var e=I(()=>s()!==null);return()=>e()?`/ ${s()}`:``})(),null),r(t=>F(e,{...Y()},t)),e})()]}}),null),T(e,n(h,{get when(){return i()!==null},get children(){return[(()=>{var e=j_();return r(t=>F(e,Y(!0),t)),e})(),(()=>{var e=Xg();return T(e,i),r(t=>F(e,{...Y()},t)),e})()]}}),null),r(t=>F(e,$_,t)),e})()}function lv(e){let t=()=>e.item.raw,i=()=>{let e=t().decayTime;if(typeof e!=`number`)return null;let n=V();return n===null?e:Math.max(0,e-n)},a=()=>typeof t().user==`string`?t().user:null,o=()=>{let e=a();return e?er()?.[e]?.username??null:null},s=()=>{let e=a();return e?o()??e:null},c=()=>t().structure,l=()=>typeof c()?.type==`string`?c().type:null,u=()=>typeof c()?.hits==`number`?c().hits:null,d=()=>typeof c()?.hitsMax==`number`?c().hitsMax:null,f=()=>typeof c()?.level==`number`?c().level:null,p=()=>typeof c()?.energy==`number`?c().energy:null,m=()=>typeof c()?.energyCapacity==`number`?c().energyCapacity:null,g=()=>t().store,_=()=>typeof t().storeCapacity==`number`?t().storeCapacity:null;return(()=>{var e=s_(),t=e.firstChild;return T(t,n(h,{get when(){return i()!==null},get children(){return[(()=>{var e=M_();return r(t=>F(e,Y(!0),t)),e})(),(()=>{var e=Xg();return T(e,i),r(t=>F(e,{...Y()},t)),e})()]}}),null),T(t,n(h,{get when(){return s()},get children(){return[(()=>{var e=t_();return r(t=>F(e,Y(!0),t)),e})(),(()=>{var e=Yg();return T(e,n(Ug,{get username(){return o()},get fallback(){return s()}})),r(t=>F(e,Y(),t)),e})()]}}),null),T(e,n(h,{get when(){return l()},get children(){var e=P_(),t=e.firstChild;t.firstChild;var i=t.nextSibling;return T(t,l,null),T(i,n(h,{get when(){return d()!==null},get children(){return[(()=>{var e=n_();return r(t=>F(e,Y(!0),t)),e})(),(()=>{var e=r_(),t=e.firstChild;return T(e,()=>u()??0,t),T(e,d,null),r(t=>F(e,{...Y()},t)),e})()]}}),null),T(i,n(h,{get when(){return f()!==null},get children(){return[(()=>{var e=g_();return r(t=>F(e,Y(!0),t)),e})(),(()=>{var e=Xg();return T(e,f),r(t=>F(e,{...Y()},t)),e})()]}}),null),T(i,n(h,{get when(){return m()!==null},get children(){return[(()=>{var e=N_();return r(t=>F(e,Y(!0),t)),e})(),(()=>{var e=r_(),t=e.firstChild;return T(e,()=>p()??0,t),T(e,m,null),r(t=>F(e,{...Y()},t)),e})()]}}),null),r(e=>F(i,$_,e)),e}}),null),T(e,n(tv,{get store(){return g()},get capacity(){return _()}}),null),r(e=>F(t,$_,e)),e})()}var uv={creep:rv,flag:iv,controller:av,spawn:ov,extension:ov,tower:ov,link:ov,storage:sv,terminal:sv,container:sv,lab:sv,factory:sv,nuker:sv,powerSpawn:sv,powerBank:cv,ruin:lv};function dv(t){let i=()=>G_[t.item.type]??`#c9d1d9`,a=()=>K_[t.item.type]??t.item.type,o=()=>t.item.type===`creep`,s=()=>t.item.type===`flag`,c=()=>{if(!o())return!1;let e=t.item.raw,n=typeof e.user==`string`?e.user:null;return n!==null&&n===H()?._id},l=()=>{if(o()||s()||t.item.type===`controller`)return!1;let e=t.item.raw,n=typeof e.user==`string`?e.user:null;return n===null?fr()?.userId===H()?._id:n===H()?._id},u=()=>uv[t.item.type]||ev,[d,f]=e(!1),p=null,[m,g]=e(!1),_=null,[v,y]=e(!1),b=null,x=e=>{if(e.stopPropagation(),!v()){y(!0),b=setTimeout(()=>y(!1),3e3);return}b&&=(clearTimeout(b),null),y(!1);let n=L();if(!n)return;let r=t.item.id,i=t.item.raw;n.http.game.removeFlag(i.room,i.name,$n()??void 0).then(()=>pf(r)).catch(()=>{})},S=e=>{if(e.stopPropagation(),!m()){g(!0),_=setTimeout(()=>g(!1),3e3);return}_&&=(clearTimeout(_),null),g(!1);let n=L();if(!n)return;let r=t.item.id,i=t.item.raw,a=(typeof i.room==`string`?i.room:null)??ar()??``;if(t.item.type===`constructionSite`)n.http.game.removeConstructionSite(a,[r],$n()??void 0).then(()=>pf(r)).catch(e=>W_(`removeConstructionSite failed:`,e));else{let e=typeof i.user==`string`?i.user:fr()?.userId??``;n.http.game.addObjectIntent(`room`,a,`destroyStructure`,[{id:r,roomName:a,user:e}],$n()).then(()=>pf(r)).catch(e=>W_(`destroyStructure failed:`,e))}},C=e=>{if(e.stopPropagation(),!d()){f(!0),p=setTimeout(()=>f(!1),3e3);return}p&&=(clearTimeout(p),null),f(!1);let n=L();if(!n)return;let r=t.item.id;n.http.game.addObjectIntent(r,ar()??t.item.raw.room??``,`suicide`,{id:r},$n()).then(()=>pf(r)).catch(e=>W_(`suicide failed:`,e))};return(()=>{var e=R_(),f=e.firstChild,p=f.firstChild,g=p.nextSibling,_=g.firstChild.nextSibling,y=_.nextSibling.nextSibling;y.nextSibling;var b=g.nextSibling;return T(f,n(h,{get when(){return I(()=>!o())()&&!s()},get children(){var e=F_();return r(t=>B(e,`background`,i())),e}}),p),T(p,n(h,{get when(){return s()},get fallback(){return I(a)},get children(){return n(pi,{size:12})}}),null),T(p,n(h,{get when(){return I(()=>typeof t.item.raw.name==`string`)()&&t.item.raw.name},children:e=>(()=>{var t=z_();return T(t,()=>e()),t})()}),null),T(g,()=>t.item.raw.x,_),T(g,()=>t.item.raw.y,y),T(f,n(h,{get when(){return I(()=>!!c())()&&!q()},get children(){return[(()=>{var e=I_();return e.addEventListener(`mouseleave`,e=>{d()||(e.currentTarget.style.color=`#8b949e`)}),e.addEventListener(`mouseenter`,e=>{d()||(e.currentTarget.style.color=`#f85149`)}),e.$$click=C,T(e,n(ha,{size:13})),r(t=>{var n=d()?`Click again to confirm suicide`:`Suicide`,r=d()?`#f85149`:`#8b949e`;return n!==t.e&&R(e,`title`,t.e=n),r!==t.t&&B(e,`color`,t.t=r),t},{e:void 0,t:void 0}),e})(),(()=>{var e=L_();return e.addEventListener(`mouseleave`,e=>e.currentTarget.style.color=`#8b949e`),e.addEventListener(`mouseenter`,e=>e.currentTarget.style.color=`#58a6ff`),e.$$click=()=>{tm(t.item.id,t.item.raw.name),Pp(!0)},T(e,n(di,{size:13})),e})()]}}),b),T(f,n(h,{get when(){return I(()=>!!l())()&&!q()},get children(){var e=I_();return e.addEventListener(`mouseleave`,e=>{m()||(e.currentTarget.style.color=`#8b949e`)}),e.addEventListener(`mouseenter`,e=>{m()||(e.currentTarget.style.color=`#f85149`)}),e.$$click=S,T(e,n(ha,{size:13})),r(n=>{var r=m()?`Click again to confirm`:t.item.type===`constructionSite`?`Remove construction site`:`Destroy structure`,i=m()?`#f85149`:`#8b949e`;return r!==n.e&&R(e,`title`,n.e=r),i!==n.t&&B(e,`color`,n.t=i),n},{e:void 0,t:void 0}),e}}),b),T(f,n(h,{get when(){return I(()=>!!s())()&&!q()},get children(){var e=I_();return e.addEventListener(`mouseleave`,e=>{v()||(e.currentTarget.style.color=`#8b949e`)}),e.addEventListener(`mouseenter`,e=>{v()||(e.currentTarget.style.color=`#f85149`)}),e.$$click=x,T(e,n(ha,{size:13})),r(t=>{var n=v()?`Click again to confirm deletion`:`Delete flag`,r=v()?`#f85149`:`#8b949e`;return n!==t.e&&R(e,`title`,t.e=n),r!==t.t&&B(e,`color`,t.t=r),t},{e:void 0,t:void 0}),e}}),b),b.addEventListener(`mouseleave`,e=>e.currentTarget.style.color=`#8b949e`),b.addEventListener(`mouseenter`,e=>e.currentTarget.style.color=`#fff`),b.$$click=()=>pf(t.item.id),T(e,n(me,{get component(){return u()},get item(){return t.item}}),null),T(e,n(Jg,{get item(){return t.item}}),null),T(e,n(h,{get when(){return t.item.id},children:e=>(()=>{var t=B_();return t.$$click=()=>navigator.clipboard?.writeText(e()),T(t,e),r(()=>R(t,`title`,e())),t})()}),null),r(t=>B(e,`border`,`1px solid ${c()&&d()||m()||v()?`#f85149`:`#30363d`}`)),e})()}function fv(){return(()=>{var e=V_();return T(e,n(h,{get when(){return uf().length>0},get fallback(){return H_()},get children(){return n(b,{get each(){return uf()},children:e=>n(dv,{item:e})})}})),e})()}P([`click`,`input`]);var pv=z(`<div style="padding:3px 0;color:#8b949e">Reserved by`),mv=z(`<div style="padding:3px 0;color:#c9d1d9">`),hv=z(`<div style="padding:3px 0;color:#8b949e">Expires in`),gv=z(`<div style="padding:3px 0;color:#c9d1d9;font-variant-numeric:tabular-nums"> ticks`),_v=z(`<div style="padding:3px 0;color:#8b949e">RCL`),vv=z(`<span style=color:#8b949e>(<!>%)`),yv=z(`<div style="padding:3px 0;color:#c9d1d9;font-variant-numeric:tabular-nums">`),bv=z(`<div style="display:grid;grid-template-columns:repeat(3, 1fr);gap:4px;margin-top:8px">`),xv=z(`<div style="padding:8px;border-bottom:1px solid #30363d;flex-shrink:0"><div style="padding:4px 8px;background:#161b22;border-radius:6px;border:1px solid #30363d"><div style=font-size:10px;font-weight:600;color:#8b949e;text-transform:uppercase;letter-spacing:0.04em;margin-bottom:4px> Room</div><div style=font-size:13px;font-weight:600;color:#c9d1d9></div><div style="display:grid;grid-template-columns:auto 1fr;row-gap:1px;margin-top:4px;font-size:11px"><div style="padding:3px 0;color:#8b949e">Shard</div><div style="padding:3px 0;color:#c9d1d9"></div><div style="padding:3px 0;color:#8b949e">Tick</div><div style="padding:3px 0;color:#c9d1d9"></div><div style="padding:3px 0;color:#8b949e">Tick duration</div><div style="padding:3px 0;color:#c9d1d9"></div><div style="padding:3px 0;color:#8b949e">Objects</div><div style="padding:3px 0;color:#c9d1d9"></div><div style="padding:3px 0;color:#8b949e">Owner</div><div style="padding:3px 0;color:#c9d1d9"></div></div><label style=display:flex;align-items:center;justify-content:space-between;font-size:11px;color:#c9d1d9;cursor:pointer;margin-top:6px><span>Creep-Namen</span><input type=checkbox></label><label style=display:flex;align-items:center;justify-content:space-between;font-size:11px;color:#c9d1d9;cursor:pointer;margin-top:4px><span>Room Visuals</span><input type=checkbox>`),Sv=z(`<span>`),Cv=z(`<button type=button style="padding:5px 8px;border-radius:6px;cursor:pointer;display:flex;align-items:center;justify-content:center">`),wv=[{mode:`view`,label:`View`,icon:()=>n(di,{size:14})},{mode:`flag`,label:`Flag`,icon:()=>n(pi,{size:14})},{mode:`build`,label:`Build`,icon:()=>n(yi,{size:14})}];function Tv(e){return(()=>{var t=xv(),i=t.firstChild.firstChild.nextSibling,a=i.nextSibling,o=a.firstChild.nextSibling,s=o.nextSibling.nextSibling,c=s.nextSibling.nextSibling,l=c.nextSibling.nextSibling,u=l.nextSibling.nextSibling,d=a.nextSibling,f=d.firstChild.nextSibling,p=d.nextSibling.firstChild.nextSibling;return T(i,()=>e.room),T(o,()=>e.shard??`—`),T(s,()=>V()??`—`),T(c,(()=>{var e=I(()=>!!Re());return()=>e()?`${Re()}ms`:`—`})()),T(l,()=>lr()??`—`),T(u,n(Ug,{get username(){return fr()?.username},fallback:`—`,color:`#c9d1d9`})),T(a,n(h,{get when(){return I(()=>!fr())()&&dr()},get children(){return[pv(),(()=>{var e=mv();return T(e,n(Ug,{get username(){return er()?.[dr().user]?.username},get fallback(){return dr().user},color:`#c9d1d9`})),e})(),hv(),(()=>{var e=gv(),t=e.firstChild;return T(e,(()=>{var e=I(()=>V()!==null);return()=>e()?Math.max(0,dr().endTime-V()):`—`})(),t),e})()]}}),null),T(a,n(h,{get when(){return I(()=>pr()!==null)()&&pr()>0},get children(){return[_v(),(()=>{var e=yv();return T(e,n(h,{get when(){return I(()=>pr()<8)()&&cr()!==null},get fallback(){return(()=>{var e=Sv();return T(e,pr),e})()},get children(){return[I(()=>pr()),` → `,I(()=>pr()+1),`\xA0`,(()=>{var e=vv(),t=e.firstChild.nextSibling;return t.nextSibling,T(e,()=>(cr()/(Ms[pr()]??1)*100).toFixed(1),t),e})()]}})),e})()]}}),null),f.addEventListener(`change`,e=>Ht(e.currentTarget.checked)),p.addEventListener(`change`,e=>Rt(e.currentTarget.checked)),T(t,n(h,{get when(){return!be()},get children(){var e=bv();return T(e,n(b,{each:wv,children:e=>{let t=()=>!q()&&ep()===e.mode;return(()=>{var n=Cv();return n.$$click=()=>{q()&&Pf(),tp(e.mode)},T(n,()=>e.icon()),r(r=>{var i=e.label,a=`1px solid ${t()?`#58a6ff`:`#30363d`}`,o=t()?`#1f6feb33`:`#161b22`,s=t()?`#c9d1d9`:`#8b949e`;return i!==r.e&&R(n,`title`,r.e=i),a!==r.t&&B(n,`border`,r.t=a),o!==r.a&&B(n,`background`,r.a=o),s!==r.o&&B(n,`color`,r.o=s),r},{e:void 0,t:void 0,a:void 0,o:void 0}),n})()}})),e}}),null),r(()=>f.checked=It()),r(()=>p.checked=$t()),t})()}P([`click`]);var Ev=z(`<div style=margin-bottom:8px><select style="width:100%;padding:5px 8px;background:#161b22;border:1px solid #30363d;border-radius:6px;color:#c9d1d9;font-size:12px;cursor:pointer">`),Dv=z(`<div style="padding:8px;border-bottom:1px solid #30363d;flex-shrink:0"><div style="padding:4px 8px;background:#161b22;border-radius:6px;border:1px solid #30363d"><div style=font-size:10px;font-weight:600;color:#8b949e;text-transform:uppercase;letter-spacing:0.04em;margin-bottom:4px>Map</div><div style="display:grid;grid-template-columns:auto 1fr;row-gap:1px;font-size:11px;margin-bottom:8px"><div style="padding:3px 0;color:#8b949e">Zoom</div><div style="padding:3px 0;color:#c9d1d9"></div><div style="padding:3px 0;color:#8b949e">Live</div><div style="padding:3px 0;color:#c9d1d9"></div></div><label style=display:flex;align-items:center;justify-content:space-between;font-size:11px><span>Show room names</span><input type=checkbox></label><label style=display:flex;align-items:center;justify-content:space-between;font-size:11px;color:#c9d1d9;cursor:pointer;margin-top:4px><span>Show unclaimable rooms</span><input type=checkbox></label><label style=display:flex;align-items:center;justify-content:space-between;font-size:11px;color:#c9d1d9;cursor:pointer;margin-top:4px><span>Show map visuals</span><input type=checkbox></label><label style=display:flex;align-items:center;justify-content:space-between;font-size:11px;color:#c9d1d9;cursor:pointer;margin-top:4px><span>Room decorations</span><input type=checkbox></label></div><div style="display:grid;grid-template-columns:repeat(3, 1fr);gap:4px;margin-top:8px">`),Ov=z(`<option>`),kv=z(`<button type=button style="padding:5px 8px;border-radius:6px;cursor:pointer;font-size:11px;font-weight:600">`),Av=[{mode:`owner`,label:`Owner`},{mode:`mineral`,label:`Mineral`},{mode:`none`,label:`None`}];function jv(e){let t=()=>(e.zoom??1)>=Mn,i=()=>Se()?.serverData?.shards?.filter(e=>e!==null)??[],a=()=>Oe()===!1&&i().length>1;return(()=>{var o=Dv(),s=o.firstChild,c=s.firstChild.nextSibling,l=c.firstChild.nextSibling,u=l.nextSibling.nextSibling,d=c.nextSibling,f=d.firstChild.nextSibling,p=d.nextSibling,m=p.firstChild.nextSibling,g=p.nextSibling,_=g.firstChild.nextSibling,v=g.nextSibling.firstChild.nextSibling,y=s.nextSibling;return T(o,n(h,{get when(){return a()},get children(){var t=Ev(),a=t.firstChild;return a.addEventListener(`change`,t=>e.onShardChange?.(t.currentTarget.value)),T(a,n(b,{get each(){return i()},children:e=>(()=>{var t=Ov();return t.value=e,T(t,e),t})()})),r(()=>a.value=e.shard??``),t}}),s),T(l,()=>e.zoom?.toFixed(2)??`—`),T(u,()=>e.subsActive?`Yes`:`No`),f.addEventListener(`change`,e=>En(e.currentTarget.checked)),m.addEventListener(`change`,e=>Bt(e.currentTarget.checked)),_.addEventListener(`change`,e=>yt(e.currentTarget.checked)),v.addEventListener(`change`,e=>wn(e.currentTarget.checked)),T(y,n(b,{each:Av,children:e=>{let t=()=>In()===e.mode;return(()=>{var n=kv();return n.$$click=()=>An(e.mode),T(n,()=>e.label),r(e=>{var r=`1px solid ${t()?`#58a6ff`:`#30363d`}`,i=t()?`#1f6feb33`:`#161b22`,a=t()?`#c9d1d9`:`#8b949e`;return r!==e.e&&B(n,`border`,e.e=r),i!==e.t&&B(n,`background`,e.t=i),a!==e.a&&B(n,`color`,e.a=a),e},{e:void 0,t:void 0,a:void 0}),n})()}})),r(e=>{var n=t()?`#c9d1d9`:`#484f58`,r=t()?`pointer`:`default`,i=!t();return n!==e.e&&B(d,`color`,e.e=n),r!==e.t&&B(d,`cursor`,e.t=r),i!==e.a&&(f.disabled=e.a=i),e},{e:void 0,t:void 0,a:void 0}),r(()=>f.checked=qt()),r(()=>m.checked=jt()),r(()=>_.checked=Zn()),r(()=>v.checked=xt()),o})()}P([`click`]);var Mv=z(`<img width=12 height=12 alt style="border-radius:2px;flex:0 0 auto;display:block">`),Nv=z(`<div style="padding:3px 8px;color:#484f58">None`),Pv=z(`<div style="padding:3px 8px;color:#c9d1d9;display:flex;align-items:center;gap:4px;min-width:0">`),Fv=z(`<div style="margin:8px 8px 0;border-radius:6px;overflow:hidden"><div style="padding:4px 8px;background:#161b22;border-bottom:1px solid #21262d;font-size:10px;font-weight:600;color:#8b949e;text-transform:uppercase;letter-spacing:0.04em">`),Iv=z(`<div style="padding:6px 8px;font-size:11px;color:#484f58;font-style:italic">None`),Lv=z(`<div style="padding:3px 8px;color:#8b949e">Reservation`),Rv=z(`<div style="padding:3px 8px;color:#8b949e">Mineral`),zv=z(`<div style="padding:3px 8px;color:#79c0ff">`),Bv=z(`<div style="padding:3px 8px;color:#8b949e">Density`),Vv=z(`<div style="padding:3px 8px;color:#c9d1d9">`),Hv=z(`<div style=font-size:11px><div style="display:flex;align-items:center;gap:6px;padding:5px 8px;font-weight:600;color:#c9d1d9;font-size:12px;border-bottom:1px solid #21262d"><span style=overflow:hidden;text-overflow:ellipsis;white-space:nowrap></span></div><div style="display:grid;grid-template-columns:auto 1fr;align-items:center;row-gap:1px;column-gap:0">`),Uv=z(`<span title="Controller level"style="margin-left:auto;padding:0 7px;line-height:17px;background:#21262d;border-radius:4px;color:#c9d1d9;font-size:11px;font-variant-numeric:tabular-nums">`),Wv=z(`<div style="padding:3px 8px;color:#8b949e">Owner`),Gv=z(`<div style=display:flex;align-items:center;gap:4px;align-self:flex-end;color:#8b949e><span>—`),Kv=z(`<div style="padding:5px 8px;border-top:1px solid #21262d;display:flex;flex-direction:column;gap:3px"><div style=color:#8b949e>Sign</div><div style=color:#c9d1d9;font-style:italic>“<!>”</div><div style=align-self:flex-end;color:#484f58;font-size:10px>`),qv=[`Low`,`Medium`,`High`,`Ultra`];function Jv(e){return qv[e-1]??String(e)}function Yv(e){let t=new Date(e),n=new Date,r=t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate(),i=t.toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`,second:`2-digit`});return r?`Today at ${i}`:`${t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}, ${i}`}function Xv(e){let t=i(()=>`data:image/svg+xml,${encodeURIComponent(gt(e.badge))}`);return(()=>{var e=Mv();return r(()=>R(e,`src`,t())),e})()}function Zv(e){return n(h,{get when(){return e.name},get fallback(){return Nv()},children:t=>(()=>{var r=Pv();return T(r,n(h,{get when(){return e.badge},children:e=>n(Xv,{get badge(){return e()}})}),null),T(r,n(Ug,{get username(){return t()},color:`#c9d1d9`,style:{overflow:`hidden`,"text-overflow":`ellipsis`,"white-space":`nowrap`}}),null),r})()})}function Qv(e){return(()=>{var t=Fv(),i=t.firstChild;return T(i,()=>e.label),T(t,n(h,{get when(){return e.info},get fallback(){return Iv()},children:e=>(()=>{var t=Hv(),r=t.firstChild,i=r.firstChild,a=r.nextSibling;return T(i,()=>e().room),T(r,n(h,{get when(){return e().level},children:e=>(()=>{var t=Uv();return T(t,e),t})()}),null),T(a,n(h,{get when(){return e().reservation},get fallback(){return[Wv(),n(Zv,{get name(){return e().owner},get badge(){return e().badge}})]},get children(){return[Lv(),n(Zv,{get name(){return e().reservation},get badge(){return e().badge}})]}}),null),T(a,n(h,{get when(){return e().mineral},get children(){return[Rv(),(()=>{var t=zv();return T(t,()=>e().mineral),t})(),Bv(),(()=>{var t=Vv();return T(t,()=>Jv(e().density??0)),t})()]}}),null),T(t,n(h,{get when(){return e().sign},children:e=>(()=>{var t=Kv(),r=t.firstChild.nextSibling,i=r.firstChild.nextSibling;i.nextSibling;var a=r.nextSibling;return T(r,()=>e().text,i),T(t,n(h,{get when(){return e().username||e().badge},get children(){var t=Gv();return t.firstChild,T(t,n(h,{get when(){return e().badge},children:e=>n(Xv,{get badge(){return e()}})}),null),T(t,n(Ug,{get username(){return e().username},color:`#8b949e`}),null),t}}),a),T(a,()=>Yv(e().datetime)),t})()}),null),t})()}),null),r(n=>{var r=`1px solid ${e.dim?`#21262d`:`#30363d`}`,i=e.dim?.6:1;return r!==n.e&&B(t,`border`,n.e=r),i!==n.t&&B(t,`opacity`,n.t=i),n},{e:void 0,t:void 0}),t})()}var $v=z(`<span style=color:#8b949e;font-size:11px>Checking…`),ey=z(`<div style=margin-top:8px><div style="padding:6px 8px;font-size:11px;font-weight:600;color:#c9d1d9;margin-bottom:6px">Your flags`),ty=z(`<div style=flex:1;overflow:auto;min-height:0;padding:8px><div style="border-radius:6px;border:1px solid #30363d;overflow:hidden;background:#0d1117"><div style="padding:6px 8px;background:#161b22;border-bottom:1px solid #21262d;font-size:11px;font-weight:600;color:#c9d1d9">Create flag</div><div style=padding:8px;display:flex;flex-direction:column;gap:8px><label>Name<input placeholder="Flag name"style="background:#010409;color:#c9d1d9;border-radius:4px;padding:5px 6px;font-size:12px;outline:none"></label><label>Primary color</label><label>Secondary color</label><div style=color:#484f58;font-size:11px;line-height:1.4>`),ny=z(`<span style=color:#f85149;font-size:11px>`),ry=z(`<div style=margin-top:8px;color:#484f58;font-style:italic;font-size:12px>No flags.`),iy=z(`<div style="border-radius:6px;border:1px solid #30363d;margin-bottom:6px;overflow:hidden"><div style="display:flex;align-items:center;gap:7px;padding:6px 8px;background:#161b22;border-bottom:1px solid #21262d"><div style=width:8px;height:8px;border-radius:50%;flex-shrink:0></div><span style=font-size:11px;font-weight:600;color:#c9d1d9;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap></span><span style=font-size:10px;color:#8b949e;flex-shrink:0></span><span style=font-size:10px;color:#484f58;flex-shrink:0;margin-left:4px>(<!>,<!>)`),{error:ay}=ce(`flag`),oy={};for(let[e,t]of Object.entries(Qf))oy[t]=e;function sy(){let t=e=>{rp({...np(),...e})},[i,a]=e(null),[o,s]=e(!1),c=null,l=e=>{e.http.game.genUniqueFlagName().then(e=>{t({name:e.name}),a(null)}).catch(e=>{ay(`gen unique name failed:`,e)})};p(()=>{if(ep()!==`flag`)return;let e=L();if(!e)return;let t=w(()=>np().name.trim());if(!t){l(e);return}e.http.game.checkUniqueFlagName(t).then(()=>{a(null)}).catch(()=>{l(e)})});let u=e=>{t({name:e}),a(null),c&&clearTimeout(c);let n=e.trim();if(!n){s(!1);return}s(!0),c=setTimeout(()=>{let e=L();if(!e){s(!1);return}e.http.game.checkUniqueFlagName(n).then(()=>{a(null)}).catch(e=>{a(e.message)}).finally(()=>{s(!1)})},300)},d=()=>Qf[np().color]??1,f=()=>Qf[np().secondaryColor]??1,m=e=>{t({color:oy[e]??`COLOR_WHITE`})},g=e=>{t({secondaryColor:oy[e]??`COLOR_WHITE`})},_=()=>{let e=ye(),t=[];for(let[n,r]of Object.entries(e))r&&typeof r==`object`&&`room`in r&&`x`in r&&`y`in r&&t.push([n,r]);return t},v=e=>e===void 0||e<0||e>=yn.length?`#8b949e`:`#${yn[e].toString(16).padStart(6,`0`)}`,y={display:`flex`,"flex-direction":`column`,gap:`5px`,"font-size":`11px`,color:`#8b949e`};return(()=>{var e=ty(),t=e.firstChild.firstChild.nextSibling.firstChild,a=t.firstChild.nextSibling,s=t.nextSibling;s.firstChild;var c=s.nextSibling;c.firstChild;var l=c.nextSibling;return a.$$input=e=>u(e.currentTarget.value),T(t,n(h,{get when(){return i()},children:e=>(()=>{var t=ny();return T(t,e),t})()}),null),T(t,n(h,{get when(){return o()},get children(){return $v()}}),null),T(s,n(Nh,{get value(){return d()},onChange:m}),null),T(c,n(Nh,{get value(){return f()},onChange:g}),null),T(l,(()=>{var e=I(()=>!!ip());return()=>e()?`Marked at x=${ip().tx}, y=${ip().ty}. Click again to create the flag, or click elsewhere to move the mark.`:`Click a position in the room to mark it.`})()),T(e,n(h,{get when(){return _().length>0},get fallback(){return ry()},get children(){var e=ey();return e.firstChild,T(e,n(b,{get each(){return _()},children:([e,t])=>(()=>{var n=iy(),i=n.firstChild.firstChild,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling,c=s.firstChild.nextSibling,l=c.nextSibling.nextSibling;return l.nextSibling,T(a,e),T(o,()=>t.room),T(s,()=>t.x,c),T(s,()=>t.y,l),r(e=>B(i,`background`,v(t.color))),n})()}),null),e}}),null),r(e=>{var n=y,r=`1px solid ${i()?`#f85149`:`#30363d`}`,o=y,l=y;return e.e=F(t,n,e.e),r!==e.t&&B(a,`border`,e.t=r),e.a=F(s,o,e.a),e.o=F(c,l,e.o),e},{e:void 0,t:void 0,a:void 0,o:void 0}),r(()=>a.value=np().name),e})()}P([`input`]);var cy=z(`<span style=color:#8b949e>…`),ly=z(`<span style=color:#3fb950>✓`),uy=z(`<span style=color:#f85149>✗`),dy=z(`<div style=font-size:10px;color:#f85149>`),fy=z(`<div style="margin-top:8px;border-radius:6px;border:1px solid #30363d;overflow:hidden;background:#0d1117"><div style="padding:6px 8px;background:#161b22;border-bottom:1px solid #21262d;font-size:11px;font-weight:600;color:#c9d1d9">Spawn name</div><div style=padding:8px;display:flex;flex-direction:column;gap:6px><div style=display:flex;gap:6px;align-items:center><input type=text style="flex:1;background:#010409;color:#c9d1d9;border-radius:4px;padding:5px 7px;font-size:12px;outline:none;transition:border-color 150ms ease"><span style=font-size:14px;flex-shrink:0;width:14px;text-align:center>`),py=z(`<div style=flex:1;overflow:auto;min-height:0;padding:8px><div style="border-radius:6px;border:1px solid #30363d;overflow:hidden;background:#0d1117;margin-bottom:8px"><div style="padding:6px 8px;background:#161b22;border-bottom:1px solid #21262d;font-size:11px;font-weight:600;color:#c9d1d9">Controller Level </div><div style=padding:8px;font-size:11px;color:#8b949e></div></div><div style="border-radius:6px;border:1px solid #30363d;overflow:hidden;background:#0d1117"><div style="padding:6px 8px;background:#161b22;border-bottom:1px solid #21262d;font-size:11px;font-weight:600;color:#c9d1d9">Structures</div></div><div style="margin-top:8px;padding:0 4px"><div style=color:#484f58;font-style:italic;font-size:12px>`),my=z(`<div style="padding:6px 8px;display:flex;justify-content:space-between;align-items:center;border-bottom:1px solid #21262d;font-size:11px;color:#c9d1d9"><span style=text-transform:capitalize></span><span style=color:#8b949e>`);function hy(t){let i=Object.keys($f),[o,s]=e(`idle`),[c,l]=e(``),d=null,f=(e,t)=>{let n=$f[e];return n?O()===`empty`&&e===`spawn`?Math.max(n[t]??0,1):n[t]??0:0},m=(e,t)=>{let n=f(e,t);if(n===2500)return 1/0;let r=hr()[e]??0;return Math.max(0,n-r)},g=()=>cp().structureType===`spawn`;p(u(()=>cp().structureType,(e,n)=>{if(e!==`spawn`||e===n)return;let r=L();if(!r)return;s(`loading`),l(``);let i=!1;a(()=>{i=!0}),r.http.game.genUniqueObjectName(`spawn`,t.shard).then(e=>{i||(lp({structureType:`spawn`,structureName:e.name}),s(`valid`))}).catch(()=>{i||(lp({structureType:`spawn`,structureName:`Spawn1`}),s(`idle`))})}));let _=e=>{if(d&&clearTimeout(d),!e.trim()){s(`invalid`),l(`Name cannot be empty`);return}s(`loading`),l(``),d=setTimeout(()=>{let n=L();n&&n.http.game.checkUniqueObjectName(`spawn`,e.trim(),t.shard).then(e=>{e.error?(s(`invalid`),l(e.error)):(s(`valid`),l(``))}).catch(()=>{s(`invalid`),l(`Could not validate name`)})},400)},v=e=>{lp({structureType:`spawn`,structureName:e}),_(e)},y=e=>{lp({structureType:e,structureName:``}),s(`idle`),l(``)},x=()=>{switch(o()){case`loading`:return cy();case`valid`:return ly();case`invalid`:return uy();default:return null}};return(()=>{var e=py(),t=e.firstChild,a=t.firstChild;a.firstChild;var s=a.nextSibling,l=t.nextSibling;l.firstChild;var u=l.nextSibling,d=u.firstChild;return T(a,()=>pr()??`?`,null),T(s,()=>{let e=O();return e===`empty`?`World is empty — place a spawn to claim this room.`:e===`lost`?`You lost all your spawns — respawn to continue.`:pr()==null?`No controller — roads and containers only.`:`RCL ${pr()} — Select a structure type and click a tile to build.`}),T(l,n(b,{each:i,children:e=>{let t=()=>pr()??0,i=()=>f(e,t()),a=()=>hr()[e]??0,o=()=>cp().structureType===e,s=()=>i()===2500,c=()=>!s()&&m(e,t())<=0;return n(h,{get when(){return i()>0},get children(){var t=my(),n=t.firstChild,l=n.nextSibling;return t.$$click=()=>!c()&&y(e),T(n,()=>e.replace(/([A-Z])/g,` $1`).trim(),null),T(n,()=>o()&&` ✓`,null),T(l,(()=>{var e=I(()=>!!s());return()=>e()?`${a()}/∞`:`${a()}/${i()}`})(),null),T(l,()=>c()&&` (Max)`,null),r(e=>{var n=o()?`#1f3158`:`transparent`,r=c()?`default`:`pointer`,i=c()?.5:1;return n!==e.e&&B(t,`background`,e.e=n),r!==e.t&&B(t,`cursor`,e.t=r),i!==e.a&&B(t,`opacity`,e.a=i),e},{e:void 0,t:void 0,a:void 0}),t}})}}),null),T(e,n(h,{get when(){return g()},get children(){var e=fy(),t=e.firstChild.nextSibling,i=t.firstChild.firstChild,a=i.nextSibling;return i.$$input=e=>v(e.currentTarget.value),T(a,x),T(t,n(h,{get when(){return I(()=>o()===`invalid`)()&&c()},get children(){var e=dy();return T(e,c),e}}),null),r(e=>B(i,`border`,`1px solid ${o()===`invalid`?`#f85149`:o()===`valid`?`#238636`:`#30363d`}`)),r(()=>i.value=cp().structureName??``),e}}),u),T(d,()=>cp().structureType?`Click a tile in the room to build.`:`Select a structure type, then click a tile.`),e})()}P([`input`,`click`]);var gy=z(`<div style="padding:8px;border-bottom:1px solid #30363d;flex-shrink:0"><div style=display:flex;flex-direction:column;gap:6px><div style=font-size:11px><div></div><div style=font-size:10px;color:#484f58;margin-top:2px>~</div></div><div style=display:flex;gap:3px><button type=button style="flex:1.5;padding:4px;border-radius:4px;border:1px solid #30363d;font-size:11px"></button></div><div style=display:flex;align-items:center;gap:6px><span style=font-size:10px;color:#8b949e;white-space:nowrap>Speed</span><select style="flex:1;background:#161b22;color:#8b949e;border:1px solid #30363d;border-radius:4px;padding:3px 6px;font-size:11px;cursor:pointer">`),_y=z(`<button type=button>`),vy=z(`<option>/s`),yy=[.5,1,2,5,10,20],by=[{delta:-100,label:`-100`},{delta:-10,label:`-10`}],xy=[{delta:10,label:`+10`},{delta:100,label:`+100`}];function Sy(e){return{flex:`1`,padding:`4px`,"border-radius":`4px`,border:`1px solid #30363d`,background:`#161b22`,color:e?`#484f58`:`#8b949e`,cursor:e?`not-allowed`:`pointer`,"font-size":`11px`}}function Cy(){let e=()=>{let e=xf(),t=_f(),n=Re()??3e3,r=(e-t)*n;return new Date(Date.now()-r).toLocaleString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})};return(()=>{var t=gy(),i=t.firstChild.firstChild,a=i.firstChild,o=a.nextSibling;o.firstChild;var s=i.nextSibling,c=s.firstChild,l=s.nextSibling.firstChild.nextSibling;return T(a,(()=>{var e=I(()=>!!Df());return()=>e()?`Loading…`:`Tick ${_f()}`})()),T(o,e,null),T(s,n(b,{each:by,children:e=>(()=>{var t=_y();return t.$$click=()=>If(e.delta),T(t,()=>e.label),r(e=>{var n=Df(),r=Sy(Df());return n!==e.e&&(t.disabled=e.e=n),e.t=F(t,r,e.t),e},{e:void 0,t:void 0}),t})()}),c),ge(c,`click`,Lf,!0),T(c,()=>Cf()?`⏸`:`▶`),T(s,n(b,{each:xy,children:e=>(()=>{var t=_y();return t.$$click=()=>If(e.delta),T(t,()=>e.label),r(e=>{var n=Df(),r=Sy(Df());return n!==e.e&&(t.disabled=e.e=n),e.t=F(t,r,e.t),e},{e:void 0,t:void 0}),t})()}),null),l.addEventListener(`change`,e=>zf(parseFloat(e.currentTarget.value))),T(l,n(b,{each:yy,children:e=>(()=>{var t=vy(),n=t.firstChild;return t.value=e,T(t,e,n),t})()})),r(e=>{var t=Df()?`#f0883e`:`#c9d1d9`,n=Df(),r=Cf()?`#1a3a2a`:`#161b22`,i=Cf()?`#3fb950`:`#8b949e`,o=Df()?`not-allowed`:`pointer`;return t!==e.e&&B(a,`color`,e.e=t),n!==e.t&&(c.disabled=e.t=n),r!==e.a&&B(c,`background`,e.a=r),i!==e.o&&B(c,`color`,e.o=i),o!==e.i&&B(c,`cursor`,e.i=o),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),r(()=>l.value=Tf()),t})()}P([`click`]);var wy=z(`<div style=font-size:11px;color:#f85149;margin-bottom:4px>`),Ty=z(`<div style="border-top:1px solid #30363d;padding:8px 10px;flex-shrink:0"><div style=display:flex;align-items:center;justify-content:space-between;font-size:10px;font-weight:700;color:#8b949e;text-transform:uppercase;letter-spacing:0.06em;margin-bottom:6px><span>Custom UI</span><button title="Reload from segment"style=background:transparent;border:none;color:#8b949e;padding:2px;display:flex;align-items:center></button></div><div style=display:flex;flex-direction:column;gap:4px>`),Ey=z(`<div style="font-size:10px;font-weight:700;color:#8b949e;text-transform:uppercase;letter-spacing:0.06em;border-bottom:1px solid #21262d;padding-bottom:2px">`),Dy=z(`<div style="display:flex;justify-content:space-between;gap:8px;font-size:12px;padding:1px 0"><span style=color:#8b949e;flex-shrink:0></span><span style="color:#c9d1d9;font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">`),Oy=z(`<div style=display:flex;gap:4px><select style="flex:1;min-width:0;background:#161b22;color:#c9d1d9;border:1px solid #30363d;border-radius:4px;padding:4px 6px;font-size:12px"></select><button style=flex-shrink:0>`),ky=z(`<button style=text-align:left>`),Ay=z(`<option>`),jy={room:`a selected room`,selection:`selected objects`,tile:`a marked tile`};function My(e){if(e===void 0)return`—`;let t=typeof e==`object`&&e?JSON.stringify(e):String(e);return t.length>40?`${t.slice(0,39)}…`:t}function Ny(t){let[i,o]=e(null),[s,c]=nf({}),[l,u]=nf({}),[d,f]=nf({}),m;a(()=>window.clearTimeout(m));let g=()=>{let e=xm();return e?t.mode===`map`?e.map:e.room:[]},_=()=>{if(t.mode===`room`)return Dm();let e=t.selectedRoomInfo;if(!e)return null;let n=H();return e.owner?e.owner===n?.username?`own`:`foreign`:e.reservation?e.reservation===n?.username?`reserved`:`foreign`:`empty`},v=e=>{let n=e.showIf?.selType;if(n!==void 0&&!(t.mode===`room`&&uf().some(e=>e.type===n)))return!1;let r=e.showIf?.room;if(r!==void 0){let e=_();if(e===null||!r.includes(e))return!1}return!0},y=()=>{let e=[];return g().forEach((n,r)=>{if(!v(n))return;let i=`${t.mode}:${r}`;if(n.type===`header`&&n.items&&n.items.length>0){let t=n.items.map((e,t)=>({el:e,child:!0,key:`${i}.${t}`})).filter(e=>v(e.el));if(t.length===0)return;e.push({el:n,child:!1,key:i},...t);return}e.push({el:n,child:!1,key:i})}),e};p(()=>{let e=L(),n=[...new Set(g().flatMap(e=>[e,...e.items??[]]).filter(e=>e.type===`status`).map(e=>e.path))],r=t.shard;if(!e||n.length===0)return;let i=n.map(t=>e.stores.user.subscribeMemory(t,r)),o=e.stores.user.on(`user:memory`,e=>{u(e.path,e.value)});a(()=>{for(let e of i)e.dispose();o.dispose()})});let x=e=>{switch(e){case`room`:return t.mode===`map`?!!t.selectedRoomInfo:!!t.room;case`selection`:return t.mode===`room`&&uf().length>0;case`tile`:return t.mode===`room`&&ip()!==null}},w=e=>(e.needs??[]).filter(e=>!x(e)),E=e=>{let t=d[e];return!!t&&Rm().has(t)},D=()=>{if(t.mode===`map`)return{view:`map`,shard:t.shard,room:t.selectedRoomInfo?.room};let e=uf(),n=ip();return{view:`room`,shard:t.shard,room:t.room,selection:e.length>0?e.map(e=>({id:e.id,type:e.type,name:e.raw.name})):void 0,tile:n?{x:n.tx,y:n.ty}:void 0}},O=(e,t,n)=>{if(e.confirm&&i()!==t){o(t),window.clearTimeout(m),m=window.setTimeout(()=>o(null),3e3);return}window.clearTimeout(m),o(null);let r=qm(e,D(),n);r&&f(t,r)},k=(e,t)=>({padding:`5px 10px`,"border-radius":`4px`,border:`1px solid ${t?`#da3633`:`#30363d`}`,background:t?`#3d1a1a`:`#21262d`,color:e?`#484f58`:t?`#f85149`:`#c9d1d9`,"font-size":`12px`,cursor:e?`default`:`pointer`});return n(h,{get when(){return I(()=>!be()&&_m()!==null)()&&(y().length>0||Cm())},get children(){var e=Ty(),t=e.firstChild,a=t.firstChild.nextSibling,o=t.nextSibling;return a.$$click=()=>void Im(),T(a,n(Yi,{size:12})),T(e,n(h,{get when(){return Cm()},get children(){var e=wy();return T(e,Cm),e}}),o),T(o,n(b,{get each(){return y()},children:(e,t)=>{let a=e.el,o=()=>w(a),u=()=>E(e.key),d=()=>o().length>0||u(),f=()=>i()===e.key,p=()=>o().length>0?`Requires ${o().map(e=>jy[e]).join(` and `)}`:a.cmd,m=e.child?{"margin-left":`10px`}:{},h=e=>u()?`${e} …`:e;return n(S,{get children(){return[n(C,{get when(){return a.type===`header`},get children(){var e=Ey();return T(e,()=>a.label),r(n=>B(e,`margin-top`,t()===0?`0`:`6px`)),e}}),n(C,{get when(){return a.type===`status`},get children(){var e=Dy(),t=e.firstChild,n=t.nextSibling;return T(t,()=>a.label),T(n,()=>My(l[a.path])),r(t=>{var r={...m},i=`Memory.${a.path}`;return t.e=F(e,r,t.e),i!==t.t&&R(n,`title`,t.t=i),t},{e:void 0,t:void 0}),e}}),n(C,{get when(){return a.type===`select`},get children(){var t=Oy(),i=t.firstChild,o=i.nextSibling;return i.addEventListener(`change`,t=>c(e.key,t.currentTarget.value)),T(i,n(b,{get each(){return a.options},children:e=>(()=>{var t=Ay();return t.value=e,T(t,e),t})()})),o.$$click=()=>O(a,e.key,s[e.key]??a.options[0]),T(o,(()=>{var e=I(()=>!!f());return()=>e()?`confirm?`:h(a.label)})()),r(e=>{var n={...m},r=a.label,s=d(),c=p(),l={...k(d(),f())};return e.e=F(t,n,e.e),r!==e.t&&R(i,`title`,e.t=r),s!==e.a&&(o.disabled=e.a=s),c!==e.o&&R(o,`title`,e.o=c),e.i=F(o,l,e.i),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),r(()=>i.value=s[e.key]??a.options[0]),t}}),n(C,{get when(){return a.type===`button`},get children(){var t=ky();return t.$$click=()=>O(a,e.key),T(t,(()=>{var e=I(()=>!!f());return()=>e()?`${a.label} — confirm?`:h(a.label)})()),r(e=>{var n=d(),r=p(),i={...k(d(),f()),...m};return n!==e.e&&(t.disabled=e.e=n),r!==e.t&&R(t,`title`,e.t=r),e.a=F(t,i,e.a),e},{e:void 0,t:void 0,a:void 0}),t}})]}})}})),r(e=>{var t=Tm(),n=Tm()?`default`:`pointer`,r=Tm()?.5:1;return t!==e.e&&(a.disabled=e.e=t),n!==e.t&&B(a,`cursor`,e.t=n),r!==e.a&&B(a,`opacity`,e.a=r),e},{e:void 0,t:void 0,a:void 0}),e}})}P([`click`]);var Py=z(`<div style=padding-bottom:8px;overflow:auto;min-height:0>`),Fy=z(`<div style=display:flex;flex-direction:row;height:100%;background:#0d1117><div style="width:32px;height:100%;display:flex;flex-direction:column;align-items:center;border-right:1px solid #30363d;padding:8px 0;cursor:pointer"></div><div style=flex:1;display:flex;flex-direction:column;overflow:hidden><div style="padding:6px 10px;border-bottom:1px solid #30363d;font-size:12px;font-weight:600;color:#8b949e;display:flex;justify-content:space-between;align-items:center"><span>Properties`),Iy=z(`<button style=background:transparent;border:none;color:#8b949e;font-size:14px;cursor:pointer;padding:4px>`),Ly=z(`<button style=background:transparent;border:none;color:#8b949e;font-size:11px;cursor:pointer>Collapse`);function Ry(e){return n(h,{get when(){return ep()===`flag`},get fallback(){return n(h,{get when(){return ep()===`build`},get fallback(){return n(fv,{})},get children(){return n(hy,{get shard(){return e.shard}})}})},get children(){return n(sy,{})}})}function zy(e){let t=()=>{e.onToggle?.()},r=t=>{t.stopPropagation(),e.onToggle?.()};return(()=>{var i=Fy(),a=i.firstChild,o=a.nextSibling,s=o.firstChild;return s.firstChild,a.$$click=t,T(a,(()=>{var t=I(()=>!!e.onToggle);return()=>t()&&(()=>{var t=Iy();return t.$$click=r,T(t,()=>e.isCollapsed?`▶`:`◀`),t})()})()),T(s,(()=>{var t=I(()=>!!e.onToggle);return()=>t()&&(()=>{var e=Ly();return e.$$click=r,e})()})(),null),T(o,n(h,{get when(){return e.mapMode},get fallback(){return n(Tv,{get room(){return e.room??`—`},get shard(){return e.shard??null}})},get children(){return n(jv,{get zoom(){return e.mapZoom},get subsActive(){return e.mapSubsActive},get shard(){return e.shard},get onShardChange(){return e.onShardChange}})}}),null),T(o,n(h,{get when(){return I(()=>!e.mapMode)()&&q()},get children(){return n(Cy,{})}}),null),T(o,n(h,{get when(){return e.mapMode},get fallback(){return[n(Ry,{get shard(){return e.shard}}),n(Ny,{mode:`room`,get shard(){return e.shard??null},get room(){return e.room}})]},get children(){var t=Py();return T(t,n(Qv,{label:`Selected`,get info(){return e.selectedRoomInfo??null}}),null),T(t,n(Qv,{label:`Cursor`,get info(){return e.hoveredRoomInfo??null},dim:!0}),null),T(t,n(Ny,{mode:`map`,get shard(){return e.shard??null},get selectedRoomInfo(){return e.selectedRoomInfo??null}}),null),t}}),null),i})()}P([`click`]);var By=z(`<div style=display:flex;gap:6px;align-items:center><span style=font-weight:600>CPU:</span><span style=color:#c9d1d9>`),Vy=z(`<div style=display:flex;gap:6px;align-items:center><span style=font-weight:600>Memory:</span><span style=color:#c9d1d9>`),Hy=z(`<div style=display:flex;gap:6px;align-items:center><span style=font-weight:600>Zoom:</span><span style=color:#c9d1d9>%`),Uy=z(`<div style=display:flex;gap:6px;align-items:center><span style=font-weight:600>Subs:</span><span>`),Wy=z(`<div style="display:flex;gap:16px;padding:6px 16px;font-size:12px;color:#8b949e;align-items:center">`);function Gy(t){let[i,s]=e(null);o(()=>{let e=L();if(!e)return;let t=new ot;t.add(e.stores.user.subscribe(`cpu`)),t.add(e.stores.user.on(`user:cpu`,e=>{s(e)})),a(()=>{t.dispose()})});let c=()=>{let e=i();if(!e)return`—`;let t=H()?.cpu??`?`;return`${e.cpu.toFixed(0)} / ${t}`},l=()=>{let e=i();return e?`${(e.memory/1024).toFixed(1)} KB`:`—`};return(()=>{var e=Wy();return T(e,n(h,{get when(){return i()!==null},get children(){return[(()=>{var e=By(),t=e.firstChild.nextSibling;return T(t,c),e})(),(()=>{var e=Vy(),t=e.firstChild.nextSibling;return T(t,l),e})()]}}),null),T(e,n(h,{get when(){return I(()=>t.mapZoom!==null)()&&t.mapZoom!==void 0},get children(){return[(()=>{var e=Hy(),n=e.firstChild.nextSibling,r=n.firstChild;return T(n,()=>(t.mapZoom*100).toFixed(0),r),e})(),(()=>{var e=Uy(),n=e.firstChild.nextSibling;return T(n,()=>t.mapSubsActive===!1?`paused`:`active`),r(e=>B(n,`color`,t.mapSubsActive===!1?`#e3b341`:`#3fb950`)),e})()]}}),null),e})()}var Ky=z(`<div style=width:100%;height:100%;overflow:auto;background:#0d1117;color:#c9d1d9><div style="margin:0 auto;padding:24px 16px 48px">`);function qy(e){return(()=>{var t=Ky(),n=t.firstChild;return T(n,()=>e.children),r(t=>B(n,`max-width`,e.maxWidth??`1040px`)),t})()}var Jy=z(`<div style="display:flex;align-items:center;justify-content:space-between;padding:10px 0;border-bottom:1px solid #21262d"><div><div style=font-size:13px;color:#c9d1d9></div></div><button style="flex-shrink:0;margin-left:24px;width:40px;height:20px;border-radius:10px;border:none;cursor:pointer;position:relative;transition:background 0.15s"><div style="position:absolute;top:2px;width:16px;height:16px;border-radius:50%;background:#fff;transition:left 0.15s">`),Yy=z(`<div style=font-size:11px;color:#8b949e;margin-top:3px>`),Xy=z(`<div style="display:flex;align-items:center;justify-content:space-between;padding:10px 0;border-bottom:1px solid #21262d;gap:24px"><div><div style=font-size:13px;color:#c9d1d9></div></div><select style="flex-shrink:0;background:#21262d;color:#c9d1d9;border:1px solid #30363d;border-radius:4px;padding:4px 8px;font-size:12px;cursor:pointer">`),Zy=z(`<option>`),Qy=z(`<div style=margin-bottom:24px><div style=font-size:10px;font-weight:700;color:#8b949e;text-transform:uppercase;letter-spacing:0.06em;margin-bottom:4px>`),$y=z(`<div style="display:flex;align-items:center;justify-content:space-between;gap:24px;padding:10px 0;border-bottom:1px solid #21262d"><div style=font-size:13px;color:#c9d1d9></div><div style=font-size:12px;color:#8b949e;text-align:right>`),eb=z(`<div style="display:flex;align-items:center;padding:0 0 14px;border-bottom:1px solid #30363d;margin-bottom:24px"><h1 style=margin:0;font-size:22px;font-weight:600;color:#c9d1d9>Settings</h1><div style=flex:1></div><button title=Close style="display:flex;align-items:center;padding:7px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#c9d1d9;cursor:pointer">`),tb=z(`<div style=display:flex;flex-direction:column;gap:4px><label style=font-size:13px;font-weight:500>Structure theme</label><select style="background:#2a2a2a;color:#eee;border:1px solid #444;border-radius:4px;padding:4px 8px;font-size:13px"><option value=vector>Vector (procedural)</option><option value=default>Default (sprites)`),nb=z(`<div style="display:flex;align-items:center;justify-content:space-between;padding:10px 0;border-bottom:1px solid #21262d;gap:24px"><div><div style=font-size:13px;color:#c9d1d9>Config shard</div><div style=font-size:11px;color:#8b949e;margin-top:3px>Shard the config segment is read from. Leave empty for the server default.</div></div><input type=text placeholder=default style="flex-shrink:0;width:110px;background:#21262d;color:#c9d1d9;border:1px solid #30363d;border-radius:4px;padding:4px 8px;font-size:12px">`),rb=z(`<div style="font-size:11px;color:#f85149;padding:8px 0">`),ib=z(`<div style="display:flex;align-items:center;justify-content:space-between;padding:10px 0;border-bottom:1px solid #21262d"><div><div style=font-size:13px;color:#c9d1d9>Clear all caches</div><div style=font-size:11px;color:#8b949e;margin-top:3px>Deletes IndexedDB, Cache API, and localStorage. Session is kept. Page reloads afterwards.</div></div><button style="flex-shrink:0;margin-left:24px;padding:6px 14px;border-radius:6px;border:1px solid #da3633;background:transparent;font-size:12px">`),ab=z(`<div style=max-width:480px>`);function ob(e){return(()=>{var t=Jy(),n=t.firstChild,i=n.firstChild,a=n.nextSibling,o=a.firstChild;return T(i,()=>e.label),T(n,(()=>{var t=I(()=>!!e.description);return()=>t()&&(()=>{var t=Yy();return T(t,()=>e.description),t})()})(),null),a.$$click=()=>e.onChange(!e.value),r(t=>{var n=e.value?`#238636`:`#30363d`,r=e.value?`22px`:`2px`;return n!==t.e&&B(a,`background`,t.e=n),r!==t.t&&B(o,`left`,t.t=r),t},{e:void 0,t:void 0}),t})()}function sb(e){return(()=>{var t=Xy(),i=t.firstChild,a=i.firstChild,o=i.nextSibling;return T(a,()=>e.label),T(i,(()=>{var t=I(()=>!!e.description);return()=>t()&&(()=>{var t=Yy();return T(t,()=>e.description),t})()})(),null),o.addEventListener(`change`,t=>e.onChange(Number(t.currentTarget.value))),T(o,n(b,{get each(){return e.options},children:e=>(()=>{var t=Zy();return T(t,()=>e.label),r(()=>t.value=String(e.value)),t})()})),r(()=>o.value=String(e.value)),t})()}function cb(e){return(()=>{var t=Qy(),n=t.firstChild;return T(n,()=>e.title),T(t,()=>e.children,null),t})()}function lb(e){return(()=>{var t=$y(),n=t.firstChild,r=n.nextSibling;return T(n,()=>e.label),T(r,()=>e.value),t})()}var ub=[{value:5,label:`5 min`},{value:10,label:`10 min`},{value:30,label:`30 min`},{value:60,label:`1 hour`},{value:180,label:`3 hours`},{value:360,label:`6 hours`},{value:720,label:`12 hours`},{value:1440,label:`24 hours`},{value:4320,label:`3 days`}],db=[{value:0,label:`Immediately`},{value:10,label:`Every 10 min`},{value:30,label:`Every 30 min`},{value:60,label:`Every 1 hour`},{value:180,label:`Every 3 hours`},{value:360,label:`Every 6 hours`},{value:720,label:`Every 12 hours`},{value:1440,label:`Every 24 hours`},{value:4320,label:`Every 3 days`},{value:1e5,label:`Never`}];function fb(t){let i=fe(),[a,o]=e(!1);async function s(e){let t=L();if(t)try{await t.http.user.notifyPrefs(e),await t.stores.user.refreshMe()}catch(e){j(`Failed to save notification preference: ${e.message}`,`error`)}}async function c(){o(!0);try{await De(),j(`All caches cleared. Reloading…`,`success`,2e3),setTimeout(()=>window.location.reload(),1500)}catch{j(`Failed to clear caches.`,`error`),o(!1)}}return n(qy,{maxWidth:`600px`,get children(){return[(()=>{var e=eb(),r=e.firstChild.nextSibling.nextSibling;return r.$$click=()=>t.onClose(),T(r,n(ya,{size:16})),e})(),(()=>{var e=ab();return T(e,n(cb,{title:`Layout`,get children(){return n(ob,{label:`Widescreen mode`,description:`Sidebar spans full height; console sits below the room view only. When off, the console spans the full width below both the view and the sidebar.`,get value(){return At()},onChange:Mt})}}),null),T(e,n(cb,{title:`Room View`,get children(){return[n(ob,{label:`Terrain effects`,description:`Swamp glow and wall noise texture overlay.`,get value(){return en()},onChange:Ot}),n(ob,{label:`Room decorations`,description:`Load player-activated theme decorations (floor, wall, road colors) from the server.`,get value(){return xt()},onChange:wn}),n(ob,{label:`Dark overlay + lights`,description:`Darken the room and add per-object light glows.`,get value(){return Xt()},onChange:Tt}),(()=>{var e=tb(),t=e.firstChild.nextSibling;return t.addEventListener(`change`,e=>Wt(e.currentTarget.value)),r(()=>t.value=Qt()),e})()]}}),null),T(e,n(h,{get when(){return!be()},get children(){return n(cb,{title:`Notifications`,get children(){return(()=>{let e=()=>H()?.notifyPrefs??{},t=()=>!e().disabled;return[n(ob,{label:`Email notifications`,description:`Send email notifications for game events.`,get value(){return t()},onChange:e=>void s({disabled:!e})}),n(h,{get when(){return t()},get children(){return[n(sb,{label:`Send interval`,description:`Notifications are grouped and mailed out at this interval.`,get value(){return e().interval??60},options:ub,onChange:e=>void s({interval:e})}),n(ob,{label:`Send when online`,description:`Send notifications even while you are active in the game.`,get value(){return e().sendOnline??!1},onChange:e=>void s({sendOnline:e})}),n(sb,{label:`Notify on errors`,description:`Send a notification when your script throws an error.`,get value(){return e().errorsInterval??30},options:db,onChange:e=>void s({errorsInterval:e})}),n(ob,{label:`Notify on new messages`,description:`Send a notification when you receive a new in-game message.`,get value(){return!(e().disabledOnMessages??!1)},onChange:e=>void s({disabledOnMessages:!e})})]}})]})()}})}}),null),T(e,n(h,{get when(){return!be()},get children(){return n(cb,{title:`Custom UI`,get children(){return[n(sb,{label:`Config segment`,description:`Memory segment holding your custom UI definition (JSON). See docs/custom-ui.md for the format.`,get value(){return _m()??-1},get options(){return[{value:-1,label:`Disabled`},...Array.from({length:100},(e,t)=>({value:t,label:`Segment ${t}`}))]},onChange:e=>Mm(e<0?null:e)}),n(h,{get when(){return _m()!==null},get children(){return[(()=>{var e=nb(),t=e.firstChild;t.firstChild.nextSibling;var n=t.nextSibling;return n.addEventListener(`change`,e=>Nm(e.currentTarget.value)),r(()=>n.value=ym()),e})(),n(ob,{label:`Hide protocol lines`,description:`Hide SCUI response lines from the Log and Console panes. Turn off to debug your handler.`,get value(){return qn()},onChange:Et}),n(h,{get when(){return Cm()},get children(){var e=rb();return T(e,Cm),e}})]}})]}})}}),null),T(e,n(cb,{title:`Data`,get children(){var e=ib(),t=e.firstChild;t.firstChild.nextSibling;var n=t.nextSibling;return n.$$click=c,T(n,()=>a()?`Clearing…`:`Clear`),r(e=>{var t=a(),r=a()?`#8b949e`:`#f85149`,i=a()?`default`:`pointer`,o=a()?.6:1;return t!==e.e&&(n.disabled=e.e=t),r!==e.t&&B(n,`color`,e.t=r),i!==e.a&&B(n,`cursor`,e.a=i),o!==e.o&&B(n,`opacity`,e.o=o),e},{e:void 0,t:void 0,a:void 0,o:void 0}),e}}),null),T(e,n(cb,{title:`About`,get children(){return[n(lb,{label:`Client version`,get value(){return D()}}),I(()=>i&&n(lb,{label:`Mod version`,get value(){return`${i.version} (${i.kind})`}}))]}}),null),e})()]}})}P([`click`]);var pb=z(`<div style="position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);max-width:min(520px, calc(100% - 48px));max-height:calc(100% - 48px);z-index:20;display:flex;background:#161b22;border:1px solid #30363d;border-radius:8px;box-shadow:0 8px 24px rgba(0, 0, 0, 0.5);animation:motd-in 0.25s ease"><button title=Dismiss style=position:absolute;top:8px;right:8px;padding:4px;border-radius:4px;border:none;background:transparent;color:#8b949e;cursor:pointer;display:flex;align-items:center></button><div style="padding:20px 36px 20px 20px;overflow:auto;color:#c9d1d9;font-size:13px;line-height:1.6">`),mb=15e3;function hb(e){let t,i=()=>{t!==void 0&&(clearTimeout(t),t=void 0)},s=()=>{i(),t=setTimeout(()=>e.onClose(),mb)};return o(s),a(i),(()=>{var t=pb(),a=t.firstChild,o=a.nextSibling;return t.addEventListener(`mouseleave`,s),t.addEventListener(`mouseenter`,i),a.$$click=()=>e.onClose(),T(a,n(ya,{size:16})),r(()=>o.innerHTML=e.text),t})()}P([`click`]);var gb=z(`<img width=20 height=20 style=display:block;border-radius:3px>`),_b=z(`<img width=15 height=15 style=display:block;border-radius:2px>`),vb=z(`<span>`),yb=z(`<span>Settings`),bb=z(`<span>Respawn`),xb=z(`<span>Logout`),Sb=z(`<div style="position:absolute;top:calc(100% + 4px);right:0;min-width:180px;background:#161b22;border:1px solid #30363d;border-radius:6px;box-shadow:0 8px 24px rgba(0, 0, 0, 0.5);z-index:100;overflow:hidden;padding:4px">`),Cb=z(`<div style=position:fixed;inset:0;background:rgba(0,0,0,0.65);z-index:200;display:flex;align-items:center;justify-content:center><div style="width:min(440px, calc(100% - 48px));background:#161b22;border:1px solid #30363d;border-radius:8px;box-shadow:0 8px 24px rgba(0, 0, 0, 0.5);padding:20px"><div style=font-size:16px;font-weight:600;color:#f85149;margin-bottom:12px>Respawn?</div><p style="font-size:13px;color:#c9d1d9;line-height:1.5;margin:0 0 10px">All your buildings and creeps will become unowned so that you can reset your spawn in any vacant room on the map.</p><p style="font-size:13px;color:#8b949e;line-height:1.5;margin:0 0 18px"><b style=color:#c9d1d9>Note:</b> you will NOT be able to spawn again in the same room within 3 days of the initial spawn placement.</p><div style=display:flex;justify-content:flex-end;gap:8px><button style="padding:7px 14px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#c9d1d9;font-size:13px">Cancel</button><button style="padding:7px 14px;border-radius:4px;border:1px solid #da3633;background:#da3633;color:#fff;font-size:13px;font-weight:600">`),wb=z(`<div style=font-size:12px;color:#f85149;margin-bottom:12px>`),Tb=z(`<div style=position:fixed;inset:0;background:rgba(0,0,0,0.65);z-index:200;display:flex;align-items:center;justify-content:center><form style="width:min(420px, calc(100% - 48px));background:#161b22;border:1px solid #30363d;border-radius:8px;box-shadow:0 8px 24px rgba(0, 0, 0, 0.5);padding:20px"><div style=font-size:16px;font-weight:600;color:#c9d1d9;margin-bottom:16px></div><div style=display:flex;justify-content:flex-end;gap:8px;margin-top:4px><button type=button style="padding:7px 14px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#c9d1d9;font-size:13px">Cancel</button><button type=submit style="padding:7px 14px;border-radius:4px;border:1px solid #238636;background:#238636;color:#fff;font-size:13px;font-weight:600">`),Eb=z(`<div style="position:relative;margin:0 16px 0 8px"><button title=Account style="padding:5px 8px;border-radius:4px;border:1px solid #30363d;color:#c9d1d9;cursor:pointer;display:flex;align-items:center;gap:6px;font-size:13px"><span style=font-weight:600;max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap>`),Db=z(`<label style=display:block;margin-bottom:12px><span style=display:block;font-size:12px;color:#8b949e;margin-bottom:4px></span><input type=password style="width:100%;padding:7px 10px;border-radius:4px;border:1px solid #30363d;background:#0d1117;color:#c9d1d9;font-size:13px">`),Ob=z(`<button style="width:100%;display:flex;align-items:center;gap:8px;padding:8px 10px;border-radius:4px;border:none;cursor:pointer;font-size:13px;text-align:left">`);function kb(t){let[o,s]=e(!1),[c,l]=e(!1),[u,d]=e(!1),[f,m]=e(!1),[g,_]=e(``),[v,y]=e(``),[b,x]=e(``),[S,C]=e(!1),w=()=>Fe()===`password`||Fe()===`steam`||Fe()===`discord`,E=()=>H()?.password===!0,D=i(()=>E()&&g().length===0?`Enter your current password.`:v().length<8?`New password must be at least 8 characters.`:v()===b()?null:`Passwords don't match.`),O,k=i(()=>{let e=H()?.badge;return e?`data:image/svg+xml,${encodeURIComponent(gt(e))}`:null});p(()=>{if(!o())return;let e=e=>{O&&!O.contains(e.target)&&s(!1)},t=e=>{e.key===`Escape`&&s(!1)};document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),a(()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)})});function A(){let e=L();e&&(d(!0),e.http.user.respawn().then(()=>{j(`Respawn successful`,`success`),Ae()}).catch(e=>j(`Respawn failed: ${e.message}`,`error`)).finally(()=>{d(!1),l(!1)}))}function ee(){_(``),y(``),x(``),m(!0)}function M(){let e=L();if(!e||D())return;let t=!E();C(!0),e.http.user.password(v(),g()).then(()=>{j(t?`Password set`:`Password changed`,`success`),m(!1),t&&e.stores.user.refreshMe()}).catch(e=>j(`Password ${t?`setup`:`change`} failed: ${e.message}`,`error`)).finally(()=>C(!1))}return(()=>{var e=Eb(),i=e.firstChild,a=i.firstChild;return Pe(e=>O=e,e),i.$$click=()=>s(e=>!e),T(i,n(h,{get when(){return k()},get children(){var e=gb();return r(()=>R(e,`src`,k())),e}}),a),T(a,()=>H()?.username??`…`),T(i,n(Vr,{size:14}),null),T(e,n(h,{get when(){return o()},get children(){var e=Sb();return T(e,n(jb,{onClick:()=>{s(!1),t.onOpenBadgePicker()},get children(){return[n(h,{get when(){return k()},get fallback(){return n(sa,{size:15})},get children(){var e=_b();return r(()=>R(e,`src`,k())),e}}),(()=>{var e=vb();return T(e,()=>H()?.badge?`Edit Badge`:`Create Badge`),e})()]}}),null),T(e,n(jb,{onClick:()=>{s(!1),t.onOpenSettings()},get children(){return[n(ra,{size:15}),yb()]}}),null),T(e,n(h,{get when(){return w()},get children(){return n(jb,{onClick:()=>{s(!1),ee()},get children(){return[n(xi,{size:15}),(()=>{var e=vb();return T(e,()=>E()?`Change password`:`Set password`),e})()]}})}}),null),T(e,n(jb,{onClick:()=>{s(!1),l(!0)},get children(){return[n($i,{size:15}),bb()]}}),null),T(e,n(jb,{onClick:()=>{s(!1),we()},danger:!0,get children(){return[n(ji,{size:15}),xb()]}}),null),e}}),null),T(e,n(h,{get when(){return c()},get children(){var e=Cb(),t=e.firstChild.firstChild.nextSibling.nextSibling;t.firstChild;var n=t.nextSibling.firstChild,i=n.nextSibling;return e.$$click=e=>{e.target===e.currentTarget&&!u()&&l(!1)},n.$$click=()=>l(!1),i.$$click=A,T(i,()=>u()?`Respawning…`:`Respawn`),r(e=>{var t=u(),r=u()?`default`:`pointer`,a=u(),o=u()?`default`:`pointer`,s=u()?.6:1;return t!==e.e&&(n.disabled=e.e=t),r!==e.t&&B(n,`cursor`,e.t=r),a!==e.a&&(i.disabled=e.a=a),o!==e.o&&B(i,`cursor`,e.o=o),s!==e.i&&B(i,`opacity`,e.i=s),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}}),null),T(e,n(h,{get when(){return f()},get children(){var e=Tb(),t=e.firstChild,i=t.firstChild,a=i.nextSibling,o=a.firstChild,s=o.nextSibling;return e.$$click=e=>{e.target===e.currentTarget&&!S()&&m(!1)},t.addEventListener(`submit`,e=>{e.preventDefault(),M()}),T(i,()=>E()?`Change password`:`Set password`),T(t,n(h,{get when(){return E()},get children(){return n(Ab,{label:`Current password`,get value(){return g()},onInput:_,autofocus:!0})}}),a),T(t,n(Ab,{label:`New password`,get value(){return v()},onInput:y,get autofocus(){return!E()}}),a),T(t,n(Ab,{label:`Confirm new password`,get value(){return b()},onInput:x}),a),T(t,n(h,{get when(){return I(()=>!!D())()&&(v()||b())},get children(){var e=wb();return T(e,D),e}}),a),o.$$click=()=>m(!1),T(s,()=>S()?`Saving…`:`Save`),r(e=>{var t=S(),n=S()?`default`:`pointer`,r=S()||D()!=null,i=S()||D()!=null?`default`:`pointer`,a=S()||D()!=null?.6:1;return t!==e.e&&(o.disabled=e.e=t),n!==e.t&&B(o,`cursor`,e.t=n),r!==e.a&&(s.disabled=e.a=r),i!==e.o&&B(s,`cursor`,e.o=i),a!==e.i&&B(s,`opacity`,e.i=a),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}}),null),r(e=>B(i,`background`,o()?`#21262d`:`#161b22`)),e})()}function Ab(e){return(()=>{var t=Db(),n=t.firstChild,i=n.nextSibling;return T(n,()=>e.label),i.$$input=t=>e.onInput(t.currentTarget.value),r(()=>i.autofocus=e.autofocus),r(()=>i.value=e.value),t})()}function jb(t){let[n,i]=e(!1);return(()=>{var e=Ob();return e.addEventListener(`mouseleave`,()=>i(!1)),e.addEventListener(`mouseenter`,()=>i(!0)),e.$$click=()=>t.onClick(),T(e,()=>t.children),r(r=>{var i=n()?`#21262d`:`transparent`,a=t.danger?`#f85149`:`#c9d1d9`;return i!==r.e&&B(e,`background`,r.e=i),a!==r.t&&B(e,`color`,r.t=a),r},{e:void 0,t:void 0}),e})()}P([`click`,`input`]);function Mb(){return{isDesktop:ne(),isEmbedded:de(),isXxscreepsMode:pe(),isPrivateServer:Oe(),hasHistory:(Se()?.serverData?.historyChunkSize??0)>0,hasMarket:!0,hasMessaging:!0}}var Nb=z(`<div style=position:relative;width:84px;height:84px;flex-shrink:0><svg width=84 height=84 style=transform:rotate(-90deg)><circle cx=42 cy=42 r=38 fill=none stroke-width=8 opacity=0.2></circle><circle cx=42 cy=42 r=38 fill=none stroke-width=8 stroke-linecap=round></circle></svg><div style=position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center><div style=font-size:26px;font-weight:700;line-height:1></div><div style=font-size:10px;font-weight:300;letter-spacing:0.5px>`),Pb=`#4DB6AC`,Fb=`#A7FFEB`,Ib=`#C54444`,Lb=`#FF9A9A`;function Rb(e){let t=2*Math.PI*(76/2),n=()=>`${Math.max(0,Math.min(1,e.fraction))*t} ${t}`;return(()=>{var t=Nb(),i=t.firstChild,a=i.firstChild,o=a.nextSibling,s=i.nextSibling,c=s.firstChild,l=c.nextSibling;return T(c,()=>e.value),T(l,()=>e.label),r(r=>{var i=e.tooltip,c=e.ring,l=e.ring,u=n(),d=e.text;return i!==r.e&&R(t,`title`,r.e=i),c!==r.t&&R(a,`stroke`,r.t=c),l!==r.a&&R(o,`stroke`,r.a=l),u!==r.o&&R(o,`stroke-dasharray`,r.o=u),d!==r.i&&B(s,`color`,r.i=d),r},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),t})()}var zb=z(`<img alt style=display:block;border-radius:3px;flex-shrink:0>`);function Bb(e){let t=()=>e.badge?`data:image/svg+xml,${encodeURIComponent(gt(e.badge))}`:null;return n(h,{get when(){return t()},get children(){var n=zb();return r(r=>{var i=t(),a=e.size??24,o=e.size??24;return i!==r.e&&R(n,`src`,r.e=i),a!==r.t&&R(n,`width`,r.t=a),o!==r.a&&R(n,`height`,r.a=o),r},{e:void 0,t:void 0,a:void 0}),n}})}var Vb=z(`<button style="position:absolute;top:50%;right:4px;transform:translateY(-50%);display:flex;align-items:center;padding:2px;border-radius:3px;border:1px solid #30363d;background:#21262d;color:#8b949e;cursor:pointer;line-height:0">`),Hb=z(`<div style="position:relative;padding:4px 0;text-align:center;font-size:12px;font-family:monospace;color:#c9d1d9;line-height:1.2;border-top:1px solid #30363d">`),Ub=z(`<div role=button tabindex=0 style="padding:0;border:1px solid #30363d;border-radius:6px;overflow:hidden;background:#161b22;cursor:pointer;line-height:0"><canvas style=display:block>`),Wb=3;function Gb(e,t,n,r){if(!t.length)return;e.fillStyle=gn(n);let i=Wb-r*2;for(let[n,a]of t)e.fillRect(n*Wb+r,a*Wb+r,i,i)}function Kb(e,t,n,r){if(t.length){e.fillStyle=gn(n),e.beginPath();for(let[n,i]of t){let t=(n+.5)*Wb,a=(i+.5)*Wb;e.moveTo(t+r,a),e.arc(t,a,r,0,Math.PI*2)}e.fill()}}function qb(e){let t,i=null,s=null,c,l=()=>{let e=t?.getContext(`2d`);if(!e)return;if(e.setTransform(2,0,0,2,0,0),e.fillStyle=gn(sn),e.fillRect(0,0,150,150),i){let t=i.raw;e.fillStyle=gn(Wn);for(let n=0;n<2500;n++)t[n]===lt.Wall&&e.fillRect(n%50*Wb,Math.floor(n/50)*Wb,Wb,Wb);e.fillStyle=gn(Vn);for(let n=0;n<2500;n++)t[n]===lt.Swamp&&e.fillRect(n%50*Wb,Math.floor(n/50)*Wb,Wb,Wb)}let n=s;if(n){Gb(e,n.r??[],Pn,0),Gb(e,n.w??[],pn,.5);for(let t of zn)Kb(e,n[t.key]??[],t.color,t.radius);let t=n,r=c??H()?._id;for(let n in t){if(Sn.has(n))continue;let i=t[n];!Array.isArray(i)||i.length===0||Kb(e,i,n===r?On:dn,1.2)}}};o(()=>{let t=L();if(!t)return;c=e.ownerId,t.stores.room.terrain(e.room,e.shard).then(e=>{i=e,l()}).catch(()=>{});let n=t.stores.map.subscribeMap2(e.room,e.shard),r=t.stores.map.map2data(e.room,e.shard);r&&(s=r,l());let o=t.stores.map.on(`room:map2update`,({room:t,shard:n,data:r})=>{t!==e.room||(n??null)!==(e.shard??null)||(s=r,l())});a(()=>{n.dispose(),o.dispose()})});let u=()=>e.onClick?.();return(()=>{var i=Ub(),a=i.firstChild;return i.$$keydown=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u())},i.$$click=u,Pe(e=>t=e,a),R(a,`width`,300),R(a,`height`,300),B(a,`width`,`150px`),B(a,`height`,`150px`),T(i,n(h,{get when(){return e.showLabel!==!1},get children(){var t=Hb();return T(t,()=>e.room,null),T(t,n(h,{get when(){return e.onOverview},get children(){var t=Vb();return t.addEventListener(`mouseleave`,e=>e.currentTarget.style.color=`#8b949e`),t.addEventListener(`mouseenter`,e=>e.currentTarget.style.color=`#58a6ff`),t.$$click=t=>{t.stopPropagation(),e.onOverview?.()},T(t,n(Lr,{size:13})),r(()=>R(t,`title`,`Room overview — ${e.room}`)),t}}),null),t}}),null),r(()=>R(i,`title`,e.room+(e.shard?` · ${e.shard}`:``))),i})()}P([`click`,`keydown`]);function Jb(e){if(e==null||!Number.isFinite(e))return`0`;let t=Math.round(e),n=Math.abs(t);return n<1e4?String(t):n<1e6?`${(t/1e3).toPrecision(3)}K`:n<1e9?`${(t/1e6).toPrecision(3)}M`:`${(t/1e9).toPrecision(3)}B`}var Yb=z(`<div style="flex:1;min-width:0;background:#161b22;border:1px solid #30363d;border-radius:6px;padding:14px 8px 12px;text-align:center"><div style=color:#8b949e;font-size:11px;text-transform:uppercase;line-height:1.3><br></div><div style=font-size:28px;font-weight:300;margin-top:8px>`),Xb=z(`<div style=display:flex;gap:10px>`),Zb=[{key:`energyControl`,l1:`Control`,l2:`points`,color:`#A7FFEB`},{key:`energyHarvested`,l1:`Energy`,l2:`harvested`,color:`#ffe56d`},{key:`energyConstruction`,l1:`Energy`,l2:`on construct`,color:`#eeeeee`},{key:`energyCreeps`,l1:`Energy`,l2:`on creeps`,color:`#eeeeee`},{key:`creepsProduced`,l1:`Creeps`,l2:`produced`,color:`#65fd62`},{key:`creepsLost`,l1:`Creeps`,l2:`lost`,color:`#f96e76`},{key:`powerProcessed`,l1:`Power`,l2:`processed`,color:`#E04040`}];function Qb(e){return(()=>{var t=Yb(),n=t.firstChild,i=n.firstChild,a=n.nextSibling;return T(n,()=>e.l1,i),T(n,()=>e.l2,null),T(a,()=>Jb(e.value)),r(t=>B(a,`color`,e.color)),t})()}function $b(e){let t=e?.stats;if(!t)return null;let n={};for(let e of Zb){let r=t[e.key];r!=null&&(n[e.key]=Array.isArray(r)?r.reduce((e,t)=>e+(t?.value??0),0):Number(r)||0)}return n}function ex(e){return(()=>{var t=Xb();return T(t,n(b,{each:Zb,children:t=>n(Qb,{get l1(){return t.l1},get l2(){return t.l2},get color(){return t.color},get value(){return e.totals?.[t.key]}})})),t})()}function tx(e){return e.shards?Object.entries(e.shards).flatMap(([e,t])=>(t??[]).map(t=>({room:t,shard:e}))):(e.rooms??[]).map(e=>({room:e,shard:null}))}var nx=2.4,rx=1e6,ix=1e3;function ax(e){return Math.floor((e/rx)**(1/nx))+1}function ox(e){let t=ax(e),n=(t-1)**nx*rx,r=t**nx*rx;return{level:t,current:e-n,total:r-n}}function sx(e){return Math.floor((e/ix)**(1/2))}function cx(e){let t=sx(e),n=t**2*ix,r=(t+1)**2*ix;return{level:t,current:e-n,total:r-n}}var lx=[`operator`,`commander`,`executor`],ux={operator:{name:`operator`,label:`Operator`,description:`A creep working mainly in the rear, at your base, though it can be used as a saboteur in offensive operations.`,underDevelopment:!1},commander:{name:`commander`,label:`Commander`,description:`This power creep is not very useful on its own, but it's a team player. It influences and affects regular creeps, both friendly and hostile.`,underDevelopment:!0},executor:{name:`executor`,label:`Executor`,description:`This creep class prefers working alone. Due to its skills, it's a very effective performer in your economy or as a war machine when defending or attacking.`,underDevelopment:!0}},dx={GENERATE_OPS:1,OPERATE_SPAWN:2,OPERATE_TOWER:3,OPERATE_STORAGE:4,OPERATE_LAB:5,OPERATE_EXTENSION:6,OPERATE_OBSERVER:7,OPERATE_TERMINAL:8,DISRUPT_SPAWN:9,DISRUPT_TOWER:10,DISRUPT_SOURCE:11,SHIELD:12,REGEN_SOURCE:13,REGEN_MINERAL:14,DISRUPT_TERMINAL:15,OPERATE_POWER:16,FORTIFY:17,OPERATE_CONTROLLER:18,OPERATE_FACTORY:19},fx=[0,2,7,14,22],px=[10,11,12,14,22],mx=[20,21,22,23,24],hx=(e,t,n,r,i)=>[e,t,n,r,i],gx=[{id:dx.GENERATE_OPS,name:`GENERATE_OPS`,className:`operator`,icon:Ca,reqLevel:fx,values:hx(`1`,`2`,`4`,`6`,`8`),effect:`Generate %s ops resource units.`,cooldown:50},{id:dx.OPERATE_SPAWN,name:`OPERATE_SPAWN`,className:`operator`,icon:Zi,reqLevel:fx,values:hx(`10%`,`30%`,`50%`,`65%`,`80%`),effect:`Reduce spawn time by %s.`,duration:1e3,cooldown:300,range:3,ops:100},{id:dx.OPERATE_TOWER,name:`OPERATE_TOWER`,className:`operator`,icon:ri,reqLevel:fx,values:hx(`10%`,`20%`,`30%`,`40%`,`50%`),effect:`Increase damage, repair and heal amount by %s.`,duration:100,cooldown:10,range:3,ops:10},{id:dx.OPERATE_STORAGE,name:`OPERATE_STORAGE`,className:`operator`,icon:ai,reqLevel:fx,values:hx(`500K`,`1M`,`2M`,`4M`,`7M`),effect:`Increase capacity by %s units.`,duration:1e3,cooldown:800,range:3,ops:100},{id:dx.OPERATE_LAB,name:`OPERATE_LAB`,className:`operator`,icon:hi,reqLevel:fx,values:hx(`2`,`4`,`6`,`8`,`10`),effect:`Increase reaction amount by %s units.`,duration:1e3,cooldown:50,range:3,ops:10},{id:dx.OPERATE_EXTENSION,name:`OPERATE_EXTENSION`,className:`operator`,icon:jr,reqLevel:fx,values:hx(`20%`,`40%`,`60%`,`80%`,`100%`),effect:`Instantly fill %s of all extensions in the room using energy from the target structure.`,cooldown:50,range:3,ops:2},{id:dx.OPERATE_OBSERVER,name:`OPERATE_OBSERVER`,className:`operator`,icon:di,reqLevel:fx,values:hx(`200`,`400`,`600`,`800`,`1000`),effect:`Grant unlimited range. Effect duration %s ticks.`,cooldown:400,range:3,ops:10},{id:dx.OPERATE_TERMINAL,name:`OPERATE_TERMINAL`,className:`operator`,icon:Tr,reqLevel:fx,values:hx(`10%`,`20%`,`30%`,`40%`,`50%`),effect:`Decrease transfer energy cost and cooldown by %s.`,duration:1e3,cooldown:500,range:3,ops:100},{id:dx.DISRUPT_SPAWN,name:`DISRUPT_SPAWN`,className:`operator`,icon:kr,reqLevel:fx,values:hx(`1`,`2`,`3`,`4`,`5`),effect:`Pause spawning process. Effect duration %s ticks.`,cooldown:5,range:20,ops:10},{id:dx.DISRUPT_TOWER,name:`DISRUPT_TOWER`,className:`operator`,icon:xa,reqLevel:fx,values:hx(`10%`,`20%`,`30%`,`40%`,`50%`),effect:`Reduce effectiveness by %s.`,duration:5,cooldown:null,range:50,ops:10},{id:dx.DISRUPT_SOURCE,name:`DISRUPT_SOURCE`,className:`operator`,icon:Zr,reqLevel:fx,values:hx(`100`,`200`,`300`,`400`,`500`),effect:`Pause energy regeneration. Effect duration %s ticks.`,cooldown:100,range:3,ops:100},{id:dx.SHIELD,name:`SHIELD`,className:`operator`,icon:sa,reqLevel:fx,values:hx(`5K`,`10K`,`15K`,`20K`,`25K`),effect:`Create a temporary non-repairable rampart on the same square with %s hits. Cannot be used on top of another rampart.`,duration:50,cooldown:20},{id:dx.FORTIFY,name:`FORTIFY`,className:`operator`,icon:aa,reqLevel:fx,values:hx(`1`,`2`,`3`,`4`,`5`),effect:`Make a wall or rampart tile invulnerable to all creep attacks and powers. Effect duration %s ticks.`,cooldown:5,range:3,ops:5},{id:dx.OPERATE_FACTORY,name:`OPERATE_FACTORY`,className:`operator`,icon:li,reqLevel:fx,values:hx(`1`,`2`,`3`,`4`,`5`),effect:`Set the factory level to %s. Permanent and cannot be undone; re-apply to renew the effect.`,duration:1e3,cooldown:800,range:3,ops:100},{id:dx.REGEN_SOURCE,name:`REGEN_SOURCE`,className:`operator`,icon:da,reqLevel:px,values:hx(`50`,`100`,`150`,`200`,`250`),effect:`Regenerate %s energy units in a source every 15 ticks.`,duration:300,cooldown:100,range:3},{id:dx.REGEN_MINERAL,name:`REGEN_MINERAL`,className:`operator`,icon:_i,reqLevel:px,values:hx(`2`,`4`,`6`,`8`,`10`),effect:`Regenerate %s mineral units in a deposit every 10 ticks.`,duration:100,cooldown:100,range:3},{id:dx.OPERATE_POWER,name:`OPERATE_POWER`,className:`operator`,icon:Dr,reqLevel:px,values:hx(`1`,`2`,`3`,`4`,`5`),effect:`Increase power processing speed of a Power Spawn by %s units per tick.`,duration:1e3,cooldown:800,range:3,ops:200},{id:dx.DISRUPT_TERMINAL,name:`DISRUPT_TERMINAL`,className:`operator`,icon:zi,reqLevel:mx,values:hx(``,``,``,``,``),effect:`Block withdrawing resources from the terminal.`,duration:10,cooldown:8,range:50,ops:[50,40,30,20,10]},{id:dx.OPERATE_CONTROLLER,name:`OPERATE_CONTROLLER`,className:`operator`,icon:_a,reqLevel:mx,values:hx(`10`,`20`,`30`,`40`,`50`),effect:`Increase the max energy that can upgrade a Level 8 Controller each tick by %s units.`,duration:1e3,cooldown:800,range:3,ops:200}],_x=Object.fromEntries(gx.map(e=>[e.id,e]));function vx(e){return gx.filter(t=>t.className===e)}function yx(e,t){let n=e.values[Math.max(0,Math.min(4,t-1))];return e.effect.replace(`%s`,n)}function bx(e,t){let n=[],r=Array.isArray(e.ops)?e.ops[Math.max(0,Math.min(4,t-1))]:e.ops;return r!=null&&n.push(`ops ${r}`),e.duration!=null&&n.push(`dur ${e.duration}`),e.cooldown===null?n.push(`no cooldown`):e.cooldown!=null&&n.push(`cd ${e.cooldown}`),e.range!=null&&n.push(`rng ${e.range}`),n.join(` · `)}function xx(e){return e.level+1}function Sx(e,t){return sx(e??0)-t.reduce((e,t)=>e+xx(t),0)}var Cx=z(`<svg><circle cx=12 cy=12 r=9.5></svg>`,!1,!0,!1),wx=z(`<svg><path d="M12 6.5 L17 16 L7 16 Z"stroke=none></svg>`,!1,!0,!1),Tx=z(`<svg><path d="M5 8 L12 4 L19 8"></svg>`,!1,!0,!1),Ex=z(`<svg><path d="M5 13 L12 9 L19 13"></svg>`,!1,!0,!1),Dx=z(`<svg><path d="M5 18 L12 14 L19 18"></svg>`,!1,!0,!1),Ox=z(`<svg><path d="M12 2.5 L15 9 L21.5 12 L15 15 L12 21.5 L9 15 L2.5 12 L9 9 Z"></svg>`,!1,!0,!1),kx=z(`<svg viewBox="0 0 24 24"fill=none stroke-width=1.8 stroke-linecap=round stroke-linejoin=round style=display:block;flex-shrink:0>`);function Ax(e){let t=()=>e.size??24,i=()=>e.color??`currentColor`;return(()=>{var a=kx();return T(a,n(S,{get children(){return[n(C,{get when(){return e.class===`operator`},get children(){return[Cx(),(()=>{var e=wx();return r(()=>R(e,`fill`,i())),e})()]}}),n(C,{get when(){return e.class===`commander`},get children(){return[Tx(),Ex(),Dx()]}}),n(C,{get when(){return e.class===`executor`},get children(){return Ox()}})]}})),r(e=>{var n=t(),r=t(),o=i();return n!==e.e&&R(a,`width`,e.e=n),r!==e.t&&R(a,`height`,e.t=r),o!==e.a&&R(a,`stroke`,e.a=o),e},{e:void 0,t:void 0,a:void 0}),a})()}var jx=`#161b22`,Mx=`#1c2128`,Nx=`#30363d`,Px=`#c9d1d9`,X=`#8b949e`,Fx=`#58a6ff`,Ix=`#238636`,Lx=`#FF9A9A`,Rx=`#E04040`,zx=z(`<button style="display:inline-flex;align-items:center;gap:6px;padding:8px 16px;border-radius:6px;border:none;font-size:13px;font-weight:600"> Create creep`),Bx=z(`<div style=display:flex;flex-wrap:wrap;gap:6px>`),Vx=z(`<div style=font-size:11px;color:#f0883e>Scheduled for deletion`),Hx=z(`<button style=text-align:left;display:flex;flex-direction:column;gap:12px;width:220px;border-radius:8px;padding:16px;cursor:pointer><div style=display:flex;align-items:center;gap:10px><div style=min-width:0;flex:1><div style=font-size:15px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis></div><div style=font-size:12px> · Lvl `),Ux=z(`<div style=font-size:11px>No powers assigned`),Wx=z(`<span style=display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:5px>`),Gx=z(`<div style=display:flex;align-items:center;margin-bottom:16px><div style=flex:1></div><a href=https://docs.screeps.com/power.html target=_blank rel=noopener style=color:#58a6ff;font-size:13px;text-decoration:none>Learn more`),Kx=z(`<div style=display:flex;flex-wrap:wrap;gap:16px>`),qx=z(`<div style=padding:32px;text-align:center>Loading…`),Jx=z(`<div style="border-radius:10px;padding:48px 24px;text-align:center"><div style=display:flex;justify-content:center;gap:28px;margin-bottom:24px></div><p style="font-size:15px;margin:0 0 6px;line-height:1.5">You have no Power Creeps yet.</p><p style="font-size:13px;margin:0 0 24px;line-height:1.5">You need 1 free Power Level in your account to create a new Power Creep.</p><div style=display:flex;align-items:center;justify-content:center;gap:16px><a href=https://docs.screeps.com/power.html target=_blank rel=noopener style=color:#58a6ff;font-size:13px;text-decoration:none>Learn more`);function Yx(e){let t=()=>e.free>=1;return(()=>{var i=zx(),a=i.firstChild;return i.$$click=()=>t()&&e.onNew(),T(i,n(qi,{size:16}),a),r(e=>{var n=!t(),r=t()?`Create a new power creep`:`You need 1 free Power Level to create a power creep`,a=t()?Ix:`#21262d`,o=t()?`#fff`:X,s=t()?`pointer`:`not-allowed`,c=t()?1:.7;return n!==e.e&&(i.disabled=e.e=n),r!==e.t&&R(i,`title`,e.t=r),a!==e.a&&B(i,`background`,e.a=a),o!==e.o&&B(i,`color`,e.o=o),s!==e.i&&B(i,`cursor`,e.i=s),c!==e.n&&B(i,`opacity`,e.n=c),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),i})()}function Xx(e){let t=()=>e.creep.className,i=()=>ux[t()]??ux.operator,a=()=>{let t=e.creep.powers??{};return Object.keys(t).filter(e=>(t[e]?.level??0)>0).map(e=>_x[Number(e)]).filter(Boolean)};return(()=>{var o=Hx(),s=o.firstChild,c=s.firstChild,l=c.firstChild,u=l.nextSibling,d=u.firstChild;return o.$$click=()=>e.onSelect(e.creep._id),B(o,`background`,jx),B(o,`border`,`1px solid ${Nx}`),B(o,`color`,Px),T(s,n(Ax,{get class(){return t()},size:28,color:Lx}),c),T(l,()=>e.creep.name),B(u,`color`,X),T(u,()=>i().label,d),T(u,()=>e.creep.level,null),T(o,n(h,{get when(){return a().length},get fallback(){return(()=>{var e=Ux();return B(e,`color`,X),e})()},get children(){var e=Bx();return T(e,n(b,{get each(){return a()},children:e=>(()=>{var t=Wx();return B(t,`background`,Mx),B(t,`border`,`1px solid ${Nx}`),T(t,n(me,{get component(){return e.icon},size:14,color:Rx})),r(()=>R(t,`title`,e.name)),t})()})),e}}),null),T(o,n(h,{get when(){return e.creep.deleteTime},get children(){return Vx()}}),null),o})()}function Zx(e){let t=()=>e.ctx.creeps(),r=()=>(e.nav?.goToNew??Ag)(),i=t=>(e.nav?.goToCreep??jg)(t);return n(h,{get when(){return!e.loading},get fallback(){return(()=>{var e=qx();return B(e,`color`,X),e})()},get children(){return n(h,{get when(){return t().length},get fallback(){return(()=>{var t=Jx(),i=t.firstChild,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling,c=s.firstChild;return B(t,`background`,jx),B(t,`border`,`1px solid ${Nx}`),T(i,n(b,{each:lx,children:e=>n(Ax,{class:e,size:44,color:e===`operator`?Lx:Nx})})),B(a,`color`,Px),B(o,`color`,X),T(s,n(Yx,{get free(){return e.ctx.free()},onNew:r}),c),t})()},get children(){return[(()=>{var t=Gx(),i=t.firstChild;return i.nextSibling,T(t,n(Yx,{get free(){return e.ctx.free()},onNew:r}),i),t})(),(()=>{var e=Kx();return T(e,n(b,{get each(){return t()},children:e=>n(Xx,{creep:e,onSelect:i})})),e})()]}})}})}P([`click`]);var Qx=z(`<span style=font-size:10px;margin-left:4px>unlocks at Lvl `),$x=z(`<div style="border-radius:8px;padding:12px 14px;display:flex;flex-direction:column;gap:8px"><div style=display:flex;align-items:center;gap:8px><span style=font-size:12px;font-weight:600;letter-spacing:0.02em;flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis></span><span style=font-size:11px>Lv </span></div><div style=display:flex;align-items:center;gap:5px></div><div style=font-size:11px;line-height:1.4></div><div style=font-size:10px>`),eS=z(`<button style=width:14px;height:14px;border-radius:50%;padding:0;flex-shrink:0;display:flex;align-items:center;justify-content:center>`);function tS(e){let t=()=>e.stagedLevel??e.currentLevel,i=()=>Math.max(1,t()),a=()=>t()===0,o=()=>t()+1,s=n=>n<=e.currentLevel?`saved`:n<=t()?`staged`:n===o()&&e.editable?e.canIncrement?`next`:`locked`:`empty`;return(()=>{var c=$x(),l=c.firstChild,u=l.firstChild,d=u.nextSibling;d.firstChild;var f=l.nextSibling,p=f.nextSibling,m=p.nextSibling;return B(c,`background`,Mx),B(c,`border`,`1px solid ${Nx}`),T(l,n(me,{get component(){return e.def.icon},size:16,get color(){return t()>0?Rx:X}}),u),B(u,`color`,Px),T(u,()=>e.def.name),T(d,t,null),T(f,n(b,{each:[1,2,3,4,5],children:t=>{let i=()=>s(t),a=()=>i()===`next`;return(()=>{var o=eS();return o.$$click=()=>a()&&e.onIncrement?.(),T(o,n(h,{get when(){return i()===`locked`},get children(){return n(Di,{size:8,color:X})}})),r(n=>{var r=!a(),s=i()===`locked`&&e.lockLevel!=null?`Unlocks at creep Lvl ${e.lockLevel}`:a()?`Upgrade to Lv ${t}`:void 0,c=a()?`pointer`:`default`,l=i()===`saved`?Rx:i()===`staged`?Fx:`transparent`,u=i()===`next`?`1px solid ${Fx}`:i()===`locked`?`1px dashed ${Nx}`:i()===`saved`||i()===`staged`?`none`:`1px solid ${Nx}`;return r!==n.e&&(o.disabled=n.e=r),s!==n.t&&R(o,`title`,n.t=s),c!==n.a&&B(o,`cursor`,n.a=c),l!==n.o&&B(o,`background`,n.o=l),u!==n.i&&B(o,`border`,n.i=u),n},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),o})()}}),null),T(f,n(h,{get when(){return I(()=>!!(e.editable&&o()<=5&&!e.canIncrement))()&&e.lockLevel!=null},get children(){var t=Qx();return t.firstChild,B(t,`color`,X),T(t,()=>e.lockLevel,null),t}}),null),T(p,()=>yx(e.def,i())),B(m,`color`,X),T(m,()=>bx(e.def,i())),r(e=>{var n=t()>0?Px:X,r=a()?X:Px;return n!==e.e&&B(d,`color`,e.e=n),r!==e.t&&B(p,`color`,e.t=r),e},{e:void 0,t:void 0}),c})()}P([`click`]);var nS=z(`<div style=font-size:13px;margin-top:8px;line-height:1.5>`),rS=z(`<button style="padding:8px 22px;border-radius:6px;background:transparent;font-size:14px;cursor:pointer">`),iS=z(`<div style=position:fixed;inset:0;background:rgba(0,0,0,0.65);z-index:300;display:flex;align-items:center;justify-content:center><div style="border-radius:10px;padding:24px;max-width:440px;text-align:center;box-shadow:0 8px 24px rgba(0,0,0,0.5)"><div style=font-size:16px;font-weight:600;line-height:1.4></div><div style=display:flex;gap:10px;justify-content:center;margin-top:20px><button style="padding:8px 22px;border-radius:6px;border:none;color:#fff;font-size:14px;font-weight:600;cursor:pointer">`);function aS(e){o(()=>{let t=t=>{t.key===`Escape`?e.onCancel():t.key===`Enter`&&e.onConfirm()};window.addEventListener(`keydown`,t),a(()=>window.removeEventListener(`keydown`,t))});let t=t=>{t.target===t.currentTarget&&e.onCancel()};return(()=>{var r=iS(),i=r.firstChild,a=i.firstChild,o=a.nextSibling,s=o.firstChild;return r.$$click=t,B(i,`background`,jx),B(i,`border`,`1px solid ${Nx}`),B(a,`color`,Px),T(a,()=>e.title),T(i,n(h,{get when(){return e.body},get children(){var t=nS();return B(t,`color`,X),T(t,()=>e.body),t}}),o),s.$$click=()=>e.onConfirm(),B(s,`background`,Fx),T(s,()=>e.confirmLabel??(e.notice?`Close`:`Yes`)),T(o,n(h,{get when(){return!e.notice},get children(){var t=rS();return t.$$click=()=>e.onCancel(),B(t,`border`,`1px solid ${Nx}`),B(t,`color`,Px),T(t,()=>e.cancelLabel??`No`),t}}),null),r})()}P([`click`]);var oS=z(`<div style=border-radius:8px;padding:32px;text-align:center>Power creep not found. <a style=cursor:pointer>Back to list`),sS=z(`<div style=display:flex;align-items:center;gap:6px><input maxlength=50 style="padding:4px 8px;border-radius:4px;background:#0d1117;font-size:15px;outline:none"><button title="Save name"style=background:transparent;border:none;cursor:pointer></button><button title=Cancel style=background:transparent;border:none;cursor:pointer>`),cS=z(`<span> → `),lS=z(`<div style=margin-top:2px> staged`),uS=z(`<button style="background:transparent;border:1px solid #f0883e;border-radius:6px;color:#f0883e;cursor:pointer;padding:7px 10px;font-size:12px">Cancel deletion`),dS=z(`<div style="background:#21262d;border-radius:6px;padding:8px 12px;font-size:12px;color:#f0883e;margin-bottom:16px">You have reached the maximum creep level (<!>).`),fS=z(`<div><button style="display:inline-flex;align-items:center;gap:4px;padding:6px 10px;border-radius:4px;background:transparent;font-size:13px;cursor:pointer;margin-bottom:16px"> Back</button><div style="display:flex;align-items:center;gap:14px;border-radius:10px;padding:18px 20px;margin-bottom:16px"><div style=flex:1;min-width:0><div style=font-size:13px;margin-top:2px> · Level <strong></strong></div></div><div style=text-align:right;font-size:12px><div>Free GPL <strong></strong> / </div></div></div><div style="display:grid;grid-template-columns:repeat(auto-fill, minmax(220px, 1fr));gap:12px"></div><div style=display:flex;justify-content:flex-end;gap:10px;margin-top:20px><button style="padding:9px 18px;border-radius:6px;background:transparent;font-size:14px">Reset</button><button style="padding:9px 20px;border-radius:6px;border:none;font-size:14px;font-weight:600">`),pS=z(`<div style=display:flex;align-items:center;gap:8px><span style=font-size:18px;font-weight:600></span><button title=Rename style=background:transparent;border:none;cursor:pointer;padding:2px>`),mS=z(`<button title="Delete power creep"style="background:transparent;border-radius:6px;color:#f85149;cursor:pointer;padding:7px 9px;display:flex">`),hS=z(`<strong> GPL`),gS=z(`<strong>1 Power Level`);function _S(t){let i=()=>t.ctx.creeps().find(e=>e._id===t.id)??null,a=()=>i()?.className??`operator`,o=()=>(t.nav?.goToList??kg)(),s=()=>vx(a()),[c,l]=e({}),[u,d]=e(!1),[f,p]=e(!1),[m,g]=e(!1),[_,v]=e(!1),[y,x]=e(!1),[S,C]=e(!1),[w,E]=e(``),D=e=>i()?.powers?.[e]?.level??0,O=e=>c()[e]??D(e),k=()=>{let e=0;for(let t of s())e+=O(t.id)-D(t.id);return e},A=()=>(i()?.level??0)+k(),ee=()=>t.ctx.free()-k(),M=()=>k()>0,te=e=>{let t=O(e.id);return t<5&&A()<25&&ee()>=1&&A()>=e.reqLevel[t]},ne=e=>{let t=O(e.id);return t<5&&A()<e.reqLevel[t]?e.reqLevel[t]:void 0},re=e=>{if(A()>=25){x(!0);return}te(e)&&l({...c(),[e.id]:O(e.id)+1})},ie=async()=>{let e=L(),n=i();if(p(!1),!(!e||!n)){d(!0);try{let r={};for(let e of s()){let t=O(e.id);t>0&&(r[e.id]=t)}await e.http.game.powerCreeps.upgrade(n._id,r),await t.ctx.reload(),await e.stores.user.refreshMe().catch(()=>{}),l({}),j(`Power creep upgraded`,`success`,3e3)}catch(e){j(`Upgrade failed: ${e instanceof Error?e.message:String(e)}`,`error`,5e3)}finally{d(!1)}}},ae=async()=>{let e=L(),n=i(),r=w().trim();if(C(!1),!(!e||!n||!r||r===n.name))try{await e.http.game.powerCreeps.rename(n._id,r),await t.ctx.reload()}catch(e){j(`Rename failed: ${e instanceof Error?e.message:String(e)}`,`error`,5e3)}},oe=async()=>{let e=L(),n=i();if(v(!1),!(!e||!n))try{await e.http.game.powerCreeps.delete(n._id),await t.ctx.reload(),j(`Power creep "${n.name}" deleted`,`success`,3e3),o()}catch(e){j(`Delete failed: ${e instanceof Error?e.message:String(e)}`,`error`,5e3)}},N=async()=>{let e=L(),n=i();if(!(!e||!n))try{await e.http.game.powerCreeps.cancelDelete(n._id),await t.ctx.reload()}catch(e){j(`Failed to cancel deletion: ${e instanceof Error?e.message:String(e)}`,`error`,5e3)}};return n(h,{get when(){return i()},get fallback(){return(()=>{var e=oS(),t=e.firstChild.nextSibling;return B(e,`background`,jx),B(e,`border`,`1px solid ${Nx}`),B(e,`color`,X),t.$$click=o,B(t,`color`,Fx),e})()},children:e=>(()=>{var i=fS(),c=i.firstChild,d=c.firstChild,j=c.nextSibling,se=j.firstChild,P=se.firstChild,ce=P.firstChild,le=ce.nextSibling,ue=se.nextSibling,de=ue.firstChild,fe=de.firstChild.nextSibling;fe.nextSibling;var pe=j.nextSibling,me=pe.nextSibling.firstChild,he=me.nextSibling;return c.$$click=o,B(c,`border`,`1px solid ${Nx}`),B(c,`color`,X),T(c,n(Ur,{size:16}),d),B(j,`background`,jx),B(j,`border`,`1px solid ${Nx}`),T(j,n(Ax,{get class(){return a()},size:44,color:Lx}),se),T(se,n(h,{get when(){return S()},get fallback(){return(()=>{var t=pS(),r=t.firstChild,i=r.nextSibling;return B(r,`color`,Px),T(r,()=>e().name),i.$$click=()=>{E(e().name),C(!0)},B(i,`color`,X),T(i,n(Ui,{size:14})),t})()},get children(){var e=sS(),t=e.firstChild,i=t.nextSibling,a=i.nextSibling;return t.$$keydown=e=>{e.key===`Enter`&&ae(),e.key===`Escape`&&C(!1)},t.$$input=e=>E(e.currentTarget.value),B(t,`border`,`1px solid ${Nx}`),B(t,`color`,Px),i.$$click=()=>void ae(),B(i,`color`,Ix),T(i,n(zr,{size:16})),a.$$click=()=>C(!1),B(a,`color`,X),T(a,n(ya,{size:16})),r(()=>t.value=w()),e}}),P),B(P,`color`,X),T(P,()=>ux[a()].label,ce),B(le,`color`,Px),T(le,()=>e().level),T(P,n(h,{get when(){return M()},get children(){var e=cS();return e.firstChild,B(e,`color`,Fx),T(e,A,null),e}}),null),B(ue,`color`,X),T(fe,()=>Math.max(0,ee())),T(de,()=>t.ctx.gpl(),null),T(ue,n(h,{get when(){return M()},get children(){var e=lS(),t=e.firstChild;return B(e,`color`,Fx),T(e,k,t),e}}),null),T(j,n(h,{get when(){return e().deleteTime},get fallback(){return(()=>{var e=mS();return e.$$click=()=>v(!0),B(e,`border`,`1px solid ${Nx}`),T(e,n(ha,{size:16})),e})()},get children(){var e=uS();return e.$$click=()=>void N(),e}}),null),T(i,n(h,{get when(){return A()>=25},get children(){var e=dS(),t=e.firstChild.nextSibling;return t.nextSibling,B(e,`border`,`1px solid ${Nx}`),T(e,25,t),e}}),pe),T(pe,n(b,{get each(){return s()},children:e=>n(tS,{def:e,get currentLevel(){return D(e.id)},get stagedLevel(){return O(e.id)},editable:!0,get canIncrement(){return te(e)},get lockLevel(){return ne(e)},onIncrement:()=>re(e)})})),me.$$click=()=>g(!0),B(me,`border`,`1px solid ${Nx}`),he.$$click=()=>p(!0),T(he,()=>u()?`Saving…`:`Save changes`),T(i,n(h,{get when(){return f()},get children(){return n(aS,{title:`This action cannot be undone without deleting the creep.`,get body(){return[`Do you want to proceed and use `,(()=>{var e=hS(),t=e.firstChild;return B(e,`color`,Lx),T(e,()=>A()+1,t),e})(),` for this creep?`]},onConfirm:()=>void ie(),onCancel:()=>p(!1)})}}),null),T(i,n(h,{get when(){return m()},get children(){return n(aS,{title:`Do you really want to reset all changes?`,onConfirm:()=>{l({}),g(!1)},onCancel:()=>g(!1)})}}),null),T(i,n(h,{get when(){return _()},get children(){return n(aS,{get title(){return`Do you really want to delete "${e().name}"?`},get body(){return[`You will lose `,(()=>{var e=gS();return B(e,`color`,Rx),e})(),` in your account. The creep's upgrade levels are returned, but the creation level is gone for good.`]},confirmLabel:`Delete`,onConfirm:()=>void oe(),onCancel:()=>v(!1)})}}),null),T(i,n(h,{get when(){return y()},get children(){return n(aS,{title:`You have reached the maximum creep level`,notice:!0,onConfirm:()=>x(!1),onCancel:()=>x(!1)})}}),null),r(e=>{var t=ee()>0?Lx:X,n=!M()||u(),r=M()?Px:X,i=M()?`pointer`:`not-allowed`,a=M()?1:.6,o=!M()||u(),s=M()?Ix:`#21262d`,c=M()?`#fff`:X,l=M()?`pointer`:`not-allowed`,d=M()?1:.7;return t!==e.e&&B(fe,`color`,e.e=t),n!==e.t&&(me.disabled=e.t=n),r!==e.a&&B(me,`color`,e.a=r),i!==e.o&&B(me,`cursor`,e.o=i),a!==e.i&&B(me,`opacity`,e.i=a),o!==e.n&&(he.disabled=e.n=o),s!==e.s&&B(he,`background`,e.s=s),c!==e.h&&B(he,`color`,e.h=c),l!==e.r&&B(he,`cursor`,e.r=l),d!==e.d&&B(he,`opacity`,e.d=d),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0}),i})()})}P([`click`,`input`,`keydown`]);var vS=z(`<span style=color:#f0883e> (Under development)`),yS=z(`<div style=font-size:11px;text-transform:uppercase;letter-spacing:0.06em;font-weight:700;margin-bottom:12px> powers`),bS=z(`<div style="display:grid;grid-template-columns:repeat(auto-fill, minmax(220px, 1fr));gap:12px">`),xS=z(`<div><div style=display:flex;align-items:center;justify-content:space-between;margin-bottom:20px><button style="display:inline-flex;align-items:center;gap:4px;padding:6px 10px;border-radius:4px;background:transparent;font-size:13px;cursor:pointer"> Back</button><span style=font-size:13px>Creating a power creep uses <strong>1</strong> free Power Level</span></div><div style=border-radius:10px;padding:24px><label style=display:block;font-size:11px;text-transform:uppercase;letter-spacing:0.06em;font-weight:700;margin-bottom:8px>Creep name</label><input placeholder="Enter creep name"maxlength=50 style="width:100%;box-sizing:border-box;padding:9px 12px;border-radius:6px;background:#0d1117;font-size:14px;outline:none;margin-bottom:24px"><div style=font-size:11px;text-transform:uppercase;letter-spacing:0.06em;font-weight:700;margin-bottom:10px>Select class</div><div style=display:flex;gap:12px;margin-bottom:14px></div><p style="font-size:13px;line-height:1.5;margin:0 0 24px"></p></div><div style=display:flex;justify-content:flex-end;margin-top:16px><button style="padding:9px 20px;border-radius:6px;border:none;font-size:14px;font-weight:600">`),SS=z(`<span style=font-size:10px;color:#f0883e>Under development`),CS=z(`<button style="flex:1;display:flex;flex-direction:column;align-items:center;gap:8px;padding:16px 8px;border-radius:8px;cursor:pointer"><span style=font-size:13px;font-weight:600>`),wS=z(`<div style="font-size:13px;text-align:center;padding:24px 0">This class has no powers available yet.`);function TS(t){let[i,a]=e(``),[o,s]=e(`operator`),[c,l]=e(!1),u=()=>ux[o()],d=()=>!c()&&t.ctx.free()>=1&&i().trim().length>0&&!u().underDevelopment,f=()=>(t.nav?.goToList??kg)(),p=async()=>{let e=L();if(!e||!d())return;let n=i().trim();l(!0);try{await e.http.game.powerCreeps.create(n,o()),await t.ctx.reload();let r=t.ctx.creeps().find(e=>e.name===n);j(`Power creep "${n}" created`,`success`,3e3),r?(t.nav?.goToCreep??jg)(r._id):f()}catch(e){j(`Failed to create power creep: ${e instanceof Error?e.message:String(e)}`,`error`,5e3)}finally{l(!1)}};return(()=>{var e=xS(),l=e.firstChild,m=l.firstChild,g=m.firstChild,_=m.nextSibling,v=_.firstChild.nextSibling,y=l.nextSibling,x=y.firstChild,S=x.nextSibling,C=S.nextSibling,w=C.nextSibling,E=w.nextSibling,D=y.nextSibling.firstChild;return m.$$click=f,B(m,`border`,`1px solid ${Nx}`),B(m,`color`,X),T(m,n(Ur,{size:16}),g),B(_,`color`,X),B(v,`color`,Lx),B(y,`background`,jx),B(y,`border`,`1px solid ${Nx}`),B(x,`color`,X),S.$$input=e=>a(e.currentTarget.value),B(S,`border`,`1px solid ${Nx}`),B(S,`color`,Px),B(C,`color`,X),T(w,n(b,{each:lx,children:e=>{let t=ux[e],i=()=>o()===e;return(()=>{var a=CS(),o=a.firstChild;return a.$$click=()=>s(e),T(a,n(Ax,{class:e,size:36,get color(){return i()?Lx:X}}),o),T(o,()=>t.label),T(a,n(h,{get when(){return t.underDevelopment},get children(){return SS()}}),null),r(e=>{var t=`1px solid ${i()?Fx:Nx}`,n=i()?`#1c2d47`:Mx,r=i()?Px:X;return t!==e.e&&B(a,`border`,e.e=t),n!==e.t&&B(a,`background`,e.t=n),r!==e.a&&B(a,`color`,e.a=r),e},{e:void 0,t:void 0,a:void 0}),a})()}})),B(E,`color`,X),T(E,()=>u().description,null),T(E,n(h,{get when(){return u().underDevelopment},get children(){return vS()}}),null),T(y,n(h,{get when(){return!u().underDevelopment},get fallback(){return(()=>{var e=wS();return B(e,`color`,X),e})()},get children(){return[(()=>{var e=yS(),t=e.firstChild;return B(e,`color`,X),T(e,()=>u().label,t),e})(),(()=>{var e=bS();return T(e,n(b,{get each(){return vx(o())},children:e=>n(tS,{def:e,currentLevel:0})})),e})()]}}),null),D.$$click=p,T(D,()=>c()?`Creating…`:`Create creep`),r(e=>{var n=!d(),r=t.ctx.free()<1?`You need 1 free Power Level`:void 0,i=d()?Ix:`#21262d`,a=d()?`#fff`:X,o=d()?`pointer`:`not-allowed`,s=d()?1:.7;return n!==e.e&&(D.disabled=e.e=n),r!==e.t&&R(D,`title`,e.t=r),i!==e.a&&B(D,`background`,e.a=i),a!==e.o&&B(D,`color`,e.o=a),o!==e.i&&B(D,`cursor`,e.i=o),s!==e.n&&B(D,`opacity`,e.n=s),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),r(()=>S.value=i()),e})()}P([`click`,`input`]);var ES=z(`<button title=Messages style="display:flex;align-items:center;padding:7px;border-radius:4px;cursor:pointer;border:1px solid #30363d;background:#21262d;color:#c9d1d9">`),DS=z(`<div style="display:flex;align-items:center;gap:10px;padding:0 0 14px;border-bottom:1px solid #30363d;margin-bottom:24px"><h1 style=margin:0;font-size:22px;font-weight:600;color:#c9d1d9></h1><div style=flex:1></div><button style=display:flex;align-items:center;padding:7px;border-radius:4px;cursor:pointer></button><button title=Close style="display:flex;align-items:center;padding:7px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#c9d1d9;cursor:pointer">`),OS=z(`<div style=display:flex;gap:16px;margin-bottom:16px><div><div><div style=font-size:16px;font-weight:600;color:#c9d1d9;margin-bottom:6px>Global Control Level</div><div style=color:#8b949e;font-size:13px><span>Rooms: <strong style=color:#c9d1d9></strong></span><span style=margin-left:14px>CPU: <strong style=color:#c9d1d9></strong></span></div></div></div><div><div><div style=font-size:16px;font-weight:600;color:#c9d1d9;margin-bottom:8px>Global Power Level</div><button title="Manage your power creeps"style="padding:5px 10px;border-radius:4px;border:1px solid #C54444;background:#21262d;color:#ffb7ba;font-size:12px;cursor:pointer">Manage Power Creeps`),kS=z(`<div style=margin-top:24px><div style=color:#8b949e;font-size:11px;text-transform:uppercase;margin-bottom:12px>Rooms`),AS=z(`<div style=color:#c9d1d9;font-size:13px;font-weight:600;margin-bottom:10px>`),jS=z(`<div style=margin-bottom:20px><div style=display:flex;flex-wrap:wrap;gap:16px>`),MS=6e4,NS=8,PS=`#161b22`,FS=`#30363d`,IS=`#c9d1d9`,LS=`#8b949e`;function RS(){let[t,i]=e(null),[s,c]=e([]),l=!1;p(()=>{let e=L(),t=H()?._id;!e||!t||l||(l=!0,e.http.user.rooms(t).then(e=>c(tx(e))).catch(()=>{l=!1}))}),o(()=>{let e=L();if(!e)return;let t=null,n=()=>e.http.user.overview(NS,`energyHarvested`).then(e=>i(e.totals??null));n().then(()=>{t=setInterval(()=>{e.stores.user.refreshMe().catch(()=>{}),n().catch(()=>{})},MS)}).catch(()=>{}),a(()=>{t&&clearInterval(t)})});let u=()=>ox(H()?.gcl??0),d=()=>cx(H()?.power??0),f=e=>e.total>0?e.current/e.total:0,m=e=>`Next level: ${Math.floor(e.current).toLocaleString()} / ${Math.floor(e.total).toLocaleString()}`,g={flex:1,display:`flex`,"align-items":`center`,gap:`16px`,background:PS,border:`1px solid ${FS}`,"border-radius":`6px`,padding:`16px`},[_,v]=e([]),[y,x]=e(!1),w=async()=>{let e=L();if(!e)return;let t=await e.http.game.powerCreeps.list();v(t.list??[])};p(()=>{ig()===`power`&&(x(!0),w().finally(()=>x(!1)),L()?.stores.user.refreshMe().catch(()=>{}))});let E=()=>ig()===`power`?Eg():kg(),D=()=>{let e=new Map;for(let t of s()){let n=e.get(t.shard);n?n.push(t):e.set(t.shard,[t])}return[...e.entries()].sort(([e],[t])=>(e??``).localeCompare(t??``))},O={creeps:_,free:()=>Sx(H()?.power,_()),gpl:()=>sx(H()?.power??0),reload:w},k={goToList:kg,goToNew:Ag,goToCreep:jg},A=()=>ig()===`power`?`Power Creeps`:`Overview`;return n(qy,{get children(){return[(()=>{var e=DS(),t=e.firstChild,i=t.nextSibling,a=i.nextSibling,o=a.nextSibling;return T(e,n(Bb,{get badge(){return H()?.badge},size:28}),t),T(t,A),T(e,n(Ug,{get username(){return H()?.username},color:LS,style:{"font-size":`14px`}}),i),T(e,n(h,{get when(){return Mb().hasMessaging},get children(){var e=ES();return ge(e,`click`,Dg,!0),T(e,n(Ni,{size:16})),e}}),a),a.$$click=E,T(a,n(Ca,{size:16})),ge(o,`click`,zg,!0),T(o,n(ya,{size:16})),r(e=>{var t=ig()===`power`?`Back to Overview`:`Manage Power Creeps`,n=ig()===`power`?`1px solid #C54444`:`1px solid ${FS}`,r=ig()===`power`?`#2d1a1a`:`#21262d`,i=ig()===`power`?`#ffb7ba`:IS;return t!==e.e&&R(a,`title`,e.e=t),n!==e.t&&B(a,`border`,e.t=n),r!==e.a&&B(a,`background`,e.a=r),i!==e.o&&B(a,`color`,e.o=i),e},{e:void 0,t:void 0,a:void 0,o:void 0}),e})(),n(S,{get children(){return[n(C,{get when(){return ig()===`power`},get children(){return n(S,{get children(){return[n(C,{get when(){return vg()===`list`},get children(){return n(Zx,{ctx:O,get loading(){return y()},nav:k})}}),n(C,{get when(){return vg()===`new`},get children(){return n(TS,{ctx:O,nav:k})}}),n(C,{get when(){return vg()===`detail`},get children(){return n(_S,{ctx:O,get id(){return bg()},nav:k})}})]}})}}),n(C,{get when(){return ig()===`overview`},get children(){return[(()=>{var e=OS(),t=e.firstChild,i=t.firstChild,a=i.firstChild.nextSibling.firstChild,o=a.firstChild.nextSibling,s=a.nextSibling.firstChild.nextSibling,c=t.nextSibling,l=c.firstChild,p=l.firstChild.nextSibling;return T(t,n(Rb,{get value(){return u().level},label:`GCL`,ring:Pb,text:Fb,get fraction(){return f(u())},get tooltip(){return m(u())}}),i),T(o,()=>u().level),T(s,()=>H()?.cpu??`—`),T(c,n(Rb,{get value(){return d().level},label:`GPL`,ring:Ib,text:Lb,get fraction(){return f(d())},get tooltip(){return m(d())}}),l),p.$$click=E,r(e=>{var n=g,r=g;return e.e=F(t,n,e.e),e.t=F(c,r,e.t),e},{e:void 0,t:void 0}),e})(),n(ex,{get totals(){return t()}}),n(h,{get when(){return s().length},get children(){var e=kS();return e.firstChild,T(e,n(b,{get each(){return D()},children:([e,t])=>(()=>{var r=jS(),i=r.firstChild;return T(r,n(h,{when:e,get children(){var t=AS();return T(t,e),t}}),i),T(i,n(b,{each:t,children:e=>n(qb,{get room(){return e.room},get shard(){return e.shard},onClick:()=>Bg(e.room,e.shard),onOverview:()=>Rg(e.room,e.shard)})})),r})()}),null),e}})]}})]}})]}})}P([`click`]);var zS=z(`<div style="display:flex;align-items:baseline;gap:6px;flex-shrink:0;padding:5px 12px;border-radius:8px"><span style=font-size:11px;font-weight:600;letter-spacing:0.5px></span><span style=font-size:18px;font-weight:700;line-height:1>`),BS=z(`<div style="flex:1;min-width:0;background:#161b22;border-radius:6px;padding:12px 8px;text-align:center"><div style=font-size:11px;text-transform:uppercase;line-height:1.3><br></div><div style=font-size:22px;font-weight:300;margin-top:8px>`),VS=z(`<div style=color:#8b949e;text-align:center;padding:60px>Loading…`),HS=z(`<div style=text-align:center;padding:60px><div style=color:#8b949e;font-size:18px;margin-bottom:16px>User not found</div><button style="padding:7px 12px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#c9d1d9;cursor:pointer">Back to the world`),US=z(`<span title="Your account overview"style=color:#8b949e;cursor:pointer;font-size:13px>Overview`),WS=z(`<button style="display:flex;align-items:center;gap:6px;padding:7px 12px;border-radius:4px;border:1px solid #388bfd;background:#1f3158;color:#58a6ff;cursor:pointer;font-size:13px;margin-left:6px"> Message`),GS=z(`<div style="display:flex;align-items:center;gap:10px;padding:0 0 14px;border-bottom:1px solid #30363d;margin-bottom:24px"><h1 style=margin:0;font-size:22px;font-weight:600;color:#c9d1d9></h1><div style=flex:1></div><button title=Close style="display:flex;align-items:center;padding:7px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#c9d1d9;cursor:pointer;margin-left:6px">`),KS=z(`<div style=color:#8b949e;font-size:11px;text-transform:uppercase;margin-bottom:10px>Current month`),qS=z(`<div style=display:flex;gap:10px;margin-bottom:24px>`),JS=z(`<select style="padding:4px 8px;border-radius:4px;border:1px solid #30363d;background:#161b22;color:#8b949e;font-size:11px;text-transform:uppercase;cursor:pointer;margin-bottom:10px">`),YS=z(`<div style=margin-top:24px><div style=color:#8b949e;font-size:11px;text-transform:uppercase;margin-bottom:12px>Rooms</div><div style=display:flex;flex-wrap:wrap;gap:16px>`),XS=z(`<option>`),ZS=`#8b949e`,QS=`#d9b54a`,$S=`#C54444`,eC=[{value:8,label:`Last 1 hour`},{value:180,label:`Last 24 hours`},{value:1440,label:`Last 7 days`}];function tC(){let e=new Date;return`${e.getUTCFullYear()}-${String(e.getUTCMonth()+1).padStart(2,`0`)}`}function nC(e){let t=e?.list?.[0]??e;return{rank:typeof t?.rank==`number`?t.rank:null,score:typeof t?.score==`number`?t.score:0}}var rC=e=>e==null?`—`:`#${(e+1).toLocaleString()}`,iC=e=>e.toLocaleString();function aC(e){return(()=>{var t=zS(),n=t.firstChild,i=n.nextSibling;return T(n,()=>e.label),T(i,()=>e.value),r(r=>{var a=e.tooltip,o=`2px solid ${e.border}`,s=e.color,c=e.color;return a!==r.e&&R(t,`title`,r.e=a),o!==r.t&&B(t,`border`,r.t=o),s!==r.a&&B(n,`color`,r.a=s),c!==r.o&&B(i,`color`,r.o=c),r},{e:void 0,t:void 0,a:void 0,o:void 0}),t})()}function oC(e){return(()=>{var t=BS(),n=t.firstChild,i=n.firstChild,a=n.nextSibling;return T(n,()=>e.l1,i),T(n,()=>e.l2,null),T(a,()=>e.value),r(r=>{var i=`1px solid ${e.accent}`,o=e.accent,s=e.accent;return i!==r.e&&B(t,`border`,r.e=i),o!==r.t&&B(n,`color`,r.t=o),s!==r.a&&B(a,`color`,r.a=s),r},{e:void 0,t:void 0,a:void 0}),t})()}function sC(){let[t]=l(()=>og(),async e=>{let t=L();if(!t)return null;try{return(await t.http.user.find({username:e})).user??null}catch{return null}}),i=()=>t()?._id,[a]=l(i,async e=>{let t=L();if(!t)return[];try{return tx(await t.http.user.rooms(e))}catch{return[]}}),[o,s]=e(1440),[c]=l(()=>{let e=i();return e?{id:e,interval:o()}:null},async({id:e,interval:t})=>{let n=L();if(!n)return null;try{return $b(await n.http.user.stats(t,e))}catch{return null}}),[u]=l(()=>t()?t().username:void 0,async e=>{let t=L();if(!t)return null;let n=tC(),[r,i]=await Promise.all([t.http.leaderboard.find(e,`world`,n).catch(()=>null),t.http.leaderboard.find(e,`power`,n).catch(()=>null)]);return{world:nC(r),power:nC(i)}}),d=()=>{let e=H()?.username?.toLowerCase(),n=t()?.username?.toLowerCase();return!!e&&e===n},f=()=>ox(t()?.gcl??0),p=()=>cx(t()?.power??0),m=e=>`Next level: ${Math.floor(e.current).toLocaleString()} / ${Math.floor(e.total).toLocaleString()}`;return n(qy,{get children(){return n(h,{get when(){return!t.loading},get fallback(){return VS()},get children(){return n(h,{get when(){return t()},get fallback(){return(()=>{var e=HS(),t=e.firstChild.nextSibling;return ge(t,`click`,zg,!0),e})()},children:e=>[(()=>{var t=GS(),i=t.firstChild,a=i.nextSibling,o=a.nextSibling;return T(t,n(Bb,{get badge(){return e().badge},size:28}),i),T(i,()=>e().username),T(t,n(h,{get when(){return d()},get children(){var e=US();return e.addEventListener(`mouseleave`,e=>e.currentTarget.style.color=ZS),e.addEventListener(`mouseenter`,e=>e.currentTarget.style.color=`#58a6ff`),ge(e,`click`,Eg,!0),e}}),a),T(t,n(aC,{label:`GCL`,get value(){return f().level},color:Fb,border:Pb,get tooltip(){return m(f())}}),o),T(t,n(aC,{label:`GPL`,get value(){return p().level},color:Lb,border:Ib,get tooltip(){return m(p())}}),o),T(t,n(h,{get when(){return I(()=>!d())()&&Mb().hasMessaging},get children(){var t=WS(),i=t.firstChild;return t.$$click=()=>Og(e().username),T(t,n(Ni,{size:14}),i),r(()=>R(t,`title`,`Message ${e().username}`)),t}}),o),ge(o,`click`,zg,!0),T(o,n(ya,{size:16})),t})(),KS(),(()=>{var e=qS();return T(e,n(oC,{l1:`Expansion`,l2:`rank`,accent:QS,get value(){return rC(u()?.world.rank??null)}}),null),T(e,n(oC,{l1:`Control`,l2:`points`,accent:QS,get value(){return iC(u()?.world.score??0)}}),null),T(e,n(oC,{l1:`Power`,l2:`rank`,accent:$S,get value(){return rC(u()?.power.rank??null)}}),null),T(e,n(oC,{l1:`Power`,l2:`points`,accent:$S,get value(){return iC(u()?.power.score??0)}}),null),e})(),(()=>{var e=JS();return e.addEventListener(`change`,e=>s(Number(e.currentTarget.value))),T(e,n(b,{each:eC,children:e=>(()=>{var t=XS();return T(t,()=>e.label),r(()=>t.value=e.value),t})()})),r(()=>e.value=o()),e})(),n(ex,{get totals(){return c()}}),n(h,{get when(){return a()?.length},get children(){var t=YS(),r=t.firstChild.nextSibling;return T(r,n(b,{get each(){return a()},children:t=>n(qb,{get room(){return t.room},get shard(){return t.shard},get ownerId(){return e()._id},onClick:()=>Bg(t.room,t.shard),onOverview:()=>Rg(t.room,t.shard)})})),t}})]})}})}})}P([`click`]);var cC=z(`<div style="display:flex;align-items:center;border-top:1px solid #30363d;padding:10px 0"><div style=width:190px;flex-shrink:0;color:#c9d1d9;font-size:13px></div><div style=display:flex;flex:1;min-width:0;align-items:center>`),lC=z(`<div style=flex:1;min-width:0;display:flex;justify-content:center;align-items:center;height:16px><div style=border-radius:50%>`),uC=z(`<span style=color:#8b949e;font-size:15px;font-weight:400;margin-left:10px>`),dC=z(`<div style="display:flex;align-items:center;gap:18px;background:#161b22;border:1px solid #30363d;border-radius:8px;padding:16px 20px;margin-bottom:20px"><button title=Back style="display:flex;align-items:center;justify-content:center;width:38px;height:38px;flex-shrink:0;border-radius:50%;border:1px solid #30363d;background:#21262d;color:#c9d1d9;cursor:pointer"></button><div style=flex:1;min-width:0><h1 style=margin:0;font-size:26px;font-weight:600;color:#d9b54a>Room `),fC=z(`<div style="background:#161b22;border:1px solid #30363d;border-radius:8px;padding:16px 20px;margin-top:20px"><div style=display:flex;align-items:center;margin-bottom:4px><h2 style=margin:0;font-size:18px;font-weight:600;color:#d9b54a>Graph</h2><div style=flex:1></div><select style="padding:4px 8px;border-radius:4px;border:1px solid #30363d;background:#161b22;color:#8b949e;font-size:12px;cursor:pointer">`),pC=z(`<div style=color:#8b949e;font-size:14px;margin-top:6px>Unclaimed room`),mC=z(`<div style=display:flex;align-items:center;gap:8px;margin-top:6px;color:#8b949e;font-size:14px><span>Owner:`),hC=z(`<option>`),gC=z(`<div style=color:#8b949e;text-align:center;padding:40px>Loading…`),_C=[{value:8,label:`1 hour`,unit:`m`},{value:180,label:`24 hours`,unit:`h`},{value:1440,label:`7 days`,unit:`d`}],vC=[{key:`energyHarvested`,label:`Energy harvested`,color:`#ffe56d`},{key:`energyConstruction`,label:`Construction points`,color:`#eeeeee`},{key:`energyControl`,label:`Control points`,color:`#A7FFEB`},{key:`energyCreeps`,label:`Energy spent on creeps`,color:`#eeeeee`},{key:`creepsProduced`,label:`Creeps produced`,color:`#65fd62`},{key:`creepsLost`,label:`Creeps lost`,color:`#f96e76`}],yC=e=>_C.find(t=>t.value===e)?.unit??`d`;function bC(e,t,n){let r=t-1-e;return r===0?`0`:`-${r}${n}`}function xC(e){let t=()=>e.buckets.reduce((e,t)=>Math.max(e,t.value??0),0),i=()=>e.buckets.length;return(()=>{var a=cC(),o=a.firstChild,s=o.nextSibling;return T(o,()=>e.label),T(s,n(b,{get each(){return e.buckets},children:(n,a)=>{let o=t(),s=o>0&&n.value>0?Math.max(.18,n.value/o):.07,c=n.value>0?7:3;return(()=>{var t=lC(),o=t.firstChild;return B(o,`width`,`${c}px`),B(o,`height`,`${c}px`),r(r=>{var c=`${bC(a(),i(),e.unit)}: ${Jb(n.value)}`,l=e.color,u=String(s);return c!==r.e&&R(t,`title`,r.e=c),l!==r.t&&B(o,`background`,r.t=l),u!==r.a&&B(o,`opacity`,r.a=u),r},{e:void 0,t:void 0,a:void 0}),t})()}})),a})()}function SC(){let[t,i]=e(1440),[a]=l(()=>{let e=Sg();return e?{room:e.room,shard:e.shard,interval:t()}:null},async({room:e,shard:t,interval:n})=>{let r=L();if(!r)return null;try{return await r.http.game.roomOverview(e,n,t)}catch{return null}}),[o]=l(()=>a()?.owner?.username??null,async e=>{let t=L();if(t)try{return(await t.http.user.find({username:e}))?.user?._id}catch{return}}),s=()=>Sg()?.room??``,c=()=>Sg()?.shard??null,u=()=>$b({ok:1,stats:a()?.stats}),d=e=>a()?.stats?.[e]??[];return n(qy,{get children(){return[(()=>{var e=dC(),t=e.firstChild,r=t.nextSibling,i=r.firstChild;return i.firstChild,ge(t,`click`,zg,!0),T(t,n(Ur,{size:20})),T(i,s,null),T(i,n(h,{get when(){return c()},get children(){var e=uC();return T(e,c),e}}),null),T(r,n(h,{get when(){return a()?.owner},get fallback(){return pC()},children:e=>(()=>{var t=mC();return t.firstChild,T(t,n(Bb,{get badge(){return e().badge},size:18}),null),T(t,n(Ug,{get username(){return e().username},color:`#58a6ff`}),null),t})()}),null),T(e,n(qb,{get room(){return s()},get shard(){return c()},get ownerId(){return o()},showLabel:!1,onClick:()=>Bg(s(),c())}),null),e})(),n(ex,{get totals(){return u()}}),(()=>{var e=fC(),o=e.firstChild.firstChild.nextSibling.nextSibling;return o.addEventListener(`change`,e=>i(Number(e.currentTarget.value))),T(o,n(b,{each:_C,children:e=>(()=>{var t=hC();return T(t,()=>e.label),r(()=>t.value=e.value),t})()})),T(e,n(h,{get when(){return!a.loading},get fallback(){return gC()},get children(){return n(b,{each:vC,children:e=>n(xC,{get label(){return e.label},get color(){return e.color},get buckets(){return d(e.key)},get unit(){return yC(t())}})})}}),null),r(()=>o.value=t()),e})()]}})}P([`click`]);var CC=z(`<div style="color:#8b949e;padding:24px 0;text-align:center">Loading…`),wC=z(`<div style="color:#f85149;padding:24px 0">Failed to load messages.`),TC=z(`<div style=display:flex;flex-direction:column;gap:2px>`),EC=z(`<div>`),DC=z(`<div style="color:#8b949e;padding:32px 0;text-align:center">No messages yet. You can send a message from another player's profile page.`),OC=z(`<span style=font-style:italic>You: `),kC=z(`<div style=width:8px;height:8px;border-radius:50%;background:#388bfd;flex-shrink:0>`),AC=z(`<div role=button tabindex=0 style=display:flex;align-items:center;gap:12px;padding:12px;border-radius:6px;cursor:pointer><div style=flex:1;min-width:0><div style=display:flex;align-items:baseline;gap:8px;margin-bottom:2px><span style=color:#c9d1d9></span><span style=color:#8b949e;font-size:12px;margin-left:auto;flex-shrink:0></span></div><div style=color:#8b949e;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis>`),jC=z(`<div style="color:#8b949e;padding:24px 0;text-align:center">No messages yet.`),MC=z(`<div style=display:flex;flex-direction:column;gap:12px;margin-bottom:24px>`),NC=z(`<div style=display:flex;flex-direction:column;gap:0><div style=display:flex;align-items:center;gap:8px;margin-bottom:16px><button title="Back to inbox"style="display:flex;align-items:center;gap:4px;padding:5px 10px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#c9d1d9;cursor:pointer;font-size:13px"> Inbox</button><h2 style=margin:0;font-size:16px;font-weight:600;color:#c9d1d9></h2><button title="View profile"style="display:flex;align-items:center;gap:4px;padding:5px 10px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#c9d1d9;cursor:pointer;font-size:13px;margin-left:auto">Profile </button></div><div style="border-top:1px solid #30363d;padding-top:12px"><textarea placeholder="Write a message… (Ctrl+Enter to send)"rows=3 style="width:100%;background:#161b22;border:1px solid #30363d;border-radius:6px;color:#c9d1d9;padding:8px 12px;font-size:14px;resize:vertical;box-sizing:border-box;font-family:inherit;outline:none"></textarea><div style=display:flex;align-items:center;gap:8px;margin-top:8px;justify-content:flex-end><span style=color:#8b949e;font-size:12px>Markdown supported · Ctrl+Enter to send</span><button style="display:flex;align-items:center;gap:6px;padding:7px 14px;border-radius:4px;border:none;font-size:14px"> Send`),PC=z(`<div style=display:flex;gap:10px;align-items:flex-start><div style=flex-shrink:0;margin-top:2px></div><div style=flex:1;min-width:0><div style="border-radius:6px;padding:8px 12px;color:#c9d1d9;font-size:14px;white-space:pre-wrap;word-break:break-word"></div><div style=color:#8b949e;font-size:11px;margin-top:4px>`),FC=z(`<div style="width:24px;height:24px;background:#161b22;border-radius:3px;border:1px solid #30363d">`),IC=z(`<div style="display:flex;align-items:center;gap:10px;padding:0 0 14px;border-bottom:1px solid #30363d;margin-bottom:24px"><h1 style=margin:0;font-size:22px;font-weight:600;color:#c9d1d9>Messages</h1><div style=flex:1></div><button title=Close style="display:flex;align-items:center;padding:7px;border-radius:4px;border:1px solid #30363d;background:#21262d;color:#c9d1d9;cursor:pointer">`),LC=z(`<div style="color:#8b949e;padding:32px 0;text-align:center">User not found. <span style=color:#58a6ff;cursor:pointer>Back to inbox`),RC=`#30363d`,zC=`#8b949e`,BC=`#161b22`;function VC(e){let t=new Date(e),n=Date.now()-t.getTime();return n<6e4?`Just now`:n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:n<7*864e5?`${Math.floor(n/864e5)}d ago`:t.toLocaleDateString()}function HC(e,t){return e.length>t?e.slice(0,t)+`…`:e}function UC(e){let[t]=l(()=>L(),e=>e.http.user.messages.index());return(()=>{var i=EC();return T(i,n(h,{get when(){return t.loading},get children(){return CC()}}),null),T(i,n(h,{get when(){return t.error},get children(){return wC()}}),null),T(i,n(h,{get when(){return I(()=>!t.loading)()&&t()},get children(){return n(h,{get when(){return(t()?.messages?.length??0)>0},get fallback(){return DC()},get children(){var i=TC();return T(i,n(b,{get each(){return t().messages},children:i=>{let a=()=>t().users[i._id],o=()=>i.message.type===`in`&&i.message.unread;return(()=>{var t=AC(),s=t.firstChild,c=s.firstChild,l=c.firstChild,u=l.nextSibling,d=c.nextSibling;return t.$$keydown=t=>t.key===`Enter`&&e.onSelect({username:a()?.username??i._id,id:i._id}),t.$$click=()=>e.onSelect({username:a()?.username??i._id,id:i._id}),T(t,n(Bb,{get badge(){return a()?.badge},size:32}),s),T(l,()=>a()?.username??i._id),T(u,()=>VC(i.message.date)),T(d,n(h,{get when(){return i.message.type===`out`},get children(){return OC()}}),null),T(d,()=>HC(i.message.text,120),null),T(t,n(h,{get when(){return o()},get children(){return kC()}}),null),r(e=>{var n=`1px solid ${o()?`#388bfd`:RC}`,r=o()?`#0d1b2e`:`transparent`,i=o()?600:400;return n!==e.e&&B(t,`border`,e.e=n),r!==e.t&&B(t,`background`,e.t=r),i!==e.a&&B(l,`font-weight`,e.a=i),e},{e:void 0,t:void 0,a:void 0}),t})()}})),i}})}}),null),i})()}function WC(t){let[i,a]=e([]),[o,s]=e(!0),[c,l]=e(``),[u,d]=e(!1);p(()=>{let e=L();e&&(s(!0),e.http.user.messages.list(t.respondent.id).then(e=>a(e.messages??[])).finally(()=>s(!1)))});let f=async()=>{let e=L(),n=c().trim();if(!(!e||!n||u())){d(!0);try{await e.http.user.messages.send(t.respondent.id,n),l(``);let r=await e.http.user.messages.list(t.respondent.id);a(r.messages??[])}finally{d(!1)}}};return(()=>{var e=NC(),a=e.firstChild,s=a.firstChild,d=s.firstChild,p=s.nextSibling,m=p.nextSibling;m.firstChild;var g=a.nextSibling,_=g.firstChild,v=_.nextSibling.firstChild.nextSibling,y=v.firstChild;return s.$$click=()=>t.onBack(),T(s,n(Ur,{size:14}),d),T(p,()=>t.respondent.username),m.$$click=()=>Mg(t.respondent.username),T(m,n(si,{size:12}),null),T(e,n(h,{get when(){return o()},get children(){return CC()}}),g),T(e,n(h,{get when(){return I(()=>!o())()&&i().length===0},get children(){return jC()}}),g),T(e,n(h,{get when(){return!o()},get children(){var e=MC();return T(e,n(b,{get each(){return i()},children:e=>{let t=()=>e.type===`out`;return(()=>{var i=PC(),a=i.firstChild,o=a.nextSibling.firstChild,s=o.nextSibling;return T(a,n(h,{get when(){return t()},get fallback(){return FC()},get children(){return n(Bb,{get badge(){return H()?.badge},size:24})}})),T(o,()=>e.text),T(s,()=>VC(e.date)),r(e=>{var n=t()?`#1f3158`:BC,r=`1px solid ${t()?`#388bfd33`:RC}`,i=t()?`right`:`left`;return n!==e.e&&B(o,`background`,e.e=n),r!==e.t&&B(o,`border`,e.t=r),i!==e.a&&B(s,`text-align`,e.a=i),e},{e:void 0,t:void 0,a:void 0}),i})()}})),e}}),g),_.$$keydown=e=>{(e.ctrlKey||e.metaKey)&&e.key===`Enter`&&(e.preventDefault(),f())},_.$$input=e=>l(e.currentTarget.value),v.$$click=()=>void f(),T(v,n(ta,{size:14}),y),r(e=>{var t=!c().trim()||u(),n=!c().trim()||u()?`#21262d`:`#238636`,r=!c().trim()||u()?zC:`#fff`,i=!c().trim()||u()?`default`:`pointer`;return t!==e.e&&(v.disabled=e.e=t),n!==e.t&&B(v,`background`,e.t=n),r!==e.a&&B(v,`color`,e.a=r),i!==e.o&&B(v,`cursor`,e.o=i),e},{e:void 0,t:void 0,a:void 0,o:void 0}),r(()=>_.value=c()),e})()}function GC(){let[e]=l(()=>cg(),async e=>{let t=L();if(!t)return null;try{let n=await t.http.user.find({username:e});return n.user?{username:n.user.username,id:n.user._id}:null}catch{return null}});return n(qy,{maxWidth:`720px`,get children(){return[(()=>{var e=IC(),t=e.firstChild,r=t.nextSibling,i=r.nextSibling;return T(e,n(Bb,{get badge(){return H()?.badge},size:28}),t),T(e,n(Ug,{get username(){return H()?.username},color:zC,style:{"font-size":`14px`}}),r),ge(i,`click`,zg,!0),T(i,n(ya,{size:16})),e})(),n(h,{get when(){return cg()},get fallback(){return n(UC,{onSelect:e=>Og(e.username)})},get children(){return n(h,{get when(){return!e.loading},get fallback(){return CC()},get children(){return n(h,{get when(){return e()},get fallback(){return(()=>{var e=LC(),t=e.firstChild.nextSibling;return ge(t,`click`,Dg,!0),e})()},get children(){return n(WC,{get respondent(){return e()},onBack:Dg})}})}})}})]}})}P([`click`,`keydown`,`input`]);var KC=`#161b22`,qC=`#1c2129`,Z=`#30363d`,Q=`#c9d1d9`,$=`#8b949e`,JC=`#58a6ff`,YC=`#3fb950`,XC=`#f85149`;function ZC(e){return e==null?`—`:Math.round(e).toLocaleString(`en-US`)}function QC(e){return e==null?`—`:e.toLocaleString(`en-US`,{minimumFractionDigits:3,maximumFractionDigits:3})}function $C(){return(Se()?.serverData?.shards??[]).filter(e=>e!=null)}function ew(){return mg()??$C()[0]??null}function tw(){return $C().length>1}var nw={token:`subscription token`,energy:`energy`,power:`power`,H:`hydrogen`,O:`oxygen`,U:`utrium`,L:`lemergium`,K:`keanium`,Z:`zynthium`,X:`catalyst`,OH:`hydroxide`,ZK:`zynthium keanite`,UL:`utrium lemergite`,G:`ghodium`,UH:`utrium hydride`,UO:`utrium oxide`,KH:`keanium hydride`,KO:`keanium oxide`,LH:`lemergium hydride`,LO:`lemergium oxide`,ZH:`zynthium hydride`,ZO:`zynthium oxide`,GH:`ghodium hydride`,GO:`ghodium oxide`,UH2O:`utrium acid`,UHO2:`utrium alkalide`,KH2O:`keanium acid`,KHO2:`keanium alkalide`,LH2O:`lemergium acid`,LHO2:`lemergium alkalide`,ZH2O:`zynthium acid`,ZHO2:`zynthium alkalide`,GH2O:`ghodium acid`,GHO2:`ghodium alkalide`,XUH2O:`catalyzed utrium acid`,XUHO2:`catalyzed utrium alkalide`,XKH2O:`catalyzed keanium acid`,XKHO2:`catalyzed keanium alkalide`,XLH2O:`catalyzed lemergium acid`,XLHO2:`catalyzed lemergium alkalide`,XZH2O:`catalyzed zynthium acid`,XZHO2:`catalyzed zynthium alkalide`,XGH2O:`catalyzed ghodium acid`,XGHO2:`catalyzed ghodium alkalide`,ops:`ops`,silicon:`silicon`,metal:`metal`,biomass:`biomass`,mist:`mist`,utrium_bar:`utrium bar`,lemergium_bar:`lemergium bar`,zynthium_bar:`zynthium bar`,keanium_bar:`keanium bar`,ghodium_melt:`ghodium melt`,oxidant:`oxidant`,reductant:`reductant`,purifier:`purifier`,battery:`battery`,composite:`composite`,crystal:`crystal`,liquid:`liquid`,wire:`wire`,switch:`switch`,transistor:`transistor`,microchip:`microchip`,circuit:`circuit`,device:`device`,cell:`cell`,phlegm:`phlegm`,tissue:`tissue`,muscle:`muscle`,organoid:`organoid`,organism:`organism`,alloy:`alloy`,tube:`tube`,fixtures:`fixtures`,frame:`frame`,hydraulics:`hydraulics`,machine:`machine`,condensate:`condensate`,concentrate:`concentrate`,extract:`extract`,spirit:`spirit`,emanation:`emanation`,essence:`essence`},rw=Object.keys(nw);function iw(e){return nw[e]??e}var aw={metal:[`wire`,`switch`,`transistor`,`microchip`,`circuit`,`device`],biomass:[`cell`,`phlegm`,`tissue`,`muscle`,`organoid`,`organism`],silicon:[`alloy`,`tube`,`fixtures`,`frame`,`hydraulics`,`machine`],mist:[`condensate`,`concentrate`,`extract`,`spirit`,`emanation`,`essence`]},ow={utrium_bar:`U`,lemergium_bar:`L`,zynthium_bar:`Z`,keanium_bar:`K`,ghodium_melt:`G`,oxidant:`O`,reductant:`H`,purifier:`X`,battery:`energy`},sw={ops:14255163,token:15911244},cw=(()=>{let e={};for(let t in aw)for(let n of aw[t])e[n]=jn[t];for(let t in ow){let n=ow[t];e[t]=n===`energy`?Ut:Dt[n]}return{...e,...sw}})();function lw(e){if(Dt[e]!=null)return Dt[e];if(jn[e]!=null)return jn[e];if(cw[e]!=null)return cw[e];let t=(e.startsWith(`X`)?e.slice(1):e)[0];return Dt[t]==null?Lt:Dt[t]}var uw=z(`<span style="display:inline-block;border-radius:50%;border:1px solid rgba(255, 255, 255, 0.25);vertical-align:middle;flex:none">`);function dw(e){let t=()=>e.size??18,n=()=>`#${lw(e.resourceType).toString(16).padStart(6,`0`)}`;return(()=>{var i=uw();return r(r=>{var a=iw(e.resourceType),o=`${t()}px`,s=`${t()}px`,c=n();return a!==r.e&&R(i,`title`,r.e=a),o!==r.t&&B(i,`width`,r.t=o),s!==r.a&&B(i,`height`,r.a=s),c!==r.o&&B(i,`background`,r.o=c),r},{e:void 0,t:void 0,a:void 0,o:void 0}),i})()}var fw=z(`<div style="display:grid;grid-template-columns:repeat(auto-fill, minmax(220px, 1fr));gap:8px">`),pw=z(`<div style=border-radius:8px;padding:32px;text-align:center>Couldn't load the market — this server may not support it.`),mw=z(`<button style="display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:6px;cursor:pointer;text-align:left"><span style=flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap></span><span style=font-size:13px> `);function hw(t){let[i,a]=e({}),[o,s]=e(!0),[c,l]=e(null),u=0;return p(()=>{let e=t.shard,n=L();if(!n)return;let r=++u;s(!0),n.http.game.market.ordersIndex(e).then(e=>{if(r!==u)return;let t={};for(let n of e.list??[])t[n._id]=n.count;a(t),l(null)}).catch(e=>{r===u&&l(e instanceof Error?e.message:String(e))}).finally(()=>{r===u&&s(!1)})}),n(h,{get when(){return!c()},get fallback(){return(()=>{var e=pw();return B(e,`background`,KC),B(e,`border`,`1px solid ${Z}`),B(e,`color`,$),e})()},get children(){var e=fw();return T(e,n(b,{each:rw,children:e=>{let a=()=>i()[e]??0;return(()=>{var i=mw(),o=i.firstChild,s=o.nextSibling,c=s.firstChild;return i.addEventListener(`mouseleave`,e=>e.currentTarget.style.background=KC),i.addEventListener(`mouseenter`,e=>e.currentTarget.style.background=qC),i.$$click=()=>Fg(e,t.shard),B(i,`border`,`1px solid ${Z}`),B(i,`background`,KC),B(i,`color`,Q),T(i,n(dw,{resourceType:e,size:20}),o),T(o,()=>iw(e)),T(s,a,c),T(s,()=>a()===1?`order`:`orders`,null),r(e=>B(s,`color`,a()>0?Q:$)),i})()}})),r(t=>B(e,`opacity`,o()?.6:1)),e}})}P([`click`]);var gw=z(`<div style=border-radius:8px;margin-bottom:16px;overflow:hidden><div style="display:flex;align-items:center;padding:11px 16px"><span style=font-size:12px;font-weight:600;text-transform:uppercase;letter-spacing:0.05em></span><div style=flex:1></div></div><div style="padding:4px 16px 12px">`);function _w(e){return(()=>{var t=gw(),n=t.firstChild,i=n.firstChild;i.nextSibling;var a=n.nextSibling;return B(t,`background`,KC),B(t,`border`,`1px solid ${Z}`),B(n,`border-bottom`,`1px solid ${Z}`),B(n,`background`,qC),T(i,()=>e.title),T(n,()=>e.right,null),T(a,()=>e.children),r(n=>{var r=e.accent?`3px solid ${e.accent}`:`1px solid ${Z}`,a=e.accent??`#c9d1d9`;return r!==n.e&&B(t,`border-left`,n.e=r),a!==n.t&&B(i,`color`,n.t=a),n},{e:void 0,t:void 0}),t})()}function vw(e){return e%2==1?`rgba(255, 255, 255, 0.022)`:`transparent`}var yw=z(`<div style="border-radius:6px;padding:10px 14px;margin-bottom:16px;font-size:13px">A special item that activates 60 days of CPU subscription for its owner.`),bw=z(`<div style=display:flex;align-items:center;gap:10px;margin-bottom:16px><label style=font-size:13px>Target room</label><input placeholder="e.g. W1N1"style="padding:6px 8px;border-radius:4px;width:120px"><span style=font-size:12px>shows shipping range to each order's room`),xw=z(`<div>`),Sw=z(`<div><div style=display:flex;align-items:center;gap:12px;margin-bottom:16px><button style="display:flex;align-items:center;gap:4px;padding:6px 10px;border-radius:4px;background:#21262d;cursor:pointer"> Resources</button><div style=flex:1></div><button title=Refresh style="display:flex;align-items:center;gap:6px;padding:6px 10px;border-radius:4px;background:#21262d;cursor:pointer"> Refresh</button></div><div style=display:flex;align-items:center;gap:10px;margin-bottom:16px><h2 style=margin:0;font-size:20px;font-weight:600>`),Cw=z(`<div style=border-radius:8px;padding:32px;text-align:center>Couldn't load orders for this resource.`),ww=z(`<table style=width:100%;border-collapse:collapse;font-size:13px><thead><tr style=text-align:right></tr></thead><tbody>`),Tw=z(`<span style=font-size:12px> `),Ew=z(`<div style="font-size:13px;padding:10px 0">No orders`),Dw=z(`<a href=# style=text-decoration:none>`),Ow=z(`<td style="padding:7px 0">`),kw=z(`<td style=padding-right:6px>`),Aw=z(`<tr style=text-align:right><td style="text-align:left;font-family:monospace;padding:7px 8px 7px 6px"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0">`),jw=z(`<span>—`),Mw=z(`<th style=font-weight:400;cursor:pointer;user-select:none;white-space:nowrap>`),Nw=z(`<table style=width:100%;border-collapse:collapse;font-size:13px><thead><tr style=text-align:right><th style="text-align:left;font-weight:400;padding:0 0 7px 6px">Date</th><th style="font-weight:400;padding:0 0 7px">Transactions</th><th style="font-weight:400;padding:0 0 7px">Total volume</th><th style="font-weight:400;padding:0 6px 7px 0">Price (avg ± stddev)</th></tr></thead><tbody>`),Pw=z(`<div style="font-size:13px;padding:10px 0">No history`),Fw=z(`<tr style=text-align:right><td style="text-align:left;padding:7px 0 7px 6px"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 6px 7px 0"> <span>± `);function Iw(e,t){if(!e)return;let n=Yn(e),r=Yn(t);if(!(!n||!r))return Math.max(Math.abs(n.x-r.x),Math.abs(n.y-r.y))}function Lw(e,t){let n=t[0]===`-`,r=t.slice(1);return[...e].sort((e,t)=>{let i=e[r],a=t[r],o;return o=typeof i==`number`||typeof a==`number`?(Number(i)||0)-(Number(a)||0):String(i??``).localeCompare(String(a??``)),n?-o:o})}function Rw(t){let[a,o]=e([]),[s,c]=e([]),[l,u]=e([]),[d,f]=e(gg()??``),[m,g]=e(!0),[_,v]=e(null),y=()=>t.resourceType===`token`,b=0,x=()=>{let e=L(),n=t.resourceType;if(!e||!n)return;let r=++b;g(!0),e.http.game.market.orders(n,t.shard).then(e=>{if(r!==b)return;let t=e.list??[];o(t.filter(e=>e.type===`sell`)),c(t.filter(e=>e.type===`buy`)),v(null)}).catch(e=>{r===b&&v(e instanceof Error?e.message:String(e))}).finally(()=>{r===b&&g(!1)}),e.http.game.market.stats(n,t.shard).then(e=>{r===b&&u(e.stats??[])}).catch(()=>{r===b&&u([])})};p(()=>{t.resourceType,t.shard,x()});let S=e=>{let t=d().trim().toUpperCase(),n=/^[WE]\d+[NS]\d+$/.test(t);return e.map(e=>({...e,range:n?Iw(e.roomName,t):void 0}))},C=i(()=>S(a())),w=i(()=>S(s()));return(()=>{var e=Sw(),i=e.firstChild,a=i.firstChild,o=a.firstChild,s=a.nextSibling.nextSibling,c=s.firstChild,u=i.nextSibling,p=u.firstChild;return a.$$click=()=>Pg(t.shard),B(a,`border`,`1px solid ${Z}`),B(a,`color`,Q),T(a,n(Ur,{size:14}),o),s.$$click=x,B(s,`border`,`1px solid ${Z}`),B(s,`color`,Q),T(s,n(Yi,{size:14}),c),T(u,n(dw,{get resourceType(){return t.resourceType??``},size:26}),p),B(p,`color`,Q),T(p,()=>iw(t.resourceType??``)),T(e,n(h,{get when(){return y()},get children(){var e=yw();return B(e,`background`,KC),B(e,`border`,`1px solid ${Z}`),B(e,`color`,$),e}}),null),T(e,n(h,{get when(){return!_()},get fallback(){return(()=>{var e=Cw();return B(e,`background`,KC),B(e,`border`,`1px solid ${Z}`),B(e,`color`,$),e})()},get children(){return[n(h,{get when(){return!y()},get children(){var e=bw(),t=e.firstChild,n=t.nextSibling,i=n.nextSibling;return B(t,`color`,$),n.$$input=e=>f(e.currentTarget.value),B(n,`border`,`1px solid ${Z}`),B(n,`background`,KC),B(n,`color`,Q),B(i,`color`,$),r(()=>n.value=d()),e}}),(()=>{var e=xw();return T(e,n(zw,{title:`Selling`,accent:YC,get rows(){return C()},defaultSort:`+price`,get showRoom(){return!y()},get shard(){return t.shard}}),null),T(e,n(zw,{title:`Buying`,accent:XC,get rows(){return w()},defaultSort:`-price`,get showRoom(){return!y()},get shard(){return t.shard}}),null),T(e,n(Vw,{get stats(){return l()}}),null),r(t=>B(e,`opacity`,m()?.6:1)),e})()]}}),null),e})()}function zw(t){let[a,o]=e(t.defaultSort),s=i(()=>Lw(t.rows,a())),c=e=>{o(t=>t===`+${e}`?`-${e}`:`+${e}`)};return n(_w,{get title(){return t.title},get accent(){return t.accent},get right(){return(()=>{var e=Tw(),n=e.firstChild;return B(e,`color`,$),T(e,()=>t.rows.length,n),T(e,()=>t.rows.length===1?`order`:`orders`,null),e})()},get children(){return n(h,{get when(){return t.rows.length},get fallback(){return(()=>{var e=Ew();return B(e,`color`,$),e})()},get children(){var e=ww(),i=e.firstChild,o=i.firstChild,l=i.nextSibling;return B(o,`color`,$),T(o,n(Bw,{label:`Order ID`,col:`_id`,get sort(){return a()},onClick:c,align:`left`}),null),T(o,n(Bw,{label:`Price`,col:`price`,get sort(){return a()},onClick:c}),null),T(o,n(Bw,{label:`Available`,col:`amount`,get sort(){return a()},onClick:c}),null),T(o,n(Bw,{label:`Remaining`,col:`remainingAmount`,get sort(){return a()},onClick:c}),null),T(o,n(h,{get when(){return t.showRoom},get children(){return[n(Bw,{label:`Room`,col:`roomName`,get sort(){return a()},onClick:c}),n(Bw,{label:`Range`,col:`range`,get sort(){return a()},onClick:c})]}}),null),T(l,n(b,{get each(){return s()},children:(e,i)=>(()=>{var a=Aw(),o=a.firstChild,s=o.nextSibling,c=s.nextSibling,l=c.nextSibling;return B(o,`color`,$),T(o,()=>e._id),T(s,()=>QC(e.price)),B(c,`color`,Q),T(c,()=>ZC(e.amount)),B(l,`color`,$),T(l,()=>ZC(e.remainingAmount)),T(a,n(h,{get when(){return t.showRoom},get children(){return[(()=>{var r=Ow();return T(r,n(h,{get when(){return e.roomName},get fallback(){return(()=>{var e=jw();return B(e,`color`,$),e})()},get children(){var n=Dw();return n.$$click=n=>{n.preventDefault(),Bg(e.roomName,t.shard)},B(n,`color`,JC),T(n,()=>e.roomName),n}})),r})(),(()=>{var t=kw();return B(t,`color`,$),T(t,()=>e.range??`—`),t})()]}}),null),r(e=>{var n=vw(i()),r=t.accent;return n!==e.e&&B(a,`background`,e.e=n),r!==e.t&&B(s,`color`,e.t=r),e},{e:void 0,t:void 0}),a})()})),e}})}})}function Bw(e){let t=()=>e.sort===`+${e.col}`||e.sort===`-${e.col}`,n=()=>e.sort===`+${e.col}`?` ▲`:e.sort===`-${e.col}`?` ▼`:``;return(()=>{var i=Mw();return i.$$click=()=>e.onClick(e.col),B(i,`border-bottom`,`1px solid ${Z}`),T(i,()=>e.label,null),T(i,n,null),r(n=>{var r=e.align??`right`,a=t()?Q:$,o=e.align===`left`?`0 0 7px 6px`:`0 0 7px`;return r!==n.e&&B(i,`text-align`,n.e=r),a!==n.t&&B(i,`color`,n.t=a),o!==n.a&&B(i,`padding`,n.a=o),n},{e:void 0,t:void 0,a:void 0}),i})()}function Vw(e){return n(_w,{title:`Price history`,get children(){return n(h,{get when(){return e.stats.length},get fallback(){return(()=>{var e=Pw();return B(e,`color`,$),e})()},get children(){var t=Nw(),i=t.firstChild,a=i.firstChild,o=a.firstChild,s=o.nextSibling,c=s.nextSibling,l=c.nextSibling,u=i.nextSibling;return B(a,`color`,$),B(o,`border-bottom`,`1px solid ${Z}`),B(s,`border-bottom`,`1px solid ${Z}`),B(c,`border-bottom`,`1px solid ${Z}`),B(l,`border-bottom`,`1px solid ${Z}`),T(u,n(b,{get each(){return e.stats},children:(e,t)=>(()=>{var n=Fw(),i=n.firstChild,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling,c=s.firstChild,l=c.nextSibling;return l.firstChild,B(i,`color`,$),T(i,()=>e.date),B(a,`color`,Q),T(a,()=>ZC(e.transactions)),B(o,`color`,Q),T(o,()=>ZC(e.volume)),B(s,`color`,Q),T(s,()=>QC(e.avgPrice),c),B(l,`color`,$),T(l,()=>QC(e.stddevPrice),null),r(e=>B(n,`background`,vw(t()))),n})()})),t}})}})}P([`click`,`input`]);var Hw=z(`<div style=display:flex;justify-content:flex-end;margin-bottom:12px><button title=Refresh style="display:flex;align-items:center;gap:6px;padding:6px 10px;border-radius:4px;background:#21262d;cursor:pointer"> Refresh`),Uw=z(`<div>`),Ww=z(`<div style=border-radius:8px;padding:32px;text-align:center>Couldn't load your orders.`),Gw=z(`<div style=border-radius:8px;padding:32px;text-align:center>You have no orders. Create one with the in-game Market API.`),Kw=z(`<table style=width:100%;border-collapse:collapse;font-size:13px><thead><tr style=text-align:right><th style="text-align:left;font-weight:400;padding:0 0 7px 6px">Order ID</th><th style="text-align:left;font-weight:400;padding:0 0 7px">Resource</th><th style="font-weight:400;padding:0 0 7px">Type</th><th style="font-weight:400;padding:0 0 7px">Active</th><th style="font-weight:400;padding:0 0 7px">Price</th><th style="font-weight:400;padding:0 0 7px">Available</th><th style="font-weight:400;padding:0 0 7px">Remaining</th><th style="font-weight:400;padding:0 0 7px">Total</th><th style="font-weight:400;padding:0 6px 7px 0">Room</th></tr></thead><tbody>`),qw=z(`<span style=font-size:12px> `),Jw=z(`<a href=# style=text-decoration:none>`),Yw=z(`<tr style=text-align:right><td style="text-align:left;font-family:monospace;padding:7px 8px 7px 6px"></td><td style="text-align:left;padding:7px 0"><a href=# style=display:inline-flex;align-items:center;gap:8px;text-decoration:none></a></td><td style="padding:7px 0"></td><td style="padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="padding:7px 6px 7px 0">`),Xw=z(`<span>—`);function Zw(){let[t,i]=e([]),[a,s]=e(!0),[c,l]=e(null),u=()=>{let e=L();e&&(s(!0),e.http.game.market.myOrders().then(e=>{e.shards?i(Object.entries(e.shards).map(([e,t])=>({shard:e,orders:t}))):i([{shard:null,orders:e.list??[]}]),l(null)}).catch(e=>l(e instanceof Error?e.message:String(e))).finally(()=>s(!1)))};o(u);let d=()=>t().reduce((e,t)=>e+t.orders.length,0),f=()=>t().length>1;return n(h,{get when(){return!c()},get fallback(){return(()=>{var e=Ww();return B(e,`background`,KC),B(e,`border`,`1px solid ${Z}`),B(e,`color`,$),e})()},get children(){return[(()=>{var e=Hw(),t=e.firstChild,r=t.firstChild;return t.$$click=u,B(t,`border`,`1px solid ${Z}`),B(t,`color`,Q),T(t,n(Yi,{size:14}),r),e})(),n(h,{get when(){return d()},get fallback(){return(()=>{var e=Gw();return B(e,`background`,KC),B(e,`border`,`1px solid ${Z}`),B(e,`color`,$),e})()},get children(){var e=Uw();return T(e,n(b,{get each(){return t()},children:e=>n(h,{get when(){return e.orders.length},get children(){return n(_w,{get title(){return I(()=>!!f())()?e.shard??`My orders`:`My orders`},get right(){return(()=>{var t=qw(),n=t.firstChild;return B(t,`color`,$),T(t,()=>e.orders.length,n),T(t,()=>e.orders.length===1?`order`:`orders`,null),t})()},get children(){var t=Kw(),i=t.firstChild,a=i.firstChild,o=a.firstChild,s=o.nextSibling,c=s.nextSibling,l=c.nextSibling,u=l.nextSibling,d=u.nextSibling,f=d.nextSibling,p=f.nextSibling,m=p.nextSibling,g=i.nextSibling;return B(a,`color`,$),B(o,`border-bottom`,`1px solid ${Z}`),B(s,`border-bottom`,`1px solid ${Z}`),B(c,`border-bottom`,`1px solid ${Z}`),B(l,`border-bottom`,`1px solid ${Z}`),B(u,`border-bottom`,`1px solid ${Z}`),B(d,`border-bottom`,`1px solid ${Z}`),B(f,`border-bottom`,`1px solid ${Z}`),B(p,`border-bottom`,`1px solid ${Z}`),B(m,`border-bottom`,`1px solid ${Z}`),T(g,n(b,{get each(){return e.orders},children:(t,i)=>(()=>{var a=Yw(),o=a.firstChild,s=o.nextSibling,c=s.firstChild,l=s.nextSibling,u=l.nextSibling,d=u.nextSibling,f=d.nextSibling,p=f.nextSibling,m=p.nextSibling,g=m.nextSibling;return B(o,`color`,$),T(o,()=>t._id),c.$$click=n=>{n.preventDefault(),Fg(t.resourceType,e.shard)},B(c,`color`,JC),T(c,n(dw,{get resourceType(){return t.resourceType},size:16}),null),T(c,()=>iw(t.resourceType),null),T(l,()=>t.type===`sell`?`Selling`:`Buying`),T(u,()=>t.active?`Yes`:`No`),B(d,`color`,Q),T(d,()=>QC(t.price)),B(f,`color`,Q),T(f,()=>ZC(t.amount)),B(p,`color`,$),T(p,()=>ZC(t.remainingAmount)),B(m,`color`,$),T(m,()=>ZC(t.totalAmount)),T(g,n(h,{get when(){return t.roomName},get fallback(){return(()=>{var e=Xw();return B(e,`color`,$),e})()},get children(){var n=Jw();return n.$$click=n=>{n.preventDefault(),Bg(t.roomName,e.shard)},B(n,`color`,JC),T(n,()=>t.roomName),n}})),r(e=>{var n=vw(i()),r=t.type===`sell`?YC:XC,o=t.active?YC:XC;return n!==e.e&&B(a,`background`,e.e=n),r!==e.t&&B(l,`color`,e.t=r),o!==e.a&&B(u,`color`,e.a=o),e},{e:void 0,t:void 0,a:void 0}),a})()})),t}})}})})),r(t=>B(e,`opacity`,a()?.6:1)),e}})]}})}P([`click`]);var Qw=z(`<div style=display:flex;justify-content:flex-end;margin-bottom:12px><button title=Refresh style="display:flex;align-items:center;gap:6px;padding:6px 10px;border-radius:4px;background:#21262d;cursor:pointer"> Refresh`),$w=z(`<th style="text-align:left;font-weight:400;padding:0 0 7px">Shard`),eT=z(`<table style=width:100%;border-collapse:collapse;font-size:13px><thead><tr style=text-align:right><th style="text-align:left;font-weight:400;padding:0 0 7px 6px">Date</th><th style="font-weight:400;padding:0 0 7px">Tick</th><th style="text-align:left;font-weight:400;padding:0 12px 7px">Description</th><th style="font-weight:400;padding:0 0 7px">Change</th><th style="font-weight:400;padding:0 6px 7px 0">Balance</th></tr></thead><tbody>`),tT=z(`<button style="display:flex;align-items:center;gap:4px;padding:6px 12px;border-radius:4px;background:#21262d;cursor:pointer"> Newer`),nT=z(`<button style="display:flex;align-items:center;gap:4px;padding:6px 12px;border-radius:4px;background:#21262d;cursor:pointer">Older `),rT=z(`<div style=display:flex;justify-content:space-between;margin-top:16px>`),iT=z(`<div style=border-radius:8px;padding:32px;text-align:center>Couldn't load your history.`),aT=z(`<div style=border-radius:8px;padding:32px;text-align:center>Your market history is empty.`),oT=z(`<td style="text-align:left;padding:7px 0">`),sT=z(`<tr style=text-align:right><td style="text-align:left;padding:7px 0 7px 6px"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="text-align:left;padding:7px 12px"></td><td style="font-variant-numeric:tabular-nums;padding:7px 0"></td><td style="font-variant-numeric:tabular-nums;padding:7px 6px 7px 0">`),cT=z(`<span>`);function lT(e){switch(e.type){case`market.buy`:return`Resources bought via market order`;case`market.sell`:return`Resources sold via market order`;case`market.fee`:return`Market fee`;default:return e.type.replace(/[._]/g,` `)}}function uT(e){let t=new Date(e);return isNaN(t.getTime())?e:t.toLocaleString()}function dT(){let[t,i]=e([]),[a,s]=e(0),[c,l]=e(!1),[u,d]=e(!0),[f,p]=e(null),m=e=>{let t=L();t&&(d(!0),t.http.user.moneyHistory(e).then(t=>{i(t.list??[]),s(t.page??e),l(t.hasMore??!1),p(null)}).catch(e=>p(e instanceof Error?e.message:String(e))).finally(()=>d(!1)))};return o(()=>m(0)),n(h,{get when(){return!f()},get fallback(){return(()=>{var e=iT();return B(e,`background`,KC),B(e,`border`,`1px solid ${Z}`),B(e,`color`,$),e})()},get children(){return[(()=>{var e=Qw(),t=e.firstChild,r=t.firstChild;return t.$$click=()=>m(a()),B(t,`border`,`1px solid ${Z}`),B(t,`color`,Q),T(t,n(Yi,{size:14}),r),e})(),n(h,{get when(){return t().length},get fallback(){return(()=>{var e=aT();return B(e,`background`,KC),B(e,`border`,`1px solid ${Z}`),B(e,`color`,$),e})()},get children(){return[n(_w,{title:`Credit history`,get children(){var e=eT(),i=e.firstChild,a=i.firstChild,o=a.firstChild,s=o.nextSibling,c=s.nextSibling,l=c.nextSibling,d=l.nextSibling,f=i.nextSibling;return B(a,`color`,$),B(o,`border-bottom`,`1px solid ${Z}`),T(a,n(h,{get when(){return tw()},get children(){var e=$w();return B(e,`border-bottom`,`1px solid ${Z}`),e}}),s),B(s,`border-bottom`,`1px solid ${Z}`),B(c,`border-bottom`,`1px solid ${Z}`),B(l,`border-bottom`,`1px solid ${Z}`),B(d,`border-bottom`,`1px solid ${Z}`),T(f,n(b,{get each(){return t()},children:(e,t)=>(()=>{var i=sT(),a=i.firstChild,o=a.nextSibling,s=o.nextSibling,c=s.nextSibling,l=c.nextSibling;return B(a,`color`,$),T(a,()=>uT(e.date)),T(i,n(h,{get when(){return tw()},get children(){var t=oT();return B(t,`color`,$),T(t,()=>e.shard??`—`),t}}),o),B(o,`color`,$),T(o,()=>e.tick),B(s,`color`,Q),T(s,()=>lT(e)),T(c,()=>e.change>0?`+`:``,null),T(c,()=>QC(e.change),null),B(l,`color`,Q),T(l,()=>QC(e.balance)),r(n=>{var r=vw(t()),a=e.change>0?YC:e.change<0?XC:$;return r!==n.e&&B(i,`background`,n.e=r),a!==n.t&&B(c,`color`,n.t=a),n},{e:void 0,t:void 0}),i})()})),r(t=>B(e,`opacity`,u()?.6:1)),e}}),(()=>{var e=rT();return T(e,n(h,{get when(){return a()>0},get fallback(){return cT()},get children(){var e=tT(),t=e.firstChild;return e.$$click=()=>m(a()-1),B(e,`border`,`1px solid ${Z}`),B(e,`color`,Q),T(e,n(qr,{size:14}),t),e}}),null),T(e,n(h,{get when(){return c()},get children(){var e=nT();return e.firstChild,e.$$click=()=>m(a()+1),B(e,`border`,`1px solid ${Z}`),B(e,`color`,Q),T(e,n(Yr,{size:14}),null),e}}),null),e})()]}})]}})}P([`click`]);var fT=z(`<label style=display:flex;align-items:center;gap:8px;font-size:13px>Shard<select style="padding:6px 8px;border-radius:4px;cursor:pointer">`),pT=z(`<div style="display:flex;align-items:center;gap:12px;padding:0 0 14px;margin-bottom:8px"><h1 style=margin:0;font-size:22px;font-weight:600>Market</h1><div style=flex:1></div><button title=Close style=display:flex;align-items:center;padding:7px;border-radius:4px;background:#21262d;cursor:pointer>`),mT=z(`<div style=display:flex;gap:4px;margin-bottom:20px>`),hT=z(`<option>`),gT=z(`<button style="padding:8px 16px;border:none;background:transparent;font-size:14px;cursor:pointer;margin-bottom:-1px">`);function _T(){let e=()=>ug()===`all-orders`||ug()===`resource`,t=e=>{ug()===`resource`&&fg()?Fg(fg(),e):Pg(e)};return n(qy,{get children(){return[(()=>{var i=pT(),a=i.firstChild,o=a.nextSibling.nextSibling;return B(i,`border-bottom`,`1px solid ${Z}`),B(a,`color`,Q),T(i,n(h,{get when(){return I(()=>!!e())()&&tw()},get children(){var e=fT(),i=e.firstChild.nextSibling;return B(e,`color`,$),i.addEventListener(`change`,e=>t(e.currentTarget.value)),B(i,`border`,`1px solid ${Z}`),B(i,`background`,KC),B(i,`color`,Q),T(i,n(b,{get each(){return $C()},children:e=>(()=>{var t=hT();return t.value=e,T(t,e),t})()})),r(()=>i.value=ew()??``),e}}),o),ge(o,`click`,zg,!0),B(o,`border`,`1px solid ${Z}`),B(o,`color`,Q),T(o,n(ya,{size:16})),i})(),(()=>{var t=mT();return B(t,`border-bottom`,`1px solid ${Z}`),T(t,n(vT,{label:`All orders`,get active(){return e()},onClick:()=>Pg(ew())}),null),T(t,n(vT,{label:`My orders`,get active(){return ug()===`my-orders`},onClick:Ig}),null),T(t,n(vT,{label:`History`,get active(){return ug()===`history`},onClick:Lg}),null),t})(),n(S,{get children(){return[n(C,{get when(){return ug()===`resource`},get children(){return n(Rw,{get resourceType(){return fg()},get shard(){return ew()}})}}),n(C,{get when(){return ug()===`my-orders`},get children(){return n(Zw,{})}}),n(C,{get when(){return ug()===`history`},get children(){return n(dT,{})}}),n(C,{get when(){return ug()===`all-orders`},get children(){return n(hw,{get shard(){return ew()}})}})]}})]}})}function vT(e){return(()=>{var t=gT();return t.$$click=()=>e.onClick(),T(t,()=>e.label),r(n=>{var r=`2px solid ${e.active?JC:`transparent`}`,i=e.active?Q:$,a=e.active?600:400;return r!==n.e&&B(t,`border-bottom`,n.e=r),i!==n.t&&B(t,`color`,n.t=i),a!==n.a&&B(t,`font-weight`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),t})()}P([`click`]);var yT=z(`<div style=position:fixed;inset:0;background:rgba(0,0,0,0.65);z-index:200;display:flex;align-items:center;justify-content:center><div style="background:#161b22;border:1px solid #30363d;border-radius:10px;width:540px;max-height:90vh;display:flex;flex-direction:column;overflow:hidden"><div style="display:flex;align-items:center;justify-content:space-between;padding:14px 20px;border-bottom:1px solid #30363d;flex-shrink:0"><span style=font-size:15px;font-weight:600;color:#c9d1d9>Edit Badge</span><button style="background:transparent;border:none;color:#8b949e;cursor:pointer;line-height:1;padding:2px 6px"></button></div><div style=overflow:auto;flex:1;padding:20px><div style=display:flex;gap:16px;margin-bottom:20px><div style=flex-shrink:0><div style=font-size:11px;color:#8b949e;text-transform:uppercase;letter-spacing:0.06em;margin-bottom:8px;font-weight:700>Preview</div><img width=96 height=96 style=display:block></div><div style=flex:1;min-width:0><div style=font-size:11px;color:#8b949e;text-transform:uppercase;letter-spacing:0.06em;margin-bottom:8px;font-weight:700>Badge Design</div><div style="display:grid;grid-template-columns:repeat(6, 1fr);gap:4px"></div></div></div><div style=margin-bottom:20px><div style=font-size:11px;color:#8b949e;text-transform:uppercase;letter-spacing:0.06em;margin-bottom:8px;font-weight:700>Colors</div><div style=display:flex;gap:6px;margin-bottom:10px></div><div style="display:grid;grid-template-columns:repeat(20, 1fr);gap:2px;margin-bottom:10px"></div><div style=display:flex;align-items:center;gap:8px><div style="width:24px;height:24px;border-radius:4px;border:1px solid rgba(255,255,255,0.2);flex-shrink:0"></div><input type=text maxlength=7 placeholder=#rrggbb style="width:90px;padding:4px 8px;border-radius:4px;background:#0d1117;color:#c9d1d9;font-size:12px;font-family:monospace;outline:none"></div></div><div style=margin-bottom:16px><div style=display:flex;align-items:baseline;gap:8px;margin-bottom:6px><span style=font-size:11px;color:#8b949e;text-transform:uppercase;letter-spacing:0.06em;font-weight:700>Variation</span><span style=font-size:12px;color:#c9d1d9></span></div><input type=range min=-100 max=100 style=width:100%;accent-color:#58a6ff></div><label style=display:flex;align-items:center;gap:8px;cursor:pointer;font-size:13px;color:#c9d1d9><input type=checkbox style=accent-color:#58a6ff;width:14px;height:14px>Rotate / Flip</label></div><div style="display:flex;justify-content:flex-end;gap:8px;padding:14px 20px;border-top:1px solid #30363d;flex-shrink:0"><button style="padding:8px 16px;border-radius:6px;border:1px solid #30363d;background:transparent;color:#8b949e;font-size:13px">Cancel</button><button style="padding:8px 16px;border-radius:6px;border:none;background:#238636;color:#fff;font-size:13px;font-weight:600">`),bT=z(`<button style=border-radius:4px;padding:3px;cursor:pointer;display:flex;align-items:center;justify-content:center><img width=48 height=48 style=display:block>`),xT=z(`<button style="display:flex;align-items:center;gap:6px;padding:5px 10px;border-radius:6px;font-size:12px;cursor:pointer"><div style="width:12px;height:12px;border-radius:50%;border:1px solid rgba(255,255,255,0.2);flex-shrink:0">`),ST=z(`<button style=width:100%;aspect-ratio:1;border-radius:2px;cursor:pointer;padding:0;outline:none>`),CT={};for(let e=1;e<=24;e++){let t=gt({type:e,color1:`#4a5060`,color2:`#7a9ec0`,color3:`#c0daf0`,param:0,flip:!1});CT[e]=`data:image/svg+xml,${encodeURIComponent(t)}`}function wT(e){return typeof e==`string`?e:ft[e]?.rgb??`#000000`}function TT(e){return typeof e==`number`?Math.max(0,Math.min(79,e)):e}var ET=[{slot:1,label:`Background`},{slot:2,label:`Primary`},{slot:3,label:`Secondary`}],DT=Array.from({length:24},(e,t)=>t+1),OT=/^#[0-9a-f]{6}$/i;function kT(t){let[a,o]=e(w(()=>typeof t.badge.type==`number`?t.badge.type:1)),[s,c]=e(w(()=>TT(t.badge.color1))),[l,u]=e(w(()=>TT(t.badge.color2))),[d,f]=e(w(()=>TT(t.badge.color3))),[m,h]=e(w(()=>t.badge.param??0)),[g,_]=e(w(()=>t.badge.flip??!1)),[v,y]=e(1),[x,S]=e(!1),[C,E]=e(w(()=>wT(TT(t.badge.color1)))),D=e=>e===1?s():e===2?l():d(),O=e=>{let t=v();t===1?c(e):t===2?u(e):f(e)};p(()=>{E(wT(D(v())))});let k=e=>{let t=D(v());return typeof t==`number`?t===e:t.toLowerCase()===(ft[e]?.rgb??``).toLowerCase()},A=()=>({type:a(),color1:wT(s()),color2:wT(l()),color3:wT(d()),param:m(),flip:g()}),ee=i(()=>{let e=gt(A());return`data:image/svg+xml,${encodeURIComponent(e)}`}),M=e=>{if(E(e),!OT.test(e))return;let t=ft.findIndex(t=>t.rgb.toLowerCase()===e.toLowerCase());O(t>=0?t:e)},te=async()=>{let e=L();if(e){S(!0);try{await e.http.user.badge(A()),await e.stores.user.refreshMe(),t.onClose(),t.onSaved?.(),j(`Badge saved`,`success`,3e3)}catch(e){j(`Failed to save badge: ${e instanceof Error?e.message:String(e)}`,`error`,5e3)}finally{S(!1)}}},ne=e=>{e.target===e.currentTarget&&t.onClose()};return(()=>{var e=yT(),i=e.firstChild.firstChild,s=i.firstChild.nextSibling,c=i.nextSibling,l=c.firstChild,u=l.firstChild,d=u.firstChild.nextSibling,f=u.nextSibling.firstChild.nextSibling,p=l.nextSibling,S=p.firstChild.nextSibling,w=S.nextSibling,E=w.nextSibling.firstChild,A=E.nextSibling,j=p.nextSibling,re=j.firstChild,ie=re.firstChild.nextSibling,ae=re.nextSibling,oe=j.nextSibling.firstChild,N=c.nextSibling.firstChild,se=N.nextSibling;return e.$$click=ne,s.$$click=()=>t.onClose(),T(s,n(ya,{size:18})),T(f,n(b,{each:DT,children:e=>(()=>{var t=bT(),n=t.firstChild;return t.$$click=()=>o(e),r(r=>{var i=a()===e?`#1f3a2a`:`#0d1117`,o=`1px solid ${a()===e?`#238636`:`#21262d`}`,s=a()===e?ee():CT[e];return i!==r.e&&B(t,`background`,r.e=i),o!==r.t&&B(t,`border`,r.t=o),s!==r.a&&R(n,`src`,r.a=s),r},{e:void 0,t:void 0,a:void 0}),t})()})),T(S,n(b,{each:ET,children:({slot:e,label:t})=>(()=>{var n=xT(),i=n.firstChild;return n.$$click=()=>y(e),T(n,t,null),r(t=>{var r=`1px solid ${v()===e?`#58a6ff`:`#30363d`}`,a=v()===e?`#1c2d47`:`transparent`,o=v()===e?`#58a6ff`:`#8b949e`,s=wT(D(e));return r!==t.e&&B(n,`border`,t.e=r),a!==t.t&&B(n,`background`,t.t=a),o!==t.a&&B(n,`color`,t.a=o),s!==t.o&&B(i,`background`,t.o=s),t},{e:void 0,t:void 0,a:void 0,o:void 0}),n})()})),T(w,n(b,{each:ft,children:e=>(()=>{var t=ST();return t.$$click=()=>O(e.index),r(n=>{var r=e.rgb,i=e.rgb,a=k(e.index)?`2px solid #fff`:`1px solid transparent`;return r!==n.e&&R(t,`title`,n.e=r),i!==n.t&&B(t,`background`,n.t=i),a!==n.a&&B(t,`border`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),t})()})),A.$$input=e=>M(e.currentTarget.value),T(ie,m),ae.$$input=e=>h(+e.currentTarget.value),oe.addEventListener(`change`,e=>_(e.currentTarget.checked)),N.$$click=()=>t.onClose(),se.$$click=te,T(se,()=>x()?`Saving…`:`Save Badge`),r(e=>{var t=ee(),n=OT.test(C())?C():wT(D(v())),r=`1px solid ${OT.test(C())?`#30363d`:`#f85149`}`,i=x(),a=x()?`not-allowed`:`pointer`,o=x(),s=x()?`not-allowed`:`pointer`,c=x()?.7:1;return t!==e.e&&R(d,`src`,e.e=t),n!==e.t&&B(E,`background`,e.t=n),r!==e.a&&B(A,`border`,e.a=r),i!==e.o&&(N.disabled=e.o=i),a!==e.i&&B(N,`cursor`,e.i=a),o!==e.n&&(se.disabled=e.n=o),s!==e.s&&B(se,`cursor`,e.s=s),c!==e.h&&B(se,`opacity`,e.h=c),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0}),r(()=>A.value=C()),r(()=>ae.value=m()),r(()=>oe.checked=g()),e})()}P([`click`,`input`]);var AT=z(`<button style="padding:7px;border-radius:4px;margin:0 4px;display:flex;align-items:center">`),jT=z(`<button title="World Map"style="position:absolute;top:8px;left:8px;z-index:5;padding:12px;border-radius:6px;border:1px solid #30363d;background:rgba(33,38,45,0.85);color:#c9d1d9;cursor:pointer;display:flex;align-items:center">`),MT=z(`<button title="Room overview"style="position:absolute;top:66px;left:8px;z-index:5;padding:12px;border-radius:6px;border:1px solid #30363d;background:rgba(33,38,45,0.85);color:#c9d1d9;cursor:pointer;display:flex;align-items:center">`),NT=z(`<button title=History style=position:absolute;top:124px;left:8px;z-index:5;padding:12px;border-radius:6px;color:#c9d1d9;display:flex;align-items:center>`),PT=z(`<div style=flex:1;position:relative;overflow:hidden>`),FT=z(`<div style="border-top:1px solid #30363d;overflow:hidden;position:relative"><div style=position:absolute;top:0;left:0;width:100%;height:4px;cursor:row-resize;z-index:10;background:#21262d>`),IT=z(`<div style="border-left:1px solid #30363d;overflow:hidden;position:relative"><div style=position:absolute;top:0;left:0;width:4px;height:100%;cursor:col-resize;z-index:10;background:#21262d>`),LT=z(`<div style=display:flex;flex:1;overflow:hidden><div style=display:flex;flex-direction:column;flex:1;overflow:hidden>`),RT=z(`<div style=position:absolute;top:0;left:0;right:0;bottom:0;z-index:10;overflow:hidden>`),zT=z(`<div style=width:100%;height:100%;display:flex;flex-direction:column;overflow:hidden;background:#0d1117><div style="display:flex;border-bottom:1px solid #30363d;align-items:center"><div style=flex:1></div></div><div style=flex:1;position:relative;overflow:hidden;display:flex;flex-direction:column>`),BT=z(`<button title=Login style="padding:7px;border-radius:4px;border:none;background:#238636;color:#fff;cursor:pointer;margin:0 16px 0 8px;display:flex;align-items:center">`),VT=z(`<div style=display:flex;flex-direction:column;flex:1;overflow:hidden><div style=display:flex;flex:1;overflow:hidden>`),HT=s(()=>tt(()=>import(`./CodePanel-CHPhho9S.js`).then(e=>({default:e.CodePanel})),__vite__mapDeps([0,1,2,3,4,5,6,7]))),UT=s(()=>tt(()=>import(`./SegmentsPanel-D5OVxC4l.js`).then(e=>({default:e.SegmentsPanel})),__vite__mapDeps([8,4,1,2,3,5,6,7,9]))),WT=s(()=>tt(()=>import(`./MapViewer-D3H3HyXS.js`).then(e=>({default:e.MapViewer})),__vite__mapDeps([10,1,2,3,4,5,6,7,11]))),GT={type:1,color1:`#4a5060`,color2:`#7a9ec0`,color3:`#c0daf0`,param:0,flip:!1};function KT(){return new URLSearchParams(window.location.search).get(`shard`)}function qT(){let e=`${Ve()}/room/`,t=window.location.pathname;if(!t.startsWith(e))return{room:null,shard:null,tick:null};let n=t.slice(e.length).split(`/`).filter(Boolean),r=n.length>=2?n[1]:n[0],i=n.length>=2?decodeURIComponent(n[0]):null;if(!r)return{room:null,shard:null,tick:null};let a=r.toUpperCase();if(!Yn(a))return{room:null,shard:null,tick:null};let o=i??KT(),s=window.location.hash.match(/tick=(\d+)/);return{room:a,shard:o,tick:s?parseInt(s[1],10):null}}function JT(){let e=`${Ve()}/map`,t=window.location.pathname;if(t!==e&&!t.startsWith(`${e}/`))return null;let n=t.slice(e.length).replace(/^\//,``);return{shard:(n?decodeURIComponent(n.split(`/`)[0]):null)??KT()}}function YT(e){return(()=>{var t=AT();return t.$$click=()=>e.onClick(),T(t,()=>e.children),r(n=>{var r=e.title,i=e.disabled,a=`1px solid ${e.active?`#388bfd`:`#30363d`}`,o=e.active?`#1f3158`:`#21262d`,s=e.disabled?`#484f58`:e.active?`#58a6ff`:`#c9d1d9`,c=e.disabled?`default`:`pointer`;return r!==n.e&&R(t,`title`,n.e=r),i!==n.t&&(t.disabled=n.t=i),a!==n.a&&B(t,`border`,n.a=a),o!==n.o&&B(t,`background`,n.o=o),s!==n.i&&B(t,`color`,n.i=s),c!==n.n&&B(t,`cursor`,n.n=c),n},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),t})()}function XT(){let t=qT(),[i,s]=e(t.room??oe(k.room)??`W1N1`),[c,l]=e(t.shard??oe(k.shard)),[u,d]=e(JT()!==null||!t.room),f=()=>Se()?.serverData?.welcomeText??null,[m,g]=e(!1),_=()=>be()&&u()&&!m()&&f()!==null,[v,y]=e(!1),[b,x]=e(!be()&&!H()?.badge),[S,C]=e(!1),[E,D]=e(!1);p(()=>{S(),Fp(),D(!0),Promise.resolve().then(()=>D(!1))}),p(()=>{Fp()&&(C(!1),y(!1))}),p(()=>{S()&&Ip(!1)}),p(()=>{be()&&tp(`view`)}),p(()=>{if(c()!==null||Oe()!==!1)return;let e=Se()?.serverData?.shards?.[0];e&&l(e)});let[O,A]=e(void 0),[ee,j]=e(null),[M,ne]=e(null),re=oe(k.mapZoom),[ae,N]=e(t.room&&re?Number(re):null),[P,ce]=e(null),le=()=>Se()?.serverData?.historyChunkSize??(Oe()??!0?20:100),ue=t.tick;p(()=>{let e=V();if(e===null||ue===null)return;let t=ue;ue=null,Nf(e,Se()?.serverData?.historyKeepTicks,le()),Ff(t)}),p(()=>{J()!==`game`&&(C(!1),y(!1),Ip(!1))}),p(()=>{if(w(u))return;let e=Fh(i(),c());q()?history.replaceState(null,``,`${e}#tick=${_f()}`):history.replaceState(null,``,e)});let[de,fe]=e(Ee(k.sidebarWidth,300)),[pe,me]=e(Ee(k.sidebarWidth,300)),[he,_e]=e(Ee(k.consoleHeight,220)),[ve,F]=e(Ee(k.consoleHeight,220)),[ye,xe]=e(!1),[Ce,Te]=e(!1),De=()=>de()<=32,ke=()=>he()<=32,R=()=>{de()>32?(me(de()),fe(32)):fe(pe())},Ae=()=>{he()>32?(F(he()),_e(32)):_e(ve())},z=e=>{e.preventDefault(),xe(!0);let t=e.clientX,n=de(),r=e=>{let r=e.clientX-t;fe(Math.max(32,Math.min(500,n-r)))},i=()=>{xe(!1),te(k.sidebarWidth,de()),window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)},je=e=>{e.preventDefault(),Te(!0);let t=e.clientY,n=he(),r=e=>{let r=e.clientY-t;_e(Math.max(32,Math.min(500,n-r)))},i=()=>{Te(!1),te(k.consoleHeight,he()),window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)},Me=(e,t)=>{L()?.stores.navigation.navigateTo(e,t)},Ne=()=>{let e=JT();if(e){d(!0),e.shard!==null&&l(e.shard),w(q)&&Pf();return}let{room:t,shard:n,tick:r}=qT();t&&(s(t),l(n),d(!1),r===null?w(q)&&Pf():ue=r)};p(e=>{let t=J();return t===`game`&&e!==void 0&&e!==`game`&&Ne(),t});let Pe=e=>{l(e),ie(k.shard,e),history.pushState(null,``,Ph(e))},Fe=e=>{w(q)&&Pf(),A(e),d(!0),history.pushState(null,``,Ph(c()))};o(()=>{!qT().room&&!JT()&&history.replaceState(null,``,Ph(c())),Jm(),a(Ym),window.addEventListener(`popstate`,Ne),a(()=>window.removeEventListener(`popstate`,Ne));let e=L()?.stores.navigation;if(e){let t=e.on(`navigation:change`,e=>{e.room!==null&&(w(q)&&Pf(),s(e.room),l(e.shard),d(!1),j(null),ne(null),ie(k.room,e.room),e.shard?ie(k.shard,e.shard):se(k.shard),history.pushState(null,``,Fh(e.room,e.shard)))});a(()=>t.dispose())}let t=e=>{if(!vn(e.target)){if(e.key===`o`||e.key===`O`){C(e=>!e),y(!1);return}(e.key===`l`||e.key===`L`)&&Hp(),(e.key===`c`||e.key===`C`)&&Up(),(e.key===`y`||e.key===`Y`)&&Wp(),u()||(e.key===`1`&&tp(`view`),be()||(e.key===`2`&&tp(`flag`),e.key===`3`&&tp(`build`)),e.key===`m`&&Fe(i()))}};window.addEventListener(`keydown`,t),a(()=>window.removeEventListener(`keydown`,t))});let Ie=()=>(()=>{var e=PT();return T(e,n(h,{get when(){return S()},get children(){return n(HT,{onClose:()=>C(!1)})}}),null),T(e,n(h,{get when(){return Fp()},get children(){return n(UT,{get shard(){return c()},onClose:()=>Ip(!1)})}}),null),T(e,n(h,{get when(){return!u()},get fallback(){return n(WT,{get shard(){return c()},get originRoom(){return O()},get initialZoom(){return ae()??void 0},onNavigateToRoom:e=>Me(e,c()),onHoveredRoomChanged:j,onSelectedRoomChanged:ne,onZoomChanged:e=>{N(e),te(k.mapZoom,e)},onSubscriptionStateChanged:ce})},get children(){return[n(Tp,{get room(){return i()},get shard(){return c()},onNavigate:Me}),(()=>{var e=jT();return e.$$click=()=>Fe(i()),T(e,n(Fi,{size:24})),e})(),(()=>{var e=MT();return e.$$click=()=>Rg(i(),c()),T(e,n(Lr,{size:24})),e})(),n(h,{get when(){return Mb().hasHistory},get children(){var e=NT();return e.$$click=()=>q()?Pf():V()!==null&&Nf(V(),Se()?.serverData?.historyKeepTicks,le()),T(e,n($r,{size:24})),r(t=>{var n=!q()&&V()===null,r=`1px solid ${q()?`#58a6ff`:`#30363d`}`,i=q()?`rgba(31,111,235,0.85)`:`rgba(33,38,45,0.85)`,a=!q()&&V()===null?`not-allowed`:`pointer`,o=!q()&&V()===null?.4:1;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&B(e,`border`,t.t=r),i!==t.a&&B(e,`background`,t.a=i),a!==t.o&&B(e,`cursor`,t.o=a),o!==t.i&&B(e,`opacity`,t.i=o),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}})]}}),null),T(e,n(h,{get when(){return _()},get children(){return n(hb,{get text(){return f()},onClose:()=>g(!0)})}}),null),e})(),Le=()=>n(h,{get when(){return!be()},get children(){var e=FT(),t=e.firstChild;return t.$$pointerdown=je,T(e,n(kh,{get shard(){return c()},get isCollapsed(){return ke()},onToggle:Ae}),null),r(t=>{var n=`${he()}px`,r=Ce()?`none`:`height 0.15s ease`;return n!==t.e&&B(e,`height`,t.e=n),r!==t.t&&B(e,`transition`,t.t=r),t},{e:void 0,t:void 0}),e}}),Re=e=>(()=>{var t=IT(),a=t.firstChild;return a.$$pointerdown=z,T(t,n(zy,{get isCollapsed(){return De()},onToggle:R,get mapMode(){return u()},get hoveredRoomInfo(){return ee()},get selectedRoomInfo(){return M()},get room(){return i()},get shard(){return c()},get mapZoom(){return ae()},get mapSubsActive(){return P()},onShardChange:Pe}),null),r(n=>{var r=S()||Fp()?`0`:`${de()}px`,i=e&&!(E()||ye())?`width 0.15s ease`:`none`;return r!==n.e&&B(t,`width`,n.e=r),i!==n.t&&B(t,`transition`,n.t=i),n},{e:void 0,t:void 0}),t})();return(()=>{var e=zT(),t=e.firstChild,r=t.firstChild,a=t.nextSibling;return T(t,n(is,{}),r),T(t,n(h,{get when(){return!be()||u()},get children(){return n(Gy,{get mapZoom(){return I(()=>!!u())()?ae():null},get mapSubsActive(){return I(()=>!!u())()?P():null}})}}),r),T(t,n(YT,{get title(){return J()===`user`?`Close overview`:`Overview`},get active(){return J()===`user`},get disabled(){return be()},onClick:()=>J()===`user`?zg():Eg(),get children(){return n(Ci,{size:16})}}),null),T(t,n(h,{get when(){return I(()=>!be())()&&Mb().hasMarket},get children(){return n(YT,{get title(){return J()===`market`?`Close Market`:`Market`},get active(){return J()===`market`},onClick:()=>J()===`market`?zg():Pg(c(),u()?null:i()),get children(){return n(la,{size:16})}})}}),null),T(t,n(h,{get when(){return!be()},get children(){return n(YT,{title:`Code Editor`,get active(){return S()},onClick:()=>{J()!==`game`&&zg(),C(e=>!e),y(!1)},get children(){return n(ti,{size:16})}})}}),null),T(t,n(h,{get when(){return!be()},get fallback(){return[n(YT,{title:`Settings`,get active(){return v()},onClick:()=>{J()!==`game`&&zg(),y(e=>!e),C(!1)},get children(){return n(ra,{size:16})}}),(()=>{var e=BT();return ge(e,`click`,we,!0),T(e,n(ki,{size:16})),e})()]},get children(){return n(kb,{onOpenSettings:()=>{J()!==`game`&&zg(),y(!0),C(!1)},onOpenBadgePicker:()=>x(!0)})}}),null),T(a,n(h,{get when(){return At()},get fallback(){return(()=>{var e=VT(),t=e.firstChild;return T(t,Ie,null),T(t,()=>Re(!0),null),T(e,Le,null),e})()},get children(){var e=LT(),t=e.firstChild;return T(t,Ie,null),T(t,Le,null),T(e,()=>Re(!1),null),e}}),null),T(a,n(h,{get when(){return J()===`user`||J()===`profile`||J()===`messages`||J()===`market`||J()===`room-overview`||v()},get children(){var e=RT();return T(e,n(h,{get when(){return J()===`user`},get children(){return n(RS,{})}}),null),T(e,n(h,{get when(){return J()===`profile`},get children(){return n(sC,{})}}),null),T(e,n(h,{get when(){return J()===`messages`},get children(){return n(GC,{})}}),null),T(e,n(h,{get when(){return J()===`market`},get children(){return n(_T,{})}}),null),T(e,n(h,{get when(){return J()===`room-overview`},get children(){return n(SC,{})}}),null),T(e,n(h,{get when(){return v()},get children(){return n(fb,{onClose:()=>y(!1)})}}),null),e}}),null),T(e,n(Op,{}),null),T(e,n(h,{get when(){return b()},get children(){return n(kT,{get badge(){return H()?.badge??GT},onClose:()=>x(!1)})}}),null),e})()}P([`click`,`pointerdown`]);var ZT=z(`<div style=width:100%;height:100%>`),{log:QT}=ce(`app`);function $T(){let e=new URLSearchParams(window.location.search).get(`guest`);return e===null?null:e.startsWith(`http`)?e:ae(N.url)??`https://screeps.com`}function eE(){let e=Mb();if(e.isXxscreepsMode||$T()!==null)return!0;let t=e.isEmbedded?M():ae(N.url);if(e.isDesktop)return!!t;let n=ae(N.token);return!!(t&&n)}function tE(){let t=()=>_e()===`connected`&&L()!==null,r=Mb(),i=r.isDesktop,[a,s]=e(eE());return o(async()=>{try{if(_e()===`idle`&&(await Be().catch(()=>{}),_e()!==`connected`)){if(r.isXxscreepsMode){let e=M();QT(`xxscreeps mode — auto-connecting as guest to ${e}`),await Ne({url:e,auth:`guest`,storage:null}).catch(()=>{})}else if(!r.isEmbedded){let e=$T();e&&(QT(`?guest param — auto-connecting as guest to ${e}`),await Ne({url:e,auth:`guest`,storage:null}).catch(()=>{}))}}}finally{s(!1)}}),(()=>{var e=ZT();return T(e,(()=>{var e=I(()=>!!t());return()=>e()?n(XT,{}):I(()=>!!a())()?n(Xo,{}):n(i?Jo:fo,{})})(),null),T(e,n(Qo,{}),null),T(e,n(ts,{}),null),e})()}ne()&&(await Me(),await tt(()=>import(`./init-BDelQmvs.js`),__vite__mapDeps([12,3,4])));var nE=document.getElementById(`root`);if(!nE)throw Error(`Root element not found`);Ie(()=>n(tE,{}),nE);
|