screeps-client 0.6.0 → 0.7.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/dist/embedded/_client/CodePanel-CVrM6x4v.js +1 -0
- package/dist/embedded/_client/MapViewer-COMbpdgT.js +1 -0
- package/dist/embedded/_client/decompress-DIM550rx.js +1 -0
- package/dist/embedded/_client/index-DDx5QnXZ.js +19 -0
- package/dist/embedded/_client/rolldown-runtime-QTnfLwEv.js +1 -0
- package/dist/embedded/_client/terrain.worker-BgNTQAMk.js +1 -0
- package/dist/embedded/_client/vendor-codemirror-B_kaIH0M.js +34 -0
- package/dist/embedded/_client/vendor-pixi-DseA5gVO.js +1274 -0
- package/dist/embedded/index.html +12 -3
- package/dist/standalone/_client/CodePanel-CwVNxrB0.js +1 -0
- package/dist/standalone/_client/MapViewer-B3Ow_Bmv.js +1 -0
- package/dist/standalone/_client/decompress-DIM550rx.js +1 -0
- package/dist/standalone/_client/index-q2IQJ_hs.js +19 -0
- package/dist/standalone/_client/rolldown-runtime-QTnfLwEv.js +1 -0
- package/dist/standalone/_client/terrain.worker-BgNTQAMk.js +1 -0
- package/dist/standalone/_client/vendor-codemirror-B_kaIH0M.js +34 -0
- package/dist/standalone/_client/vendor-pixi-_F6CfCZH.js +1274 -0
- package/dist/standalone/index.html +12 -3
- package/dist/xxscreeps-mod/_client/CodePanel-D6kl0sq1.js +1 -0
- package/dist/xxscreeps-mod/_client/MapViewer-B2pRqyZI.js +1 -0
- package/dist/xxscreeps-mod/_client/decompress-DIM550rx.js +1 -0
- package/dist/xxscreeps-mod/_client/index-DGByyYWv.js +19 -0
- package/dist/xxscreeps-mod/_client/rolldown-runtime-QTnfLwEv.js +1 -0
- package/dist/xxscreeps-mod/_client/terrain.worker-BgNTQAMk.js +1 -0
- package/dist/xxscreeps-mod/_client/vendor-codemirror-B_kaIH0M.js +34 -0
- package/dist/xxscreeps-mod/_client/vendor-pixi-DoK_ycfH.js +1274 -0
- package/dist/xxscreeps-mod/index.html +12 -3
- package/package.json +1 -1
- package/dist/embedded/_client/CodePanel-KBQ78175.js +0 -1
- package/dist/embedded/_client/MapViewer-BL7mzGWw.js +0 -1
- package/dist/embedded/_client/index-KFumkHjd.js +0 -24
- package/dist/embedded/_client/terrain.worker-D9zNeJfz.js +0 -1
- package/dist/embedded/_client/vendor-codemirror-D3PB7yT8.js +0 -24
- package/dist/embedded/_client/vendor-pixi-CWBnI4gg.js +0 -1280
- package/dist/standalone/_client/CodePanel-sM0UkfOw.js +0 -1
- package/dist/standalone/_client/MapViewer-B-eI44Qx.js +0 -1
- package/dist/standalone/_client/index-CHCJvDO3.js +0 -24
- package/dist/standalone/_client/terrain.worker-D9zNeJfz.js +0 -1
- package/dist/standalone/_client/vendor-codemirror-D3PB7yT8.js +0 -24
- package/dist/standalone/_client/vendor-pixi-DrpfKiIN.js +0 -1280
- package/dist/xxscreeps-mod/_client/CodePanel-Bfi6k72H.js +0 -1
- package/dist/xxscreeps-mod/_client/MapViewer-CKPZHZAs.js +0 -1
- package/dist/xxscreeps-mod/_client/index-04hhqfkD.js +0 -24
- package/dist/xxscreeps-mod/_client/terrain.worker-D9zNeJfz.js +0 -1
- package/dist/xxscreeps-mod/_client/vendor-codemirror-D3PB7yT8.js +0 -24
- package/dist/xxscreeps-mod/_client/vendor-pixi-CerEzm_8.js +0 -1280
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_client/decompress-DIM550rx.js","_client/rolldown-runtime-QTnfLwEv.js","_client/CodePanel-CwVNxrB0.js","_client/vendor-codemirror-B_kaIH0M.js","_client/MapViewer-B3Ow_Bmv.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{C as e,D as t,E as n,O as r,S as i,T as a,_ as o,b as s,c,d as l,f as u,g as d,h as f,l as p,m,p as h,s as g,u as _,v,w as y,x as b,y as x}from"./vendor-codemirror-B_kaIH0M.js";import{n as S,t as C}from"./decompress-DIM550rx.js";import{a as w,c as T,d as E,f as ee,i as D,l as O,m as te,n as ne,o as re,p as k,r as ie,s as ae,t as A,u as j}from"./vendor-pixi-_F6CfCZH.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 oe=new Set([`className`,`value`,`readOnly`,`noValidate`,`formNoValidate`,`isMap`,`noModule`,`playsInline`,`adAuctionHeaders`,`allowFullscreen`,`browsingTopics`,`defaultChecked`,`defaultMuted`,`defaultSelected`,`disablePictureInPicture`,`disableRemotePlayback`,`preservesPitch`,`shadowRootClonable`,`shadowRootCustomElementRegistry`,`shadowRootDelegatesFocus`,`shadowRootSerializable`,`sharedStorageWritable`,...`allowfullscreen.async.alpha.autofocus.autoplay.checked.controls.default.disabled.formnovalidate.hidden.indeterminate.inert.ismap.loop.multiple.muted.nomodule.novalidate.open.playsinline.readonly.required.reversed.seamless.selected.adauctionheaders.browsingtopics.credentialless.defaultchecked.defaultmuted.defaultselected.defer.disablepictureinpicture.disableremoteplayback.preservespitch.shadowrootclonable.shadowrootcustomelementregistry.shadowrootdelegatesfocus.shadowrootserializable.sharedstoragewritable`.split(`.`)]),M=new Set([`innerHTML`,`textContent`,`innerText`,`children`]),se=Object.assign(Object.create(null),{className:`class`,htmlFor:`for`}),ce=Object.assign(Object.create(null),{class:`className`,novalidate:{$:`noValidate`,FORM:1},formnovalidate:{$:`formNoValidate`,BUTTON:1,INPUT:1},ismap:{$:`isMap`,IMG:1},nomodule:{$:`noModule`,SCRIPT:1},playsinline:{$:`playsInline`,VIDEO:1},readonly:{$:`readOnly`,INPUT:1,TEXTAREA:1},adauctionheaders:{$:`adAuctionHeaders`,IFRAME:1},allowfullscreen:{$:`allowFullscreen`,IFRAME:1},browsingtopics:{$:`browsingTopics`,IMG:1},defaultchecked:{$:`defaultChecked`,INPUT:1},defaultmuted:{$:`defaultMuted`,AUDIO:1,VIDEO:1},defaultselected:{$:`defaultSelected`,OPTION:1},disablepictureinpicture:{$:`disablePictureInPicture`,VIDEO:1},disableremoteplayback:{$:`disableRemotePlayback`,AUDIO:1,VIDEO:1},preservespitch:{$:`preservesPitch`,AUDIO:1,VIDEO:1},shadowrootclonable:{$:`shadowRootClonable`,TEMPLATE:1},shadowrootdelegatesfocus:{$:`shadowRootDelegatesFocus`,TEMPLATE:1},shadowrootserializable:{$:`shadowRootSerializable`,TEMPLATE:1},sharedstoragewritable:{$:`sharedStorageWritable`,IFRAME:1,IMG:1}});function le(e,t){let n=ce[e];return typeof n==`object`?n[t]?n.$:void 0:n}var ue=new Set([`beforeinput`,`click`,`dblclick`,`contextmenu`,`focusin`,`focusout`,`input`,`keydown`,`keyup`,`mousedown`,`mousemove`,`mouseout`,`mouseover`,`mouseup`,`pointerdown`,`pointermove`,`pointerout`,`pointerover`,`pointerup`,`touchend`,`touchmove`,`touchstart`]),de=new Set(`altGlyph.altGlyphDef.altGlyphItem.animate.animateColor.animateMotion.animateTransform.circle.clipPath.color-profile.cursor.defs.desc.ellipse.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feDistantLight.feDropShadow.feFlood.feFuncA.feFuncB.feFuncG.feFuncR.feGaussianBlur.feImage.feMerge.feMergeNode.feMorphology.feOffset.fePointLight.feSpecularLighting.feSpotLight.feTile.feTurbulence.filter.font.font-face.font-face-format.font-face-name.font-face-src.font-face-uri.foreignObject.g.glyph.glyphRef.hkern.image.line.linearGradient.marker.mask.metadata.missing-glyph.mpath.path.pattern.polygon.polyline.radialGradient.rect.set.stop.svg.switch.symbol.text.textPath.tref.tspan.use.view.vkern`.split(`.`)),fe={xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`},N=e=>d(()=>e());function pe(e,t,n){let r=n.length,i=t.length,a=r,o=0,s=0,c=t[i-1].nextSibling,l=null;for(;o<i||s<a;){if(t[o]===n[s]){o++,s++;continue}for(;t[i-1]===n[a-1];)i--,a--;if(i===o){let t=a<r?s?n[s-1].nextSibling:n[a-s]:c;for(;s<a;)e.insertBefore(n[s++],t)}else if(a===s)for(;o<i;)(!l||!l.has(t[o]))&&t[o].remove(),o++;else if(t[o]===n[a-1]&&n[s]===t[i-1]){let r=t[--i].nextSibling;e.insertBefore(n[s++],t[o++].nextSibling),e.insertBefore(n[--a],r),t[i]=n[a]}else{if(!l){l=new Map;let e=s;for(;e<a;)l.set(n[e],e++)}let r=l.get(t[o]);if(r!=null)if(s<r&&r<a){let c=o,u=1,d;for(;++c<i&&c<a&&!((d=l.get(t[c]))==null||d!==r+u);)u++;if(u>r-s){let i=t[o];for(;s<r;)e.insertBefore(n[s++],i)}else e.replaceChild(n[s++],t[o++])}else o++;else t[o++].remove()}}}var me=`_$DX_DELEGATE`;function he(e,t,n,r={}){if(!t)throw Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");let i;return v(r=>{i=r,t===document?e():z(t,e(),t.firstChild?null:void 0,n)},r.owner),()=>{i(),t.textContent=``}}function P(e,t,n,i){let a,o=()=>{if(Te())throw Error(`Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.`);let t=i?document.createElementNS(`http://www.w3.org/1998/Math/MathML`,`template`):document.createElement(`template`);return t.innerHTML=e,n?t.content.firstChild.firstChild:i?t.firstChild:t.content.firstChild},s=t?()=>r(()=>document.importNode(a||=o(),!0)):()=>(a||=o()).cloneNode(!0);return s.cloneNode=s,s}function F(e,t=window.document){let n=t[me]||(t[me]=new Set);for(let r=0,i=e.length;r<i;r++){let i=e[r];n.has(i)||(n.add(i),t.addEventListener(i,ke))}}function I(e,t,n){Te(e)||(n==null?e.removeAttribute(t):e.setAttribute(t,n))}function ge(e,t,n,r){Te(e)||(r==null?e.removeAttributeNS(t,n):e.setAttributeNS(t,n,r))}function _e(e,t,n){Te(e)||(n?e.setAttribute(t,``):e.removeAttribute(t))}function ve(e,t){Te(e)||(t==null?e.removeAttribute(`class`):e.className=t)}function ye(e,t,n,r){if(r)Array.isArray(n)?(e[`$$${t}`]=n[0],e[`$$${t}Data`]=n[1]):e[`$$${t}`]=n;else if(Array.isArray(n)){let r=n[0];e.addEventListener(t,n[0]=t=>r.call(e,n[1],t))}else e.addEventListener(t,n,typeof n!=`function`&&n)}function be(e,t,n={}){let r=Object.keys(t||{}),i=Object.keys(n),a,o;for(a=0,o=i.length;a<o;a++){let r=i[a];!r||r===`undefined`||t[r]||(De(e,r,!1),delete n[r])}for(a=0,o=r.length;a<o;a++){let i=r[a],o=!!t[i];!i||i===`undefined`||n[i]===o||!o||(De(e,i,!0),n[i]=o)}return n}function L(e,t,n){if(!t)return n?I(e,`style`):t;let r=e.style;if(typeof t==`string`)return r.cssText=t;typeof n==`string`&&(r.cssText=n=void 0),n||={},t||={};let i,a;for(a in n)t[a]??r.removeProperty(a),delete n[a];for(a in t)i=t[a],i!==n[a]&&(r.setProperty(a,i),n[a]=i);return n}function R(e,t,n){n==null?e.style.removeProperty(t):e.style.setProperty(t,n)}function xe(e,t={},n,r){let i={};return r||o(()=>i.children=Ae(e,t.children,i.children)),o(()=>typeof t.ref==`function`&&Se(t.ref,e)),o(()=>Ce(e,t,n,!0,i,!0)),i}function Se(e,t,n){return r(()=>e(t,n))}function z(e,t,n,r){if(n!==void 0&&!r&&(r=[]),typeof t!=`function`)return Ae(e,t,r,n);o(r=>Ae(e,t(),r,n),r)}function Ce(e,t,n,r,i={},a=!1){t||={};for(let r in i)if(!(r in t)){if(r===`children`)continue;i[r]=Oe(e,r,null,i[r],n,a,t)}for(let o in t){if(o===`children`){r||Ae(e,t.children);continue}let s=t[o];i[o]=Oe(e,o,s,i[o],n,a,t)}}function we(e){let t,r,i=Te();if(!i||!(t=n.registry.get(r=Pe()))){if(i)throw n.done=!0,Error(`Hydration Mismatch. Unable to find DOM nodes for hydration key: ${r}\n${e?e().outerHTML:``}`);return e()}return n.completed&&n.completed.add(t),n.registry.delete(r),t}function Te(e){return!!n.context&&!n.done&&(!e||e.isConnected)}function Ee(e){return e.toLowerCase().replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function De(e,t,n){let r=t.trim().split(/\s+/);for(let t=0,i=r.length;t<i;t++)e.classList.toggle(r[t],n)}function Oe(e,t,n,r,i,a,o){let s,c,l,u,d;if(t===`style`)return L(e,n,r);if(t===`classList`)return be(e,n,r);if(n===r)return r;if(t===`ref`)a||n(e);else if(t.slice(0,3)===`on:`){let i=t.slice(3);r&&e.removeEventListener(i,r,typeof r!=`function`&&r),n&&e.addEventListener(i,n,typeof n!=`function`&&n)}else if(t.slice(0,10)===`oncapture:`){let i=t.slice(10);r&&e.removeEventListener(i,r,!0),n&&e.addEventListener(i,n,!0)}else if(t.slice(0,2)===`on`){let i=t.slice(2).toLowerCase(),a=ue.has(i);if(!a&&r){let t=Array.isArray(r)?r[0]:r;e.removeEventListener(i,t)}(a||n)&&(ye(e,i,n,a),a&&F([i]))}else if(t.slice(0,5)===`attr:`)I(e,t.slice(5),n);else if(t.slice(0,5)===`bool:`)_e(e,t.slice(5),n);else if((d=t.slice(0,5)===`prop:`)||(l=M.has(t))||!i&&((u=le(t,e.tagName))||(c=oe.has(t)))||(s=e.nodeName.includes(`-`)||`is`in o)){if(d)t=t.slice(5),c=!0;else if(Te(e))return n;t===`class`||t===`className`?ve(e,n):s&&!c&&!l?e[Ee(t)]=n:e[u||t]=n}else{let r=i&&t.indexOf(`:`)>-1&&fe[t.split(`:`)[0]];r?ge(e,r,t,n):I(e,se[t]||t,n)}return n}function ke(e){if(n.registry&&n.events&&n.events.find(([t,n])=>n===e))return;let t=e.target,r=`$$${e.type}`,i=e.target,a=e.currentTarget,o=t=>Object.defineProperty(e,"target",{configurable:!0,value:t}),s=()=>{let n=t[r];if(n&&!t.disabled){let i=t[`${r}Data`];if(i===void 0?n.call(t,e):n.call(t,i,e),e.cancelBubble)return}return t.host&&typeof t.host!=`string`&&!t.host._$host&&t.contains(e.target)&&o(t.host),!0},c=()=>{for(;s()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t||document}}),n.registry&&!n.done&&(n.done=_$HY.done=!0),e.composedPath){let n=e.composedPath();o(n[0]);for(let e=0;e<n.length-2&&(t=n[e],s());e++){if(t._$host){t=t._$host,c();break}if(t.parentNode===a)break}}else c();o(i)}function Ae(e,t,n,r,i){let a=Te(e);if(a){!n&&(n=[...e.childNodes]);let t=[];for(let e=0;e<n.length;e++){let r=n[e];r.nodeType===8&&r.data.slice(0,2)===`!$`?r.remove():t.push(r)}n=t}for(;typeof n==`function`;)n=n();if(t===n)return n;let s=typeof t,c=r!==void 0;if(e=c&&n[0]&&n[0].parentNode||e,s===`string`||s===`number`){if(a||s===`number`&&(t=t.toString(),t===n))return n;if(c){let i=n[0];i&&i.nodeType===3?i.data!==t&&(i.data=t):i=document.createTextNode(t),n=Ne(e,n,r,i)}else n=n!==``&&typeof n==`string`?e.firstChild.data=t:e.textContent=t}else if(t==null||s===`boolean`){if(a)return n;n=Ne(e,n,r)}else if(s===`function`)return o(()=>{let i=t();for(;typeof i==`function`;)i=i();n=Ae(e,i,n,r)}),()=>n;else if(Array.isArray(t)){let s=[],l=n&&Array.isArray(n);if(je(s,t,n,i))return o(()=>n=Ae(e,s,n,r,!0)),()=>n;if(a){if(!s.length)return n;if(r===void 0)return n=[...e.childNodes];let t=s[0];if(t.parentNode!==e)return n;let i=[t];for(;(t=t.nextSibling)!==r;)i.push(t);return n=i}if(s.length===0){if(n=Ne(e,n,r),c)return n}else l?n.length===0?Me(e,s,r):pe(e,n,s):(n&&Ne(e),Me(e,s));n=s}else if(t.nodeType){if(a&&t.parentNode)return n=c?[t]:t;if(Array.isArray(n)){if(c)return n=Ne(e,n,r,t);Ne(e,n,null,t)}else n==null||n===``||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}else console.warn(`Unrecognized value. Skipped inserting`,t);return n}function je(e,t,n,r){let i=!1;for(let a=0,o=t.length;a<o;a++){let o=t[a],s=n&&n[e.length],c;if(!(o==null||o===!0||o===!1))if((c=typeof o)==`object`&&o.nodeType)e.push(o);else if(Array.isArray(o))i=je(e,o,s)||i;else if(c===`function`)if(r){for(;typeof o==`function`;)o=o();i=je(e,Array.isArray(o)?o:[o],Array.isArray(s)?s:[s])||i}else e.push(o),i=!0;else{let t=String(o);s&&s.nodeType===3&&s.data===t?e.push(s):e.push(document.createTextNode(t))}}return i}function Me(e,t,n=null){for(let r=0,i=t.length;r<i;r++)e.insertBefore(t[r],n)}function Ne(e,t,n,r){if(n===void 0)return e.textContent=``;let i=r||document.createTextNode(``);if(t.length){let r=!1;for(let a=t.length-1;a>=0;a--){let o=t[a];if(i!==o){let t=o.parentNode===e;!r&&!a?t?e.replaceChild(i,o):e.insertBefore(i,n):t&&o.remove()}else r=!0}}else e.insertBefore(i,n);return[i]}function Pe(){return n.getNextContextId()}var Fe=`http://www.w3.org/2000/svg`;function Ie(e,t=!1,n=void 0){return t?document.createElementNS(Fe,e):document.createElement(e,{is:n})}function Le(e,t){let i=d(e);return d(()=>{let e=i();switch(typeof e){case`function`:return Object.assign(e,{[g]:!0}),r(()=>e(t));case`string`:let i=de.has(e),a=n.context?we():Ie(e,i,r(()=>t.is));return xe(a,t,i),a}})}function Re(e){let[,n]=t(e,[`component`]);return Le(()=>e.component,n)}var ze=class e{fn;constructor(e){this.fn=e}static create(t){return t===!0?new e(console.debug.bind(console)):typeof t==`function`?new e(t):new e(null)}child(t){if(!this.fn)return this;let n=this.fn;return new e((...e)=>n(`[screeps:${t}]`,...e))}log(...e){this.fn?.(...e)}};function Be(e){return{signin:(t,n)=>e.request(`POST`,`/api/auth/signin`,{email:t,password:n}),me:()=>e.request(`GET`,`/api/auth/me`),queryToken:t=>e.request(`GET`,`/api/auth/query-token`,{token:t}),steamTicket:(t,n)=>e.request(`POST`,`/api/auth/steam-ticket`,{ticket:t,...n==null?{}:{useNativeAuth:n}}),modInfo:()=>e.request(`GET`,`/api/authmod`)}}function Ve(e){return{list:()=>e.request(`GET`,`/api/game/power-creeps/list`),create:(t,n)=>e.request(`POST`,`/api/game/power-creeps/create`,{name:t,className:n}),delete:t=>e.request(`POST`,`/api/game/power-creeps/delete`,{id:t}),cancelDelete:t=>e.request(`POST`,`/api/game/power-creeps/cancel-delete`,{id:t}),upgrade:(t,n)=>e.request(`POST`,`/api/game/power-creeps/upgrade`,{id:t,powers:n}),rename:(t,n)=>e.request(`POST`,`/api/game/power-creeps/rename`,{id:t,name:n}),experimentation:()=>e.request(`POST`,`/api/game/power-creeps/experimentation`)}}function B(e,t){return t&&(e.shard=t),e}function He(e,t){return{roomTerrain:(t,n)=>e.request(`GET`,`/api/game/room-terrain`,B({room:t,encoded:1},n)),roomObjects:(t,n)=>e.request(`GET`,`/api/game/room-objects`,B({room:t},n)),roomDecorations:t?()=>Promise.resolve(t):(t,n)=>e.request(`GET`,`/api/game/room-decorations`,B({room:t},n)),roomStatus:(t,n)=>e.request(`GET`,`/api/game/room-status`,B({room:t},n)),roomOverview:(t,n=8,r)=>e.request(`GET`,`/api/game/room-overview`,B({room:t,interval:n},r)),time:t=>e.request(`GET`,`/api/game/time`,B({},t)),worldSize:t=>e.request(`GET`,`/api/game/world-size`,B({},t)),mapStats:(t,n,r)=>e.request(`POST`,`/api/game/map-stats`,B({rooms:t,statName:n},r)),roomsTerrain:(t,n)=>{let r=new URLSearchParams({encoded:`true`});return n&&r.set(`shard`,n),e.request(`POST`,`/api/game/rooms?${r}`,{rooms:t})},createFlag:(t,n,r,i,a,o,s)=>e.request(`POST`,`/api/game/create-flag`,B({room:t,x:n,y:r,name:i,color:a,secondaryColor:o},s)),genUniqueFlagName:()=>e.request(`POST`,`/api/game/gen-unique-flag-name`),checkUniqueFlagName:t=>e.request(`POST`,`/api/game/check-unique-flag-name`,{name:t}),changeFlagColor:(t,n,r,i)=>e.request(`POST`,`/api/game/change-flag-color`,{room:t,name:n,color:r,secondaryColor:i}),removeFlag:(t,n)=>e.request(`POST`,`/api/game/remove-flag`,{room:t,name:n}),genUniqueObjectName:(t,n)=>e.request(`POST`,`/api/game/gen-unique-object-name`,B({type:t},n)),checkUniqueObjectName:(t,n,r)=>e.request(`POST`,`/api/game/check-unique-object-name`,B({type:t,name:n},r)),placeSpawn:(t,n,r,i,a)=>e.request(`POST`,`/api/game/place-spawn`,B({room:t,x:n,y:r,...i?{name:i}:{}},a)),createConstruction:(t,n,r,i,a,o)=>e.request(`POST`,`/api/game/create-construction`,B({room:t,x:n,y:r,structureType:i,...a?{name:a}:{}},o)),removeConstructionSite:(t,n,r)=>e.request(`POST`,`/api/game/add-object-intent`,B({_id:`room`,room:t,name:`removeConstructionSite`,intent:n.map(e=>({id:e,roomName:t}))},r)),addObjectIntent:(t,n,r,i,a)=>e.request(`POST`,`/api/game/add-object-intent`,B({_id:t,room:n,name:r,intent:i},a)),addGlobalIntent:(t,n)=>e.request(`POST`,`/api/game/add-global-intent`,{name:t,intent:n}),roomHistory:(t,n,r)=>r?e.request(`GET`,`/room-history/${encodeURIComponent(r)}/${encodeURIComponent(t)}/${n}.json`):e.request(`GET`,`/room-history`,{room:t,time:n}),setNotifyWhenAttacked:(t,n)=>e.request(`POST`,`/api/game/set-notify-when-attacked`,{_id:t,enabled:n}),createInvader:(t,n,r,i,a,o)=>e.request(`POST`,`/api/game/create-invader`,{room:t,x:n,y:r,size:i,type:a,...o==null?{}:{boosted:o}}),removeInvader:t=>e.request(`POST`,`/api/game/remove-invader`,{_id:t}),tick:()=>e.request(`GET`,`/api/game/tick`),powerCreeps:Ve(e),market:{ordersIndex:t=>e.request(`GET`,`/api/game/market/orders-index`,B({},t)),myOrders:()=>e.request(`GET`,`/api/game/market/my-orders`),orders:(t,n)=>e.request(`GET`,`/api/game/market/orders`,B({resourceType:t},n)),stats:(t,n)=>e.request(`GET`,`/api/game/market/stats`,B({resourceType:t},n))},shards:{info:()=>e.request(`GET`,`/api/game/shards/info`)}}}function Ue(e){return{send:(t,n)=>e.request(`POST`,`/api/user/messages/send`,{respondent:t,text:n}),list:t=>e.request(`GET`,`/api/user/messages/list`,{respondent:t}),index:()=>e.request(`GET`,`/api/user/messages/index`),markRead:t=>e.request(`POST`,`/api/user/messages/mark-read`,{id:t}),unreadCount:()=>e.request(`GET`,`/api/user/messages/unread-count`)}}function We(e,t){return t&&(e.shard=t),e}function Ge(e){return{branches:()=>e.request(`GET`,`/api/user/branches`),code:{get:t=>e.request(`GET`,`/api/user/code`,t?{branch:t}:{}),set:(t,n)=>e.request(`POST`,`/api/user/code`,{branch:t,modules:n,_hash:Date.now()})},memory:{get:(t,n)=>e.request(`GET`,`/api/user/memory`,We({path:t},n)),set:(t,n,r)=>e.request(`POST`,`/api/user/memory`,We({path:t,value:n},r)),segment:{get:(t,n)=>e.request(`GET`,`/api/user/memory-segment`,We({segment:t},n)),set:(t,n,r)=>e.request(`POST`,`/api/user/memory-segment`,We({segment:t,data:n},r))}},console:(t,n)=>e.request(`POST`,`/api/user/console`,We({expression:t},n)),stats:t=>e.request(`GET`,`/api/user/stats`,{interval:t}),rooms:t=>e.request(`GET`,`/api/user/rooms`,{id:t}),overview:(t,n)=>e.request(`GET`,`/api/user/overview`,{interval:t,statName:n}),worldStatus:()=>e.request(`GET`,`/api/user/world-status`),worldStartRoom:t=>e.request(`GET`,`/api/user/world-start-room`,We({},t)),find:t=>e.request(`GET`,`/api/user/find`,t),moneyHistory:t=>e.request(`GET`,`/api/user/money-history`,t==null?{}:{page:t}),respawn:()=>e.request(`POST`,`/api/user/respawn`),respawnProhibitedRooms:()=>e.request(`GET`,`/api/user/respawn-prohibited-rooms`),badge:t=>e.request(`POST`,`/api/user/badge`,{badge:t}),setActiveBranch:(t,n)=>e.request(`POST`,`/api/user/set-active-branch`,{activeName:t,branch:n}),cloneBranch:(t,n,r)=>e.request(`POST`,`/api/user/clone-branch`,{newName:t,...n?{branch:n}:{},...r==null?{}:{defaultModules:r}}),deleteBranch:t=>e.request(`POST`,`/api/user/delete-branch`,{branch:t}),notifyPrefs:t=>e.request(`POST`,`/api/user/notify-prefs`,t),tutorialDone:()=>e.request(`POST`,`/api/user/tutorial-done`),email:t=>e.request(`POST`,`/api/user/email`,{email:t}),setSteamVisible:t=>e.request(`POST`,`/api/user/set-steam-visible`,{visible:t}),password:(t,n)=>e.request(`POST`,`/api/user/password`,{password:t,...n==null?{}:{oldPassword:n}}),messages:Ue(e)}}function Ke(e){return{list:(t=10,n=`world`,r=0,i)=>e.request(`GET`,`/api/leaderboard/list`,{limit:t,mode:n,offset:r,season:i}),find:(t,n=`world`,r=``)=>e.request(`GET`,`/api/leaderboard/find`,{username:t,mode:n,season:r}),seasons:()=>e.request(`GET`,`/api/leaderboard/seasons`)}}function qe(e){return{pvp:(t=100)=>e.request(`GET`,`/api/experimental/pvp`,{interval:t}),nukes:()=>e.request(`GET`,`/api/experimental/nukes`)}}function Je(e){return{checkEmail:t=>e.request(`GET`,`/api/register/check-email`,{email:t}),checkUsername:t=>e.request(`GET`,`/api/register/check-username`,{username:t}),setUsername:(t,n)=>e.request(`POST`,`/api/register/set-username`,{username:t,...n==null?{}:{email:n}}),submit:(t,n,r,i)=>e.request(`POST`,`/api/register/submit`,{username:t,email:n,password:r,...i==null?{}:{modules:i}})}}var Ye=class extends EventTarget{baseUrl;authStrategy;logger;serverPassword;token=null;rateLimits=new Map;authenticating=!1;auth;register;game;user;leaderboard;experimental;constructor(e){super(),this.baseUrl=e.url.endsWith(`/`)?e.url:`${e.url}/`,this.authStrategy=e.auth,this.logger=e.logger??ze.create(),this.serverPassword=e.serverPassword??null,this.auth=Be(this),this.register=Je(this),this.game=He(this,e.decorationsMock),this.user=Ge(this),this.leaderboard=Ke(this),this.experimental=qe(this)}emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))}on(e,t){let n=e=>t(e.detail);return this.addEventListener(e,n),{dispose:()=>{this.removeEventListener(e,n)}}}async authenticate(){this.logger.log(`authenticate`),this.authenticating=!0;try{this.token=await this.authStrategy.authenticate(this),this.logger.log(`authenticated`)}finally{this.authenticating=!1}}setToken(e){this.token=e}async request(e,t,n,r=!1){this.logger.log(e,t);let i=new URL(t.startsWith(`/`)?t.slice(1):t,this.baseUrl),a={};this.token&&(a[`X-Token`]=this.token,a[`X-Username`]=this.token),this.serverPassword&&(a[`X-Server-Password`]=this.serverPassword);let o={method:e,headers:a};if(e===`GET`&&n)for(let[e,t]of Object.entries(n))t!=null&&i.searchParams.set(e,String(t));else n&&(a[`Content-Type`]=`application/json`,o.body=JSON.stringify(n));let s=await fetch(i.toString(),o),c=s.headers.get(`x-token`);if(c&&(this.token=c,this.emit(`http:tokenRefresh`,{token:c})),this.updateRateLimit(t,s),s.status===401&&!r&&!this.authenticating)return await this.authenticate(),this.request(e,t,n,!0);if(!s.ok&&s.status!==304){let n=``;try{n=await s.text()}catch{}let r=Error(`HTTP ${s.status}: ${n}`);throw this.emit(`http:error`,{method:e,path:t,status:s.status,error:r}),r}this.emit(`http:success`,{method:e,path:t,status:s.status});let l=await s.json();if(typeof l.error==`string`){let n=Error(`Screeps API error: ${l.error}`);throw this.emit(`http:error`,{method:e,path:t,status:s.status,error:n}),n}return typeof l.data==`string`&&l.data.startsWith(`gz:`)&&(l.data=await C(l.data)),l}updateRateLimit(e,t){let n=t.headers.get(`x-ratelimit-limit`),r=t.headers.get(`x-ratelimit-remaining`),i=t.headers.get(`x-ratelimit-reset`);n&&r&&i&&this.rateLimits.set(e,{limit:parseInt(n,10),remaining:parseInt(r,10),reset:parseInt(i,10)})}};async function Xe(e){let t=typeof e==`string`?e:e.data;if(t.startsWith(`gz:`)&&(t=JSON.stringify(await S(t))),t.startsWith(`[`)){let[e,n]=JSON.parse(t);return{kind:`channel`,message:{channel:e,data:n}}}let[n,...r]=t.split(` `);switch(n){case`auth`:return{kind:`server`,command:{type:`auth`,status:r[0],token:r[1]}};case`time`:return{kind:`server`,command:{type:`time`,time:parseInt(r[0],10)}};case`protocol`:return{kind:`server`,command:{type:`protocol`,protocol:parseInt(r[0],10)}};case`package`:return{kind:`server`,command:{type:`package`,package:parseInt(r[0],10)}};default:throw Error(`Unknown server command: ${n}`)}}var Ze=class{wsUrl;WS;logger;ws=null;token=null;authed=!1;_connected=!1;reconnecting=!1;authSub=null;queue=[];subs=new Map;listeners=new Map;MAX_RETRIES=10;MAX_DELAY_MS=6e4;_intentionalClose=!1;constructor(e){let t=e.url.replace(/^http/,`ws`).replace(/\/$/,``);this.wsUrl=`${t}/socket/websocket`,this.WS=e.WebSocket??globalThis.WebSocket,this.logger=e.logger??ze.create()}get isConnected(){return this._connected}setToken(e){this.token=e}connect(e){return this.logger.log(`connect`,this.wsUrl),this.reconnecting||(this._intentionalClose=!1),this.token=e,this.authSub?.dispose(),this.authSub=null,new Promise((e,t)=>{this.ws=new this.WS(this.wsUrl),this.ws.onopen=()=>{this.logger.log(`WebSocket opened`),this._connected=!0,this.reconnecting=!1,this.rawSend(`auth ${this.token}`),this.authSub=this.once(`auth`,n=>{let r=n;if(r.status===`ok`){for(this.logger.log(`auth ok`),this.authed=!0,r.token&&(this.token=r.token,this.emit(`socket:tokenRefresh`,{token:r.token}));this.queue.length;)this.rawSend(this.queue.shift());this.emit(`connected`,{}),e()}else this.logger.log(`auth failed`),t(Error(`WebSocket auth failed`))})},this.ws.onclose=()=>{this.logger.log(`WebSocket closed`),this._connected=!1,this.authed=!1,this.authSub?.dispose(),this.authSub=null,this.emit(`disconnected`,{willReconnect:this.reconnecting}),this.scheduleReconnect()},this.ws.onerror=e=>{this._connected||t(e)},this.ws.onmessage=e=>{this.handleMessage(e).catch(t=>{let n=typeof e.data==`string`?e.data.slice(0,200):`(binary)`;this.logger.log(`message parse error`,t instanceof Error?t.stack??t.message:String(t),`raw:`,n),this.emit(`socket:error`,t instanceof Error?t:Error(String(t)))})}})}disconnect(){this.logger.log(`disconnect`),this._intentionalClose=!0,this.reconnecting=!1,this.ws?.close(),this.ws=null,this._connected=!1,this.authed=!1,this.queue.length=0}activeSubs(){return Array.from(this.subs.entries()).map(([e,t])=>`${e}(${t})`).join(`, `)||`(none)`}subscribe(e){let t=this.subs.get(e)??0;return this.subs.set(e,t+1),t===0?(this.logger.log(`subscribe`,e,`active:`,this.activeSubs()),this.sendOrQueue(`subscribe ${e}`)):this.logger.log(`subscribe`,e,`(refs: ${t+1})`,`active:`,this.activeSubs()),{dispose:()=>this.doUnsubscribe(e)}}on(e,t){let n=this.listeners.get(e);return n||(n=new Set,this.listeners.set(e,n)),n.add(t),{dispose:()=>{this.listeners.get(e)?.delete(t)}}}once(e,t){let n=this.on(e,e=>{n.dispose(),t(e)});return n}doUnsubscribe(e){let t=this.subs.get(e)??0;t<=1?(this.subs.delete(e),this.authed&&this.rawSend(`unsubscribe ${e}`),this.logger.log(`unsubscribe`,e,`active:`,this.activeSubs())):(this.subs.set(e,t-1),this.logger.log(`unsubscribe`,e,`(refs: ${t-1})`,`active:`,this.activeSubs()))}rawSend(e){this.ws?.send(e)}sendOrQueue(e){this.authed?this.rawSend(e):this.queue.push(e)}emit(e,t){this.listeners.get(e)?.forEach(n=>{try{n(t)}catch(t){this.logger.log(`listener error on channel`,e,t instanceof Error?t.stack??t.message:String(t))}})}async handleMessage(e){let t=await Xe(e);t.kind===`server`?this.emit(t.command.type,t.command):this.emit(t.message.channel,t.message.data)}async scheduleReconnect(){if(this.reconnecting||this._intentionalClose)return;if(!this.token){this.reconnecting=!1;return}this.reconnecting=!0;let e=0;for(;e<this.MAX_RETRIES&&this.reconnecting&&!this._intentionalClose;){let t=Math.min(2**e*100,this.MAX_DELAY_MS);if(this.logger.log(`reconnect attempt ${e+1}/${this.MAX_RETRIES} in ${t}ms`),await new Promise(e=>setTimeout(e,t)),!this.reconnecting||this._intentionalClose)return;try{if(await this.connect(this.token),this._intentionalClose){this.ws?.close(),this.ws=null;return}for(let e of this.subs.keys())this.rawSend(`subscribe ${e}`);return}catch{e++}}this.reconnecting=!1,e>=this.MAX_RETRIES&&!this._intentionalClose&&this.emit(`socket:error`,Error(`WebSocket reconnection failed after ${this.MAX_RETRIES} retries`))}},Qe=class{memory=new Map;storage;namespace;constructor(e,t){this.namespace=e,this.storage=t}memKey(e){return`${this.namespace}/${e}`}get(e){let t=this.memory.get(this.memKey(e));if(t){if(t.expires!==void 0&&Date.now()>t.expires){this.memory.delete(this.memKey(e));return}return t.data}}set(e,t,n){this.memory.set(this.memKey(e),{data:t,expires:n===void 0?void 0:Date.now()+n})}delete(e){this.memory.delete(this.memKey(e))}async getPersistent(e){return this.storage?this.storage.get(`${this.namespace}/${e}`):null}async setPersistent(e,t){this.storage&&await this.storage.set(`${this.namespace}/${e}`,t)}async deletePersistent(e){this.storage&&await this.storage.delete(`${this.namespace}/${e}`)}clearMemory(){this.memory.clear()}async clearPersistent(){this.storage&&await this.storage.clear()}async clearAll(){this.clearMemory(),await this.clearPersistent()}},$e=class extends EventTarget{logger;constructor(e){super(),this.logger=e??ze.create()}emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))}on(e,t){this.logger.log(`on "${e}"`);let n=e=>t(e.detail);return this.addEventListener(e,n),{dispose:()=>{this.logger.log(`off "${e}"`),this.removeEventListener(e,n)}}}},et=function(e){return e[e.Plain=0]=`Plain`,e[e.Wall=1]=`Wall`,e[e.Swamp=2]=`Swamp`,e}({}),tt=class e{raw;constructor(e){this.raw=e}static fromEncodedString(t){let n=new Uint8Array(2500);for(let e=0;e<2500;e++){let r=parseInt(t[e],10);n[e]=r===3?1:r}return new e(n)}get(e,t){return this.raw[t*50+e]}},nt=class extends $e{http;socket;cache;roomObjects=new Map;roomUsers=new Map;roomSubCount=new Map;lastFlagsString=new Map;parseFlagsString(e,t){if(!e||e.length===0)return[];let n=[],r=e.split(`|`);for(let e of r){let r=e.split(`~`);if(r.length!==5)continue;let[i,a,o,s,c]=r,l=parseInt(a,10),u=parseInt(o,10),d=parseInt(s,10),f=parseInt(c,10);isNaN(l)||isNaN(u)||isNaN(d)||isNaN(f)||n.push({_id:i,type:`flag`,room:t,name:i,x:d,y:f,color:l,secondaryColor:u})}return n}constructor(e,t,n,r){super(r),this.http=e,this.socket=t,this.cache=n}async terrain(e,t){let n=`terrain/${t}/${e}`,r=this.cache.get(n);if(r)return this.logger.log(`terrain`,e,t,`(memory cache hit)`),r;let i=await this.cache.getPersistent(n);if(i){this.logger.log(`terrain`,e,t,`(persistent cache hit)`);let r=new tt(i);return this.cache.set(n,r),r}this.logger.log(`terrain`,e,t,`(fetching)`);let a=(await this.http.game.roomTerrain(e,t??void 0)).terrain[0];if(!a)throw Error(`No terrain data for room ${e} shard ${t}`);let o=tt.fromEncodedString(a.terrain);return this.cache.set(n,o),await this.cache.setPersistent(n,o.raw),this.emit(`room:terrainavailable`,{room:e,shard:t,terrain:o}),o}async terrainBulk(e,t){let n=new Map,r=[];for(let i of e){let e=this.cache.get(`terrain/${t}/${i}`);e?n.set(i,e):r.push(i)}if(r.length===0)return n;let i=[];if(await Promise.all(r.map(async e=>{let r=`terrain/${t}/${e}`,a=await this.cache.getPersistent(r);if(a){let t=new tt(a);this.cache.set(r,t),n.set(e,t)}else i.push(e)})),i.length===0)return n;this.logger.log(`terrainBulk`,`fetching ${i.length} rooms`,t);let a=await this.http.game.roomsTerrain(i,t??void 0);return await Promise.all(a.rooms.map(async e=>{let r=tt.fromEncodedString(e.terrain),i=`terrain/${t}/${e.room}`;this.cache.set(i,r),await this.cache.setPersistent(i,r.raw),this.emit(`room:terrainavailable`,{room:e.room,shard:t,terrain:r}),n.set(e.room,r)})),n}objects(e,t){let n=this.roomObjects.get(`${e}/${t}`);return n?{...n}:null}async fetchObjects(e,t){let n=`${e}/${t}`,r=await this.http.game.roomObjects(e,t??void 0),i={};for(let e of r.objects)e&&typeof e==`object`&&`_id`in e&&(i[e._id]=e);this.roomObjects.set(n,i);let a=this.roomUsers.get(n);this.emit(`room:update`,{room:e,shard:t,gameTime:void 0,objects:i,diff:i,visual:``,users:a})}activeRooms(){return Array.from(this.roomSubCount.entries()).map(([e,t])=>`${e}(${t})`).join(`, `)||`(none)`}subscribe(e,t){let n=`${e}/${t}`,r=this.roomSubCount.get(n)??0;this.roomSubCount.set(n,r+1),this.logger.log(`subscribe`,e,t,`(refs: ${r+1})`,`active:`,this.activeRooms());let i=t?`room:${t}/${e}`:`room:${e}`,a=t?`err@room:${t}/${e}`:`err@room:${e}`,o=this.socket.subscribe(i),s=this.socket.on(a,n=>{let r=typeof n==`string`?n:JSON.stringify(n);this.logger.log(`room error`,e,t,r),this.emit(`room:error`,{room:e,shard:t,message:r})}),c=this.socket.on(i,r=>{let i=r,a={...this.roomObjects.get(n)??{}};if(i.objects==null)i.objects===null&&this.logger.log(`room update has null objects field`,e,t,`gameTime: ${i.gameTime}`);else for(let[e,t]of Object.entries(i.objects))t===null?delete a[e]:a[e]?a[e]={...a[e],...t}:a[e]=t;let o={...i.objects??{}};if(`flags`in i){let t=i.flags??``;if(t!==(this.lastFlagsString.get(n)??``)){this.lastFlagsString.set(n,t);let r=this.parseFlagsString(t,e),i=new Map;for(let e of r)i.set(e.name,e);for(let t in a)a[t]?.type===`flag`&&!i.has(t)&&(delete a[t],o[t]=null,this.logger.log(`[flag:room] removed ${t} @ ${e}`));for(let[t,n]of i){let r=a[t];(!r||r.x!==n.x||r.y!==n.y||r.color!==n.color||r.secondaryColor!==n.secondaryColor)&&(a[t]=n,o[t]=n,this.logger.log(`[flag:room] ${r?`changed`:`added`} ${t} @ ${e} (${n.x},${n.y})`))}}}if(i.users){let e=this.roomUsers.get(n)??{};this.roomUsers.set(n,{...e,...i.users})}this.roomObjects.set(n,a);let s=this.roomUsers.get(n);this.emit(`room:update`,{room:e,shard:t,gameTime:i.gameTime,objects:a,diff:o,visual:i.visual??``,users:s})});return{dispose:()=>{o.dispose(),c.dispose(),s.dispose();let r=(this.roomSubCount.get(n)??1)-1;r<=0?(this.roomSubCount.delete(n),this.roomObjects.delete(n),this.roomUsers.delete(n),this.lastFlagsString.delete(n),this.logger.log(`unsubscribe`,e,t,`(last ref)`,`active:`,this.activeRooms())):(this.roomSubCount.set(n,r),this.logger.log(`unsubscribe`,e,t,`(refs: ${r})`,`active:`,this.activeRooms()))}}}},rt=class extends $e{http;socket;cache;console=[];maxConsoleSize;_cpu=null;get cpu(){return this._cpu}_userInfo=null;get userInfo(){return this._userInfo}_userId=null;get userId(){return this._userId}_worldStatus=null;get worldStatusValue(){return this._worldStatus}_mePromise=null;constructor(e,t,n,r,i=100){super(r),this.http=e,this.socket=t,this.cache=n,this.maxConsoleSize=i}async me(){let e=this.cache.get(`user/me`);return e?(this._userId=e._id,this._userInfo=e,e):this._mePromise?this._mePromise:(this.logger.log(`fetch me`),this._mePromise=this.http.auth.me().then(e=>{let t=e;return this._userId=t._id,this._userInfo=t,this.cache.set(`user/me`,t,6e4),this.emit(`user:me`,t),t}).finally(()=>{this._mePromise=null}),this._mePromise)}async refreshMe(){return this.logger.log(`refresh me`),this.cache.delete(`user/me`),this.me()}async worldStatus(){let e=this.cache.get(`user/worldStatus`);if(e)return this._worldStatus=e,e;this.logger.log(`fetch world status`);let t=await this.http.user.worldStatus();return this._worldStatus=t.status,this.cache.set(`user/worldStatus`,t.status,6e4),this.emit(`user:worldStatus`,{status:t.status}),t.status}async refreshWorldStatus(){return this.logger.log(`refresh world status`),this.cache.delete(`user/worldStatus`),this.worldStatus()}subscribe(e){this.logger.log(`subscribe`,e);let t=null,n=null,r=!1;return(async()=>{try{let i=this._userId??(await this.me())._id;if(r)return;let a=`user:${i}/${e}`;t=this.socket.subscribe(a),n=this.socket.on(a,t=>{if(e===`cpu`)this._cpu=t,this.emit(`user:cpu`,this._cpu);else if(e===`console`){let e=t,n={log:e.messages?.log??[],results:e.messages?.results??[],error:e.messages?.error??[]};e.error&&n.error.push(e.error),this.console.push(n),this.console.length>this.maxConsoleSize&&this.console.splice(0,this.console.length-this.maxConsoleSize),this.emit(`user:console`,{messages:n})}else e===`code`&&this.emit(`user:code`,t)})}catch(e){r||this.dispatchEvent(new ErrorEvent(`error`,{error:e instanceof Error?e:Error(String(e))}))}})(),{dispose:()=>{this.logger.log(`unsubscribe`,e),r=!0,t?.dispose(),n?.dispose()}}}subscribeMemory(e,t){this.logger.log(`subscribe memory`,e);let n=null,r=null,i=!1;return(async()=>{try{let a=this._userId??(await this.me())._id;if(i)return;let o=`user:${a}/memory/${t?`${t}/`:``}${e}`;n=this.socket.subscribe(o),r=this.socket.on(o,n=>{if(typeof n==`string`&&n.startsWith(`gz:`)){(async()=>{try{let{decompressZlib:r}=await te(async()=>{let{decompressZlib:e}=await import(`./decompress-DIM550rx.js`).then(e=>e.r);return{decompressZlib:e}},__vite__mapDeps([0,1])),i=await r(n);this.emit(`user:memory`,{path:e,shard:t??null,value:i})}catch(e){this.logger.log(`memory decompress failed`,e)}})();return}if(n===`[object Object]`){this.logger.log(`memory object placeholder`,e),this.emit(`user:memory`,{path:e,shard:t??null,value:{__screeps_object__:!0}});return}let r=n;if(n===`undefined`)r=void 0;else if(typeof n==`string`)try{r=JSON.parse(n)}catch{}this.logger.log(`memory value received`,e,r),this.emit(`user:memory`,{path:e,shard:t??null,value:r})})}catch(e){i||this.dispatchEvent(new ErrorEvent(`error`,{error:e instanceof Error?e:Error(String(e))}))}})(),{dispose:()=>{this.logger.log(`unsubscribe memory`,e),i=!0,n?.dispose(),r?.dispose()}}}subscribeMapVisual(e){this.logger.log(`subscribe mapVisual`,e);let t=null,n=null,r=!1;return(async()=>{try{let i=this._userId??(await this.me())._id;if(r)return;let a=e?`mapVisual:${i}/${e}`:`mapVisual:${i}`;t=this.socket.subscribe(a),n=this.socket.on(a,t=>{this.emit(`user:mapVisual`,{shard:e,data:typeof t==`string`?t:``})})}catch(e){r||this.dispatchEvent(new ErrorEvent(`error`,{error:e instanceof Error?e:Error(String(e))}))}})(),{dispose:()=>{this.logger.log(`unsubscribe mapVisual`,e),r=!0,t?.dispose(),n?.dispose()}}}subscribeUserStream(){this.logger.log(`subscribe user stream`);let e=null,t=null,n=!1;return(async()=>{try{let r=this._userId??(await this.me())._id;if(n)return;let i=`user:${r}`;e=this.socket.subscribe(i),t=this.socket.on(i,e=>{let t=e;if(t&&typeof t==`object`&&`flags`in t){let e=t.flags;if(e&&typeof e==`object`)for(let[t,n]of Object.entries(e)){let e=n;if(e&&typeof e==`object`){let n=e.room??`unknown`,r=e.x??`?`,i=e.y??`?`;this.logger.log(`[flag:user] ${t} @ ${n} (${r},${i})`)}}}this.emit(`user:stream`,t)})}catch(e){n||this.dispatchEvent(new ErrorEvent(`error`,{error:e instanceof Error?e:Error(String(e))}))}})(),{dispose:()=>{this.logger.log(`unsubscribe user stream`),n=!0,e?.dispose(),t?.dispose()}}}},it=class extends $e{http;cache;socketSubs=[];_version=null;get versionInfo(){return this._version}get isPrivateServer(){return this._version?(this._version.serverData?.shards?.length??0)===0:null}_shards=null;get shardList(){return this._shards}constructor(e,t,n,r){super(r),this.http=e,this.cache=n,this.socketSubs.push(t.on(`connected`,()=>{this.emit(`server:connected`,{})})),this.socketSubs.push(t.on(`disconnected`,e=>{let t=e;this.emit(`server:disconnected`,{willReconnect:t.willReconnect})})),this.socketSubs.push(t.on(`socket:error`,e=>{this.emit(`server:error`,{error:e instanceof Error?e:Error(String(e))})}))}destroy(){for(let e of this.socketSubs)e.dispose();this.socketSubs.length=0}async version(){let e=this.cache.get(`server/version`);if(e)return e;let t=await this.http.request(`GET`,`/api/version`);return this._version=t,this.cache.set(`server/version`,t,5*6e4),this.emit(`server:version`,t),t}async refreshVersion(){return this.cache.delete(`server/version`),this.version()}async shards(){let e=this.cache.get(`server/shards`);if(e)return e;let t=await this.http.request(`GET`,`/api/game/shards/info`);return this._shards=t.shards,this.cache.set(`server/shards`,t.shards,5*6e4),this.emit(`server:shards`,t.shards),t.shards}async refreshShards(){return this.cache.delete(`server/shards`),this.shards()}async worldInfo(e){let t=`server/world/${e??`default`}`,n=this.cache.get(t);if(n)return n;let r={};e&&(r.shard=e);let{width:i,height:a}=await this.http.request(`GET`,`/api/game/world-size`,r);this.logger.log(`worldInfo shard=${e??`none`} — raw size: ${i}x${a}`);let o=-i,s=-1,c=-a,l=-1;try{let e=(await this.http.request(`POST`,`/api/game/map-stats`,{rooms:[`W0N0`,`E0N0`,`W0S0`,`E0S0`],statName:`owner0`,...r})).stats??{},t=[`W0N0`,`E0N0`,`W0S0`,`E0S0`].filter(t=>t in e);this.logger.log(`worldInfo corner probe — found: [${t.length?t.join(`, `):`none`}]`),(`E0N0`in e||`E0S0`in e)&&(o=-Math.ceil(i/2),s=Math.floor(i/2)-1),(`W0S0`in e||`E0S0`in e)&&(c=-Math.ceil(a/2),l=Math.floor(a/2)-1)}catch(e){this.logger.log(`worldInfo corner probe failed — keeping W/N defaults:`,e)}this.logger.log(`worldInfo computed bounds — x: [${o}, ${s}] y: [${c}, ${l}]`);let u={shard:e??null,width:i,height:a,minX:o,maxX:s,minY:c,maxY:l};return this.cache.set(t,u,10*6e4),u}invalidateWorldInfo(e){this.cache.delete(`server/world/${e??`default`}`)}},at=class{memory=new Map;adapter;maxEntries;namespace;accessSeq=0;constructor(e){this.adapter=e.adapter,this.maxEntries=e.maxEntries,this.namespace=e.namespace}key(e,t){return`${t??`_`}/${e}`}adapterKey(e){return`map2/${e}`}tick(){return++this.accessSeq}serialize(e){let t={data:e.data,lastSeen:e.lastSeen,lastAccess:e.lastAccess};return new TextEncoder().encode(JSON.stringify(t))}deserialize(e){try{return JSON.parse(new TextDecoder().decode(e))}catch{return null}}getMemory(e,t){let n=this.memory.get(this.key(e,t));return n?(n.lastAccess=this.tick(),n.data):null}async get(e,t){let n=this.getMemory(e,t);if(n)return n;if(!this.adapter)return null;let r=this.key(e,t),i=await this.adapter.get(this.adapterKey(r));if(!i)return null;let a=this.deserialize(i);return a?(this.memory.set(r,{data:a.data,lastSeen:a.lastSeen,lastAccess:this.tick()}),a.data):null}async put(e,t,n){let r=this.key(e,t),i={data:n,lastSeen:Date.now(),lastAccess:this.tick()};this.memory.set(r,i),await this.pruneIfNeeded(),this.adapter&&await this.adapter.set(this.adapterKey(r),this.serialize(i))}async pruneIfNeeded(){if(this.memory.size<=this.maxEntries)return;let e=[...this.memory.entries()].sort((e,t)=>e[1].lastAccess-t[1].lastAccess).slice(0,this.memory.size-this.maxEntries);for(let[t]of e)this.memory.delete(t),this.adapter&&await this.adapter.delete(this.adapterKey(t))}};function ot(e){let t=Object.keys(e).sort(),n={};for(let r of t){let t=e[r];n[r]=t?[...t].sort((e,t)=>e[0]-t[0]||e[1]-t[1]):null}return JSON.stringify(n)}var st=class extends $e{socket;storage;maxSubscriptions;active=new Map;waitlist=[];keyStates=new Map;warnedAboutWaitlist=!1;constructor(e,t,n={},r){super(r),this.socket=e,this.storage=t,this.maxSubscriptions=n.maxSubscriptions??500,this.socket.on(`connected`,()=>this.onReconnect())}map2data(e,t){return this.storage.getMemory(e,t)}subscribeMap2(e,t){let n=`${e}/${t}`,r=this.active.get(n);if(r){r.refCount++,this.logger.log(`subscribeMap2`,e,t,`(active, refs: ${r.refCount})`);let i=this.getOrCreateKeyState(n,`active`);return this.emitWarmStart(e,t),this.makeSubscription(e,t,n,i)}let i=this.waitlist.find(e=>e.key===n);if(i){i.refCount++,this.logger.log(`subscribeMap2`,e,t,`(pending, refs: ${i.refCount})`);let r=this.getOrCreateKeyState(n,`pending`);return this.emitWarmStart(e,t),this.makeSubscription(e,t,n,r)}if(this.active.size<this.maxSubscriptions){this.activateKey(e,t,n,1),this.logger.log(`subscribeMap2`,e,t,`(new active)`);let r=this.getOrCreateKeyState(n,`active`);return this.emit(`room:map2state`,{room:e,shard:t,status:`active`}),this.emitWarmStart(e,t),this.makeSubscription(e,t,n,r)}this.waitlist.push({key:n,room:e,shard:t,refCount:1}),this.logger.log(`subscribeMap2`,e,t,`(new pending)`);let a=this.getOrCreateKeyState(n,`pending`);return this.emit(`room:map2state`,{room:e,shard:t,status:`pending`}),this.emitWarmStart(e,t),this.warnedAboutWaitlist||=(this.logger.log(`subscription limit (${this.maxSubscriptions}) reached — `,`some rooms are on a waitlist and will be promoted as slots free up.`),!0),this.makeSubscription(e,t,n,a)}activateKey(e,t,n,r){let i=t?`roomMap2:${t}/${e}`:`roomMap2:${e}`,a=this.socket.subscribe(i),o=this.storage.getMemory(e,t),s={room:e,shard:t,refCount:r,socketSub:a,listenerSub:void 0,lastHash:o?ot(o):null};s.listenerSub=this.socket.on(i,n=>{let r=n,i=ot(r);s.lastHash!==i&&(s.lastHash=i,this.storage.put(e,t,r),this.emit(`room:map2update`,{room:e,shard:t,data:r,source:`live`}))}),this.active.set(n,s)}promoteNext(){let e=this.waitlist.shift();if(!e)return;this.activateKey(e.room,e.shard,e.key,e.refCount),this.logger.log(`promoteNext`,e.room,e.shard,`(promoted from waitlist)`);let t=this.keyStates.get(e.key);t&&(t.status=`active`,t.statusHandlers.forEach(e=>e(`active`))),this.emit(`room:map2state`,{room:e.room,shard:e.shard,status:`active`})}getOrCreateKeyState(e,t){let n=this.keyStates.get(e);return n||(n={status:t,statusHandlers:new Set},this.keyStates.set(e,n)),n}makeSubscription(e,t,n,r){let i=!1;return{status:()=>r.status,cachedData:()=>this.storage.getMemory(e,t),onStatusChange:e=>(r.statusHandlers.add(e),{dispose:()=>{r.statusHandlers.delete(e)}}),dispose:()=>{i||(i=!0,this.disposeSubscription(e,t,n))}}}disposeSubscription(e,t,n){let r=this.waitlist.findIndex(e=>e.key===n);if(r>=0){let i=this.waitlist[r];i.refCount--,this.logger.log(`unsubscribeMap2`,e,t,`(pending, refs: ${i.refCount})`),i.refCount<=0&&(this.waitlist.splice(r,1),this.keyStates.delete(n),this.logger.log(`unsubscribeMap2`,e,t,`(removed from waitlist)`));return}let i=this.active.get(n);i&&(i.refCount--,this.logger.log(`unsubscribeMap2`,e,t,`(active, refs: ${i.refCount})`),i.refCount<=0&&(i.socketSub.dispose(),i.listenerSub.dispose(),this.active.delete(n),this.keyStates.delete(n),this.logger.log(`unsubscribeMap2`,e,t,`(deactivated, promoting next)`),this.promoteNext()))}emitWarmStart(e,t){let n=`${e}/${t}`,r=this.storage.getMemory(e,t);r?queueMicrotask(()=>{this.isSubscribed(n)&&this.emit(`room:map2update`,{room:e,shard:t,data:r,source:`cache`})}):this.storage.get(e,t).then(r=>{r&&this.isSubscribed(n)&&this.emit(`room:map2update`,{room:e,shard:t,data:r,source:`cache`})})}onReconnect(){this.logger.log(`onReconnect —`,this.active.size,`active,`,this.waitlist.length,`pending`);for(let e of this.active.values())e.lastHash=null,this.emit(`room:map2state`,{room:e.room,shard:e.shard,status:`active`});for(let e of this.waitlist)this.emit(`room:map2state`,{room:e.room,shard:e.shard,status:`pending`})}isSubscribed(e){return this.active.has(e)||this.waitlist.some(t=>t.key===e)}},ct=class extends $e{http;debounceMs;minIntervalMs;pending=new Map;timer=null;lastFlushTime=0;constructor(e,t=100,n=500,r){super(r),this.http=e,this.debounceMs=t,this.minIntervalMs=n}request(e,t,n){if(e.length===0)return;let r=JSON.stringify([t,n??`shard0`]),i=this.pending.get(r);i||(i={rooms:new Set,statName:t,shard:n??`shard0`},this.pending.set(r,i));for(let t of e)i.rooms.add(t);this.timer&&clearTimeout(this.timer);let a=Date.now()-this.lastFlushTime,o=Math.max(this.debounceMs,this.minIntervalMs-a);this.timer=setTimeout(()=>this.flush(),o)}async flush(){let e=new Map(this.pending);this.pending.clear(),this.timer=null,this.lastFlushTime=Date.now();for(let[,t]of e){let e=[...t.rooms];try{let n=await this.http.request(`POST`,`/api/game/map-stats`,{rooms:e,statName:t.statName,shard:t.shard}),r=n.users??{};for(let[e,i]of Object.entries(n.stats)){let n=this.buildData(i,r);this.emit(`mapStats:room`,{room:e,shard:t.shard===`shard0`?null:t.shard,stat:n})}for(let r of e)n.stats[r]||this.emit(`mapStats:room`,{room:r,shard:t.shard===`shard0`?null:t.shard,stat:{}})}catch(e){this.logger.log(`mapStats fetch failed:`,e)}}}buildData(e,t){let n,r;for(let t=0;t<3;t++){let i=e[`minerals${t}`];if(i){n=i.type,r=i.density;break}}let i=e.own?.user;return{own:e.own,mineral:n,density:r,username:i?t[i]?.username:void 0,safeMode:e.safeMode,badge:i?t[i]?.badge:void 0,status:e.status}}},lt=class extends $e{_history=[];_index=-1;maxHistory;constructor(e=50,t){super(t),this.maxHistory=e}navigateTo(e,t){this._history=this._history.slice(0,this._index+1),this._history.push({room:e,shard:t}),this._history.length>this.maxHistory?this._history.shift():this._index++,this.emit(`navigation:change`,this.current())}back(){return this.canBack()?(this._index--,this.emit(`navigation:change`,this.current()),!0):!1}forward(){return this.canForward()?(this._index++,this.emit(`navigation:change`,this.current()),!0):!1}canBack(){return this._index>0}canForward(){return this._index<this._history.length-1}current(){return{room:this._history[this._index]?.room??null,shard:this._history[this._index]?.shard??null,index:this._index,history:[...this._history]}}},ut=class{http;socket;stores;cache;logger;tokenRefreshIntervalMs;tokenSyncSubs=[];tokenRefreshTimer=null;lastHttpActivity=0;refreshInFlight=!1;constructor(e){let t;try{t=new URL(e.url).hostname}catch{throw TypeError(`ScreepsClient: invalid url "${e.url}"`)}this.logger=ze.create(e.debug),this.logger.log(`[screeps:client] init ${e.url}`),this.cache=new Qe(t,e.storage??null),this.http=new Ye({url:e.url,auth:e.auth,logger:this.logger.child(`http`),serverPassword:e.serverPassword,decorationsMock:e.decorationsMock}),this.socket=new Ze({url:e.url,WebSocket:e.WebSocket,logger:this.logger.child(`socket`)});let n=new at({adapter:e.storage??null,namespace:t,maxEntries:e.map2?.maxCacheEntries??1e4});this.stores={room:new nt(this.http,this.socket,this.cache,this.logger.child(`room`)),user:new rt(this.http,this.socket,this.cache,this.logger.child(`user`)),server:new it(this.http,this.socket,this.cache,this.logger.child(`server`)),map:new st(this.socket,n,{maxSubscriptions:e.map2?.maxSubscriptions??500},this.logger.child(`map`)),mapStats:new ct(this.http,100,500,this.logger.child(`mapStats`)),navigation:new lt(50,this.logger.child(`navigation`))},this.tokenRefreshIntervalMs=e.tokenRefresh===!1?null:e.tokenRefresh?.intervalMs??3e4,this.wireTokenSync()}wireTokenSync(){this.tokenSyncSubs.push(this.http.on(`http:tokenRefresh`,({token:e})=>{this.socket.setToken(e)})),this.tokenSyncSubs.push(this.socket.on(`socket:tokenRefresh`,e=>{let t=e;this.http.setToken(t.token)})),this.tokenSyncSubs.push(this.http.on(`http:success`,()=>{this.lastHttpActivity=Date.now()}))}get isConnected(){return this.socket.isConnected}async connect(){this.logger.log(`[screeps:client] connect`),await this.http.authenticate(),await this.socket.connect(this.http.token),await Promise.all([this.stores.user.me(),this.stores.user.worldStatus(),this.stores.server.version()]),this.startTokenRefresh()}disconnect(){this.logger.log(`[screeps:client] disconnect`),this.stopTokenRefresh(),this.socket.disconnect()}startTokenRefresh(){if(this.tokenRefreshIntervalMs===null||this.tokenRefreshTimer!==null)return;let e=this.tokenRefreshIntervalMs;this.lastHttpActivity=Date.now();let t=Math.max(1e3,Math.floor(e/2));this.tokenRefreshTimer=setInterval(()=>{Date.now()-this.lastHttpActivity<e||this.refreshTokenNow()},t)}stopTokenRefresh(){this.tokenRefreshTimer!==null&&(clearInterval(this.tokenRefreshTimer),this.tokenRefreshTimer=null)}async refreshTokenNow(){if(!this.refreshInFlight){this.refreshInFlight=!0;try{this.logger.log(`[screeps:client] token refresh (idle)`),await this.stores.user.refreshWorldStatus()}catch(e){this.logger.log(`[screeps:client] token refresh failed`,e)}finally{this.refreshInFlight=!1}}}async clearCache(){this.logger.log(`[screeps:client] clearCache`),await this.cache.clearAll()}},dt=class{token;constructor(e){this.token=e.token}async authenticate(e){return this.token}},ft=class{email;password;constructor(e){this.email=e.email,this.password=e.password}async authenticate(e){return(await e.auth.signin(this.email,this.password)).token}},pt=class{async authenticate(e){return`guest`}},mt=1,ht=`data`,gt=class{namespace;db=null;openPromise=null;constructor(e){this.namespace=e}get dbName(){return`screeps:${this.namespace}`}open(){return this.db?Promise.resolve(this.db):(this.openPromise||=new Promise((e,t)=>{let n=indexedDB.open(this.dbName,mt);n.onupgradeneeded=()=>{n.result.createObjectStore(ht)},n.onsuccess=()=>{this.db=n.result,this.openPromise=null,e(n.result)},n.onerror=()=>t(n.error),n.onblocked=()=>t(Error(`IndexedDB open blocked: ${this.dbName}`))}),this.openPromise)}async get(e){let t=await this.open();return new Promise((n,r)=>{let i=t.transaction(ht,`readonly`).objectStore(ht).get(e);i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async set(e,t){let n=await this.open();return new Promise((r,i)=>{let a=n.transaction(ht,`readwrite`).objectStore(ht).put(t,e);a.onsuccess=()=>r(),a.onerror=()=>i(a.error)})}async delete(e){let t=await this.open();return new Promise((n,r)=>{let i=t.transaction(ht,`readwrite`).objectStore(ht).delete(e);i.onsuccess=()=>n(),i.onerror=()=>r(i.error)})}async clear(){let e=await this.open();return new Promise((t,n)=>{let r=e.transaction(ht,`readwrite`).objectStore(ht).clear();r.onsuccess=()=>t(),r.onerror=()=>n(r.error)})}},_t=class{subs=[];add(e){this.subs.push(e)}dispose(){for(let e of this.subs)e.dispose();this.subs.length=0}},vt=5*6e4;function yt(e,t){try{return`screeps:${e}:${new URL(t).hostname}`}catch{return`screeps:${e}:${t}`}}function bt(e){if(typeof sessionStorage>`u`)return null;try{let t=sessionStorage.getItem(e);if(!t)return null;let n=JSON.parse(t);return Date.now()>n.expires?(sessionStorage.removeItem(e),null):n.data}catch{return null}}function xt(e,t){if(!(typeof sessionStorage>`u`))try{sessionStorage.setItem(e,JSON.stringify({data:t,expires:Date.now()+vt}))}catch{}}function St(e){return e.endsWith(`/`)?e:`${e}/`}async function Ct(e){let t=yt(`version`,e),n=bt(t);if(n)return n;let r=await fetch(`${St(e)}api/version`);if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.json();return xt(t,i),i}async function wt(e){let t=yt(`authmod`,e),n=bt(t);if(n)return n;let r=await fetch(`${St(e)}api/authmod`);if(!r.ok)return null;let i=await r.json();return i.ok?(xt(t,i),i):null}async function Tt(e,t){let n=new URLSearchParams({username:t}),r=await fetch(`${St(e)}api/register/check-username?${n}`);if(!r.ok)throw Error(`HTTP ${r.status}`);return r.json()}async function Et(e,t){let n=new URLSearchParams({email:t}),r=await fetch(`${St(e)}api/register/check-email?${n}`);if(!r.ok)throw Error(`HTTP ${r.status}`);return r.json()}async function Dt(e,t,n,r){let i=await fetch(`${St(e)}api/register/submit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({username:t,email:n,password:r})});if(!i.ok)throw Error(`HTTP ${i.status}`);return i.json()}function Ot(e,t){return e.serverData.features.find(e=>e.name===t)}function kt(e){return Ot(e,`screepsmod-auth`)}var At={ok:1,decorations:[{_id:`5fd719f496a97dbdd2f57bea`,user:`58356f6fc8012784246abb7e`,active:{strokeWidth:`30`,foregroundColor:`#6A88FF`,foregroundAlpha:1,backgroundColor:`#5261A0`,backgroundBrightness:`1`,strokeColor:`#465EC4`,strokeBrightness:`1`,strokeLighting:`1`,foregroundBrightness:`1`,world:!0,tileScale:1,shard:`shard1`,room:`E2S49`},decoration:{_id:`5eea71d952fdab816c74e50c`,graphics:[],description:`звездочки`,rarityMultiplier:1,type:`wallLandscape`,foregroundUrl:`https://s3.amazonaws.com/static.screeps.com/decorations/0e53bc662a2688275b9c6766cf946031b19bf0b.png`,theme:`5e908ece62339b0045ac2d0e`,rarity:4,name:`W-00031:WI:X`,group:`5edf121e1f95b4047880e2ef`,steamItemDefId:4415,enabled:!0,groupDescription:`Controllable brightness.`,preview:{original:`https://s3.amazonaws.com/static.screeps.com/decorations/6c5533fd1f83ecadb8cf105fdda95fa4687114b.png`,"128x128":`https://s3.amazonaws.com/static.screeps.com/decorations/919410fbd3c74c697d7396ba0636b2d33ca3fa5.png`,"256x256":`https://s3.amazonaws.com/static.screeps.com/decorations/16f3453e69387abfe110050532d9e7c67e8fc41.png`}}},{_id:`60086a96a6ad8c744554e05c`,user:`58356f6fc8012784246abb7e`,active:{floorBackgroundColor:`#F67BFF`,floorBackgroundBrightness:.98,floorForegroundColor:`#F67BFF`,floorForegroundAlpha:.87,swampColor:`#4073A3`,swampStrokeColor:`#CC7DD2`,swampStrokeWidth:30,roadsColor:`#E9A7EE`,roadsBrightness:.41,tileScale:1,floorForegroundBrightness:.42,world:!0,shard:`shard1`,room:`E2S49`},decoration:{_id:`5eea668452fdab5ea674e1ca`,graphics:[],description:`калейдоскоп`,rarityMultiplier:1,type:`floorLandscape`,floorForegroundUrl:`https://s3.amazonaws.com/static.screeps.com/decorations/7e3d680d2f48b1ff244a95e564275536fe4ed61.png`,theme:`5e908ed162339b0045ac2d0f`,rarity:4,name:`F-00065:AL:X`,group:`5ee9016d961c4e27734cf301`,steamItemDefId:3606,enabled:!0,groupDescription:`Adjustable brightness.`,preview:{original:`https://s3.amazonaws.com/static.screeps.com/decorations/da7256631a2a2c8568221ad1f0bef0bb5525a7.png`,"128x128":`https://s3.amazonaws.com/static.screeps.com/decorations/3c0f0da6b41e413bdc4f66a01eed62b5b252c29.png`,"256x256":`https://s3.amazonaws.com/static.screeps.com/decorations/80c9978b58403e13b4a28f47ef1422e895c04fe.png`}}},{_id:`5fbab429b2f60e0fae891bcb`,user:`58356f6fc8012784246abb7e`,active:{lighting:!0,position:`below`,width:256,height:256,syncRotate:!0,animation:`blink`,brightness:`1`,nameFilter:`ecarry*`,exclude:!1,firstColor:`#FFFFFF`,firstAlpha:1,secondColor:`#FFFFFF`,secondAlpha:`1`,flip:!1,color:`#1fe265`,alpha:.79},decoration:{_id:`5f2ab6c1ad10bf3222df1b4f`,graphics:[{url:`https://s3.amazonaws.com/static.screeps.com/decorations/a23d96123d27bf163babe0a29a54de003aea568.svg`,color:`color`,alpha:`alpha`,visible:``}],description:`38.svg`,rarityMultiplier:1,type:`creep`,theme:`5ee3db64961c4e98dc4cf121`,rarity:5,name:`C-00071:CC:X`,group:`5eec306d0042094b2845f7d6`,steamItemDefId:57779,enabled:!0,groupDescription:`Choose your own color.`,preview:{original:`https://s3.amazonaws.com/static.screeps.com/decorations/3a7853ca055d7ae5738852f6f73f27389594e2e.png`,"128x128":`https://s3.amazonaws.com/static.screeps.com/decorations/8557cffe9216525092427f90b9847ef5bdcd6c8.png`,"256x256":`https://s3.amazonaws.com/static.screeps.com/decorations/e198e4f909cdb99f11a8cc7bc9f7e7a733faeca.png`}}}]},jt={1:{calc(e=0){let t=0,n=0;e>0&&(t=e*30/100),e<0&&(n=-e*30/100),this.path1=`M 50 ${100-t} L ${n} 50 H ${100-n} Z`,this.path2=`M ${n} 50 H ${100-n} L 50 ${t} Z`}},2:{calc(e=0){let t=0,n=0;e>0&&(t=e*30/100),e<0&&(n=-e*30/100),this.path1=`M ${t} ${n} L 50 50 L ${100-t} ${n} V -1 H -1 Z`,this.path2=`M ${t} ${100-n} L 50 50 L ${100-t} ${100-n} V 101 H -1 Z`}},3:{calc(e=0){let t=Math.PI/4+Math.PI/4*(e+100)/200,n=-Math.PI/2,r=Math.PI/2+Math.PI/3,i=Math.PI/2-Math.PI/3;this.path1=`M 50 50 L ${50+100*Math.cos(n-t/2)} ${50+100*Math.sin(n-t/2)} L ${50+100*Math.cos(n+t/2)} ${50+100*Math.sin(n+t/2)} Z`,this.path2=`M 50 50 L ${50+100*Math.cos(r-t/2)} ${50+100*Math.sin(r-t/2)} L ${50+100*Math.cos(r+t/2)} ${50+100*Math.sin(r+t/2)} Z M 50 50 L ${50+100*Math.cos(i-t/2)} ${50+100*Math.sin(i-t/2)} L ${50+100*Math.cos(i+t/2)} ${50+100*Math.sin(i+t/2)}`},flip:`rotate180`},4:{calc(e=0){e+=100;let t=50-e*30/200,n=50+e*30/200;this.path1=`M 0 ${n} H 100 V 100 H 0 Z`,this.path2=e>0?`M 0 ${t} H 100 V ${n} H 0 Z`:``},flip:`rotate90`},5:{calc(e=0){e+=100;let t=50-e*10/200-10,n=50+e*10/200+10;this.path1=`M ${t} 0 H ${n} V 100 H ${t} Z`,this.path2=`M 0 ${t} H 100 V ${n} H 0 Z`},flip:`rotate45`},6:{calc(e=0){let t=5+(e+100)*8/200;this.path1=`M ${50-t} 0 H ${50+t} V 100 H ${50-t}`,this.path2=`M ${20-t} 0 H ${20+t} V 100 H ${20-t} Z M ${80-t} 0 H ${80+t} V 100 H ${80-t} Z`},flip:`rotate90`},7:{calc(e=0){let t=20+e*10/100;this.path1=`M 0 50 Q 25 30 50 50 T 100 50 V 100 H 0 Z`,this.path2=`M 0 ${50-t} Q 25 ${30-t} 50 ${50-t} T 100 ${50-t} V ${50+t} Q 75 ${70+t} 50 ${50+t} T 0 ${50+t} Z`},flip:`rotate90`},8:{calc(e=0){let t=e*20/100;this.path1=`M 0 50 H 100 V 100 H 0 Z`,this.path2=`M 0 50 Q 50 ${t} 100 50 Q 50 ${100-t} 0 50 Z`},flip:`rotate90`},9:{calc(e=0){let t=0,n=50;e>0&&(t+=e/100*20),e<0&&(n+=e/100*30),this.path1=`M 50 ${t} L 100 ${t+70} V 101 H 0 V ${t+70} Z`,this.path2=`M 50 ${t+n} L 100 ${t+n+70} V 101 H 0 V ${t+n+70} Z`},flip:`rotate180`},10:{calc(e=0){let t=30,n=7;e>0&&(t+=e*50/100),e<0&&(n-=e*20/100),this.path1=`M ${50+n+t} ${50-t} A ${t} ${t} 0 0 0 ${50+n+t} ${50+t} H 101 V ${50-t} Z`,this.path2=`M ${50-n-t} ${50-t} A ${t} ${t} 0 0 1 ${50-n-t} ${50+t} H -1 V ${50-t} Z`},flip:`rotate90`},11:{calc(e=0){let t=30,n=30,r=50-50*Math.cos(Math.PI/4),i=50-50*Math.sin(Math.PI/4);e>0&&(t+=e*25/100,n+=e*25/100),e<0&&(n-=e*50/100),this.path1=`M ${r} ${i} Q ${t} 50 ${r} ${100-i} H 0 V ${i} Z M ${100-r} ${i} Q ${100-t} 50 ${100-r} ${100-i} H 100 V ${i} Z`,this.path2=`M ${r} ${i} Q 50 ${n} ${100-r} ${i} V 0 H ${r} Z M ${r} ${100-i} Q 50 ${100-n} ${100-r} ${100-i} V 100 H ${r} Z`},flip:`rotate90`},12:{calc(e=0){let t=30,n=35;e>0&&(t+=e*30/100),e<0&&(n+=e*15/100),this.path1=`M 0 ${t} H 100 V 100 H 0 Z`,this.path2=`M 0 ${t} H ${n} V 100 H 0 Z M 100 ${t} H ${100-n} V 100 H 100 Z`},flip:`rotate180`},13:{calc(e=0){let t=30,n=0;e>0&&(t+=e*50/100),e<0&&(n-=e*20/100),this.path1=`M 0 0 H 50 V 100 H 0 Z`,this.path2=`M ${50-t} ${50-n-t} A ${t} ${t} 0 0 0 ${50+t} ${50-t-n} V 0 H ${50-t} Z`},flip:`rotate180`},14:{calc(e=0){let t=Math.PI/4;t+=e*Math.PI/4/100,this.path1=`M 50 0 Q 50 50 ${50+50*Math.cos(t)} ${50+50*Math.sin(t)} H 100 V 0 H 50 Z`,this.path2=`M 50 0 Q 50 50 ${50-50*Math.cos(t)} ${50+50*Math.sin(t)} H 0 V 0 H 50 Z`},flip:`rotate180`},15:{calc(e=0){let t=13+e*6/100;this.path1=`M ${-30-t} 110 A ${80+t} ${80+t} 0 0 1 ${130+t} 110 H ${130-t} A ${80-t} ${80-t} 0 1 0 ${-30+t} 110`,this.path2=`M ${5-t} 110 A ${45+t} ${45+t} 0 0 1 ${95+t} 110 H ${95-t} A ${45-t} ${45-t} 0 1 0 ${5+t} 110`},flip:`rotate180`},16:{calc(e=0){let t=30*Math.PI/180,n=25;e>0&&(t+=30*Math.PI/180*e/100),e<0&&(n+=e*25/100),this.path1=``;for(let e=0;e<3;e++){let r=e*Math.PI*2/3+t/2-Math.PI/2,i=e*Math.PI*2/3-t/2-Math.PI/2;this.path1+=`M ${50+100*Math.cos(r)} ${50+100*Math.sin(r)} L ${50+100*Math.cos(i)} ${50+100*Math.sin(i)} L ${50+n*Math.cos(i)} ${50+n*Math.sin(i)} A ${n} ${n} 0 0 1 ${50+n*Math.cos(r)} ${50+n*Math.sin(r)} Z`}this.path2=``;for(let e=0;e<3;e++){let r=e*Math.PI*2/3+t/2+Math.PI/2,i=e*Math.PI*2/3-t/2+Math.PI/2;this.path2+=`M ${50+100*Math.cos(r)} ${50+100*Math.sin(r)} L ${50+100*Math.cos(i)} ${50+100*Math.sin(i)} L ${50+n*Math.cos(i)} ${50+n*Math.sin(i)} A ${n} ${n} 0 0 1 ${50+n*Math.cos(r)} ${50+n*Math.sin(r)} Z`}}},17:{calc(e=0){let t=35,n=45;e>0&&(t+=e*20/100),e<0&&(n-=e*30/100),this.path1=`M 50 45 L ${50-t} ${n+45} H ${50+t} Z`,this.path2=`M 50 0 L ${50-t} ${n} H ${50+t} Z`}},18:{calc(e=0){let t=90*Math.PI/180,n=10;e>0&&(t-=60/180*Math.PI*e/100),e<0&&(n-=e*15/100),this.path1=``,this.path2=``;for(let e=0;e<3;e++){let r=Math.PI*2/3*e+t/2-Math.PI/2,i=Math.PI*2/3*e-t/2-Math.PI/2,a=`M ${50+100*Math.cos(r)} ${50+100*Math.sin(r)} L ${50+100*Math.cos(i)} ${50+100*Math.sin(i)} L ${50+n*Math.cos((r+i)/2)} ${50+n*Math.sin((r+i)/2)} Z`;e?this.path2+=a:this.path1+=a}},flip:`rotate180`},19:{calc(e=0){let t=20,n=60;n+=e*20/100,t+=e*20/100,this.path1=`M 50 -10 L ${50-n} 100 H ${50+n} Z`,this.path2=``,t>0&&(this.path2=`M 50 0 L ${50-t} 100 H ${50+t} Z`)},flip:`rotate180`},20:{calc(e=0){let t=10,n=20;e>0&&(t+=e*20/100),e<0&&(n+=e*40/100),this.path1=`M 0 ${50-n} H ${50-t} V 100 H 0 Z`,this.path2=`M ${50+t} 0 V ${50+n} H 100 V 0 Z`},flip:`rotate90`},21:{calc(e=0){let t=40,n=50;e>0&&(t-=e*20/100),e<0&&(n+=e*20/100),this.path1=`M 50 ${n} Q ${50+t} 0 50 0 T 50 ${n} Z M 50 ${100-n} Q ${50+t} 100 50 100 T 50 ${100-n} Z`,this.path2=`M ${n} 50 Q 0 ${50+t} 0 50 T ${n} 50 Z M ${100-n} 50 Q 100 ${50+t} 100 50 T ${100-n} 50 Z`},flip:`rotate45`},22:{calc(e=0){let t=20;t+=e*10/100,this.path1=`M ${50-t} ${50-t} H ${50+t} V ${50+t} H ${50-t} Z`,this.path2=``;for(let e=-4;e<4;e++)for(let n=-4;n<4;n++){let r=(e+n)%2;this.path2+=`M ${50-t-t*2*e} ${50-t-t*2*(n+r)} h ${-t*2} v ${t*2} h ${t*2} Z`}},flip:`rotate45`},23:{calc(e=0){let t=17,n=25;e>0&&(t+=e*35/100),e<0&&(n-=e*23/100),this.path1=``;for(let e=-4;e<=4;e++)this.path1+=`M ${50-t*e*2} ${50-n} l ${-t} ${-n} l ${-t} ${n} l ${t} ${n} Z`;this.path2=``;for(let e=-4;e<=4;e++)this.path2+=`M ${50-t*e*2} ${50+n} l ${-t} ${-n} l ${-t} ${n} l ${t} ${n} Z`},flip:`rotate90`},24:{calc(e=0){let t=50,n=45;e>0&&(t+=e*60/100),e<0&&(n+=e*30/100),this.path1=`M 0 ${n} L 50 70 L 100 ${n} V 100 H 0 Z`,this.path2=`M 50 0 L ${50+t} 100 H 100 V ${n} L 50 70 L 0 ${n} V 100 H ${50-t} Z`},flip:`rotate180`}};function Mt(e){let t=Math.round(e).toString(16);return t.length<2?`0`+t:t}function Nt(e,t,n){let r=(1-Math.abs(2*n-1))*t,i=e/60,a=r*(1-Math.abs(i%2-1)),o=0,s=0,c=0;!Number.isNaN(e)&&e!=null&&(i>=0&&i<1?(o=r,s=a,c=0):i>=1&&i<2?(o=a,s=r,c=0):i>=2&&i<3?(o=0,s=r,c=a):i>=3&&i<4?(o=0,s=a,c=r):i>=4&&i<5?(o=a,s=0,c=r):i>=5&&i<6&&(o=r,s=0,c=a));let l=n-r/2,u=(o+l)*255,d=(s+l)*255,f=(c+l)*255;return`#`+Mt(u)+Mt(d)+Mt(f)}function Pt(){let e=[],t=0;e.push({index:t++,rgb:Nt(0,0,.8)});for(let n=0;n<19;n++)e.push({index:t++,rgb:Nt(n*360/19,.6,.8)});e.push({index:t++,rgb:Nt(0,0,.5)});for(let n=0;n<19;n++)e.push({index:t++,rgb:Nt(n*360/19,.7,.5)});e.push({index:t++,rgb:Nt(0,0,.3)});for(let n=0;n<19;n++)e.push({index:t++,rgb:Nt(n*360/19,.4,.3)});e.push({index:t++,rgb:Nt(0,0,.1)});for(let n=0;n<19;n++)e.push({index:t++,rgb:Nt(n*360/19,.5,.1)});return e}var Ft=Pt();function It(e){if(typeof e==`string`)return e;if(typeof e==`number`){let t=Ft[e];return t?t.rgb:`#000000`}return`#000000`}function Lt(e){let t=It(e.color1),n=It(e.color2),r=It(e.color3),i=e.param??0;if(typeof e.type==`number`){let t=jt[e.type];t&&t.calc(i)}let a=0;if(e.flip&&typeof e.type==`number`){let t=jt[e.type];t?.flip===`rotate180`&&(a=180),t?.flip===`rotate90`&&(a=90),t?.flip===`rotate45`&&(a=45)}let o,s;if(typeof e.type==`number`){let t=jt[e.type];o=t?.path1??``,s=t?.path2??``}else o=e.type.path1,s=e.type.path2;let c=`<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 100 100" shape-rendering="geometricPrecision">`;return c+=`<defs><clipPath id="clip"><circle cx="50" cy="50" r="50"/></clipPath></defs>`,c+=`<g transform="rotate(${a} 50 50)">`,c+=`<rect x="0" y="0" width="100" height="100" fill="${t}" clip-path="url(#clip)"/>`,o&&(c+=`<path d="${o}" fill="${n}" clip-path="url(#clip)"/>`),s&&(c+=`<path d="${s}" fill="${r}" clip-path="url(#clip)"/>`),c+=`<circle cx="50" cy="50" r="47.5" fill="transparent" stroke="#000" stroke-width="5"/>`,c+=`</g></svg>`,c}var[Rt,zt]=x([]),Bt=0;function V(e,t=`success`,n=4e3){let r=Bt++;zt(i=>[...i,{id:r,message:e,type:t,duration:n}]),setTimeout(()=>{zt(e=>e.filter(e=>e.id!==r))},n)}var Vt=!1;function Ht(){return typeof window>`u`?!1:window.location.pathname.startsWith(`/client`)}function Ut(){return Vt}function Wt(){return window.location.origin}function Gt(){return`0.7.0`}function Kt(){return typeof window>`u`?null:window.__SCREEPS_CLIENT_EMBEDDED__??null}function qt(){return`/`.replace(/\/$/,``)}function Jt(e){let t=`[${e}]`;return{log:()=>{},warn:()=>{},error:(...e)=>console.error(t,...e)}}var H={room:`screeps:room`,shard:`screeps:shard`,sidebarWidth:`screeps:sidebarWidth`,consoleHeight:`screeps:consoleHeight`,consoleSplit:`screeps:consoleSplit`,consoleWeights:`screeps:consoleWeights`,memoryWatches:`screeps:memoryWatches`,mapZoom:`screeps:mapZoom`,widescreenMode:`screeps:settings:widescreenMode`,showCreepLabels:`screeps:settings:showCreepLabels`,showMapRoomNames:`screeps:settings:showMapRoomNames`,showUnclaimableRooms:`screeps:settings:showUnclaimableRooms`,terrainEffects:`screeps:settings:terrainEffects`,showRoomDecorations:`screeps:settings:showRoomDecorations`,roomDarkOverlay:`screeps:settings:roomDarkOverlay`,showRoomVisuals:`screeps:settings:showRoomVisuals`,spriteTheme:`screeps:settings:spriteTheme`,verboseCreepDetails:`screeps:settings:verboseCreepDetails`,showMapVisuals:`screeps:settings:showMapVisuals`},U={url:`screeps:url`,token:`screeps:token`,serverPassword:`screeps:serverPassword`};function Yt(e){return localStorage.getItem(e)}function Xt(e,t){localStorage.setItem(e,t)}function Zt(e){localStorage.removeItem(e)}function Qt(e,t){let n=localStorage.getItem(e);if(n===null)return t;let r=Number(n);return Number.isFinite(r)&&r!==0?r:t}function $t(e,t){localStorage.setItem(e,String(t))}function en(e,t){let n=localStorage.getItem(e);if(n===null)return t;try{return JSON.parse(n)}catch{return t}}function tn(e,t){localStorage.setItem(e,JSON.stringify(t))}function nn(e){return sessionStorage.getItem(e)}function rn(e,t){sessionStorage.setItem(e,t)}function an(e){sessionStorage.removeItem(e)}async function on(){if(localStorage.clear(),indexedDB.databases){let e=await indexedDB.databases();await Promise.all(e.map(e=>e.name?new Promise(t=>{let n=indexedDB.deleteDatabase(e.name);n.onsuccess=()=>t(),n.onerror=()=>t(),n.onblocked=()=>t()}):Promise.resolve()))}if(`caches`in window){let e=await caches.keys();await Promise.all(e.map(e=>caches.delete(e)))}}var{log:sn}=Jt(`client`),[W,cn]=x(null),[ln,un]=x(`idle`),[dn,fn]=x(null),[pn,mn]=x(null),[hn,gn]=x(null),[G,_n]=x(null),[vn,yn]=x(null),[K,bn]=x(!1),[xn,Sn]=x(null),[Cn,wn]=x({}),[Tn,En]=x(null),Dn=-1,On=-1,kn=[],An=5;function jn(e){if(e===void 0)return;let t=Date.now();if(Dn>=0&&e>Dn){let e=t-On;if(e>0){kn.push(e),kn.length>An&&kn.shift();let t=kn.reduce((e,t)=>e+t,0)/kn.length;yn(Math.round(t))}}Dn=e,On=t}function Mn(){Dn=-1,On=-1,kn.length=0,yn(null)}var Nn=()=>{let e=hn();return e?(e.serverData?.shards?.length??0)===0:null};async function Pn(e){Ht()&&(e={...e,url:Wt()}),sn(`connecting to ${e.url} (auth: ${e.auth})`),un(`connecting`),fn(null);try{let t;if(e.auth===`guest`)t=new pt,bn(!0);else if(e.auth===`password`){if(!e.email||!e.password)throw Error(`Email and password are required`);t=new ft({email:e.email,password:e.password})}else{if(!e.token)throw Error(`Token is required`);t=new dt({token:e.token})}let n=new ut({url:e.url,auth:t,storage:e.storage??new gt(`screeps-client`),debug:!1,serverPassword:e.serverPassword,decorationsMock:At});n.http.on(`http:tokenRefresh`,({token:e})=>{sn(`token refreshed`),rn(U.token,e)}),n.http.on(`http:error`,({method:e,path:t,error:n})=>{sn(`http error:`,e,t,n.message),V(`Request failed: ${e} ${t} — ${n.message}`,`error`,6e3)}),n.stores.server.on(`server:disconnected`,e=>{sn(`server disconnected (willReconnect: ${e.willReconnect})`),e.willReconnect||(un(`idle`),cn(null),mn(null),gn(null))}),n.stores.server.on(`server:error`,e=>{sn(`server error:`,e.error.message),fn(e.error.message),un(`error`)}),n.stores.user.on(`user:me`,e=>{sn(`user: ${e.username} (id: ${e._id})`),mn(e)}),n.stores.server.on(`server:version`,e=>{sn(`server version: ${e.package??`unknown`}`),gn(e)}),n.stores.user.on(`user:stream`,e=>{if(e&&typeof e==`object`&&`flags`in e){let t=e.flags;t&&typeof t==`object`&&wn(t)}}),n.stores.user.on(`user:worldStatus`,({status:e})=>{sn(`world status: ${e}`),En(e)}),await n.connect(),n.stores.user.subscribeUserStream(),cn(n),un(`connected`),sn(`connected to ${e.url}`),n.stores.server.worldInfo().then(e=>{Sn(e),sn(`world: ${e.width}x${e.height} x[${e.minX},${e.maxX}] y[${e.minY},${e.maxY}]`)}).catch(()=>{}),rn(U.url,e.url),n.http.token&&rn(U.token,n.http.token),e.serverPassword?rn(U.serverPassword,e.serverPassword):an(U.serverPassword)}catch(e){let t=e instanceof Error?e.message:String(e);throw sn(`connection failed:`,t),fn(t),un(`error`),cn(null),e}}async function Fn(){let e=Ht()?Wt():nn(U.url),t=nn(U.token);if(!e||!t)return;let n=nn(U.serverPassword)??void 0;sn(`auto-connect: ${e}`);try{t===`guest`?await Pn({url:e,auth:`guest`,storage:null,serverPassword:n}):await Pn({url:e,auth:`token`,token:t,serverPassword:n})}catch{sn(`auto-connect failed — clearing stored token`),an(U.token)}}function In(){sn(`disconnecting`);let e=W();e&&e.disconnect(),cn(null),un(`idle`),fn(null),mn(null),gn(null),_n(null),bn(!1),Sn(null),wn({}),En(null),Mn(),an(U.token),an(U.url),an(U.serverPassword)}var Ln={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`},Rn=P(`<svg>`),zn=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),Bn=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),Vn=e=>{let t=Bn(e);return t.charAt(0).toUpperCase()+t.slice(1)},Hn=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),q=e=>{let[n,r]=t(e,[`color`,`size`,`strokeWidth`,`children`,`class`,`name`,`iconNode`,`absoluteStrokeWidth`]);return(()=>{var e=Rn();return xe(e,i(Ln,{get width(){return n.size??Ln.width},get height(){return n.size??Ln.height},get stroke(){return n.color??Ln.stroke},get"stroke-width"(){return N(()=>!!n.absoluteStrokeWidth)()?Number(n.strokeWidth??Ln[`stroke-width`])*24/Number(n.size):Number(n.strokeWidth??Ln[`stroke-width`])},get class(){return Hn(`lucide`,`lucide-icon`,...n.name==null?[]:[`lucide-${zn(Vn(n.name))}`,`lucide-${zn(n.name)}`],n.class==null?``:n.class)}},r),!0,!0),z(e,m(l,{get each(){return n.iconNode},children:([e,t])=>m(Re,i({component:e},t))})),e})()},Un=[[`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`}]],Wn=e=>m(q,i(e,{iconNode:Un,name:`bell-off`})),Gn=[[`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`}]],Kn=e=>m(q,i(e,{iconNode:Gn,name:`bell`})),qn=[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]],Jn=e=>m(q,i(e,{iconNode:qn,name:`check`})),Yn=[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]],Xn=e=>m(q,i(e,{iconNode:Yn,name:`chevron-down`})),Zn=[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]],Qn=e=>m(q,i(e,{iconNode:Zn,name:`chevron-right`})),$n=[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]],er=e=>m(q,i(e,{iconNode:$n,name:`chevron-left`})),tr=[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]],nr=e=>m(q,i(e,{iconNode:tr,name:`clock`})),rr=[[`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`}]],ir=e=>m(q,i(e,{iconNode:rr,name:`code-xml`})),ar=[[`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`}]],or=e=>m(q,i(e,{iconNode:ar,name:`eye`})),sr=[[`path`,{d:`M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z`,key:`i9b6wo`}],[`line`,{x1:`4`,x2:`4`,y1:`22`,y2:`15`,key:`1cm3nv`}]],cr=e=>m(q,i(e,{iconNode:sr,name:`flag`})),lr=[[`path`,{d:`m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9`,key:`eefl8a`}],[`path`,{d:`m18 15 4-4`,key:`16gjal`}],[`path`,{d:`m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5`,key:`b7pghm`}]],ur=e=>m(q,i(e,{iconNode:lr,name:`hammer`})),dr=[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]],fr=e=>m(q,i(e,{iconNode:dr,name:`layout-grid`})),pr=[[`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`}]],mr=e=>m(q,i(e,{iconNode:pr,name:`loader`})),hr=[[`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`}]],gr=e=>m(q,i(e,{iconNode:hr,name:`log-in`})),_r=[[`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`}]],vr=e=>m(q,i(e,{iconNode:_r,name:`log-out`})),yr=[[`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`}]],br=e=>m(q,i(e,{iconNode:yr,name:`map`})),xr=[[`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`}]],Sr=e=>m(q,i(e,{iconNode:xr,name:`move`})),Cr=[[`rect`,{x:`14`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`zuxfzm`}],[`rect`,{x:`6`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`1okwgv`}]],wr=e=>m(q,i(e,{iconNode:Cr,name:`pause`})),Tr=[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]],Er=e=>m(q,i(e,{iconNode:Tr,name:`play`})),Dr=[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]],Or=e=>m(q,i(e,{iconNode:Dr,name:`plus`})),kr=[[`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`}]],Ar=e=>m(q,i(e,{iconNode:kr,name:`refresh-cw`})),jr=[[`path`,{d:`M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z`,key:`1qme2f`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]],Mr=e=>m(q,i(e,{iconNode:jr,name:`settings`})),Nr=[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]],Pr=e=>m(q,i(e,{iconNode:Nr,name:`terminal`})),Fr=[[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6`,key:`4alrt4`}],[`path`,{d:`M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2`,key:`v07s0e`}],[`line`,{x1:`10`,x2:`10`,y1:`11`,y2:`17`,key:`1uufr5`}],[`line`,{x1:`14`,x2:`14`,y1:`11`,y2:`17`,key:`xtxkd`}]],Ir=e=>m(q,i(e,{iconNode:Fr,name:`trash-2`})),Lr=[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]],Rr=e=>m(q,i(e,{iconNode:Lr,name:`x`})),zr=P(`<span style=font-size:11px;display:inline-flex;align-items:center;gap:3px>`),Br=P(`<div style="color:#3fb950;font-size:14px;text-align:center;padding:8px 0">Account created! Logging you in…`),Vr=P(`<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>`),Hr=P(`<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>`),Ur=P(`<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>`),Wr=P(`<span style=font-size:11px;color:#f85149>Passwords don't match`),Gr=P(`<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>`),Kr=P(`<button type=submit style=padding:10px;border-radius:6px;border:none;background:#238636;color:#fff;font-weight:600>`),qr=P(`<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`),Jr=P(`<form style=display:flex;flex-direction:column;gap:16px><h2 style=margin:0;font-size:20px>Create Account`),Yr=P(`<div style=color:#f85149;font-size:13px>`),Xr=P(`<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">`),Zr=P(`<button type=button style=background:none;border:none;color:#58a6ff;font-size:12px;cursor:pointer;padding:0>Create account`),Qr=P(`<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`),$r=P(`<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>`),ei=P(`<div style=color:#8b949e;font-size:12px;margin-top:-8px>`),ti=P(`<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>`),ni=P(`<button type=button style=padding:10px;border-radius:6px;border:none;background:#1b2838;color:#c7d5e0;font-weight:600>Login with Steam`),ri=P(`<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)`),ii=P(`<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><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"></label><button type=submit style=padding:10px;border-radius:6px;border:none;background:#238636;color:#fff;font-weight:600>`),ai=P(`<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>`),oi=P(`<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">`),si=P(`<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>`),ci=P(`<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>`),li=P(`<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>`),ui=P(`<span style="font-size:11px;padding:2px 8px;border-radius:12px;background:#21262d;border:1px solid #30363d;color:#8b949e;font-family:monospace">`),di={padding:`8px 12px`,"border-radius":`6px`,border:`1px solid #30363d`,background:`#0d1117`,color:`#c9d1d9`};function fi(e){let[t,n]=x(null),[r,i]=x(null),[a,o]=x(null);return f(()=>{let t=e();n(null),i(null),o(null);let r=!1,a=setTimeout(async()=>{try{let e=await Ct(t);if(r)return;if(n(e),o(null),kt(e)){let e=await wt(t);r||i(e)}}catch{r||(o(`Could not reach server`),n(null))}},400);y(()=>{r=!0,clearTimeout(a)})}),{serverVersion:t,authModInfo:r,serverError:a}}function pi(e,t,n){let[r,i]=x(`idle`);return f(()=>{let r=t();if(!r){i(`idle`);return}i(`checking`);let a=!1,o=setTimeout(async()=>{try{let t=await n(e(),r);a||i(t.error?`taken`:`available`)}catch{a||i(`error`)}},500);y(()=>{a=!0,clearTimeout(o)})}),r}function mi(e){let t={idle:null,checking:{children:`Checking…`,color:`#8b949e`},available:{children:[m(Jn,{size:12}),` Available`],color:`#3fb950`},taken:{children:[m(Rr,{size:12}),` Already taken`],color:`#f85149`},error:{children:`Could not verify`,color:`#d29922`}},n=()=>t[e.state];return m(u,{get when(){return n()},get children(){var e=zr();return z(e,()=>n().children),o(t=>R(e,`color`,n().color)),e}})}function hi(e){let[t,n]=x(``),[r,i]=x(``),[a,s]=x(``),[c,l]=x(``),[d,f]=x(!1),[p,h]=x(null),[g,_]=x(!1),v=pi(()=>e.url,t,Tt),y=pi(()=>e.url,r,Et),b=()=>c()!==``&&a()!==c(),S=()=>!d()&&t()!==``&&r()!==``&&a().length>=4&&a()===c()&&v()!==`taken`&&v()!==`checking`&&y()!==`taken`&&y()!==`checking`,C=async n=>{if(n.preventDefault(),S()){f(!0),h(null);try{let n=await Dt(e.url,t(),r(),a());if(n.error){h(n.error);return}_(!0),setTimeout(()=>e.onSuccess(r(),a()),1500)}catch(e){h(e instanceof Error?e.message:`Registration failed`)}finally{f(!1)}}};return(()=>{var f=Jr();return f.firstChild,f.addEventListener(`submit`,C),z(f,m(u,{get when(){return g()},get children(){return Br()}}),null),z(f,m(u,{get when(){return!g()},get children(){return[(()=>{var e=Vr(),r=e.firstChild;r.firstChild;var i=r.nextSibling;return z(r,m(mi,{get state(){return v()}}),null),i.$$input=e=>n(e.currentTarget.value),o(e=>{var t=di,n=d();return e.e=L(i,t,e.e),n!==e.t&&(i.disabled=e.t=n),e},{e:void 0,t:void 0}),o(()=>i.value=t()),e})(),(()=>{var e=Hr(),t=e.firstChild;t.firstChild;var n=t.nextSibling;return z(t,m(mi,{get state(){return y()}}),null),n.$$input=e=>i(e.currentTarget.value),o(e=>{var t=di,r=d();return e.e=L(n,t,e.e),r!==e.t&&(n.disabled=e.t=r),e},{e:void 0,t:void 0}),o(()=>n.value=r()),e})(),(()=>{var e=Ur(),t=e.firstChild.nextSibling;return t.$$input=e=>s(e.currentTarget.value),o(e=>{var n=di,r=d();return e.e=L(t,n,e.e),r!==e.t&&(t.disabled=e.t=r),e},{e:void 0,t:void 0}),o(()=>t.value=a()),e})(),(()=>{var e=Gr(),t=e.firstChild;t.firstChild;var n=t.nextSibling;return z(t,m(u,{get when(){return b()},get children(){return Wr()}}),null),n.$$input=e=>l(e.currentTarget.value),o(e=>{var t={...di,border:b()?`1px solid #f85149`:`1px solid #30363d`},r=d();return e.e=L(n,t,e.e),r!==e.t&&(n.disabled=e.t=r),e},{e:void 0,t:void 0}),o(()=>n.value=c()),e})(),N(()=>N(()=>!!p())()&&(()=>{var e=Yr();return z(e,p),e})()),(()=>{var e=Kr();return z(e,()=>d()?`Creating account…`:`Create Account`),o(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&&R(e,`cursor`,t.t=r),i!==t.a&&R(e,`opacity`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e})(),(()=>{var t=qr();return t.$$click=()=>e.onCancel(),t})()]}}),null),f})()}function gi(){let e=Ht(),t=Ut(),[n,r]=x(`login`),[i,a]=x(`password`),[s,c]=x(e?Wt():window.location.origin),[d,f]=x(``),[p,h]=x(``),[g,_]=x(``),[v,b]=x(``),{serverVersion:S,authModInfo:C,serverError:w}=fi(s),T=()=>S()?.serverData?.welcomeText??null,E=()=>(S()?.serverData?.features??[]).filter(e=>e.name!==`auth`&&e.version!=null),ee=()=>{let e=S();return e?kt(e)?.authTypes?.includes(`steam`)??!0:!0},D=()=>C()?.allowRegistration===!0||(S()?.serverData?.features??[]).some(e=>e.name===`official-like`),O=()=>{let e=s().replace(/\/$/,``),t=window.open(`${e}/api/auth/steam`,`screeps-steam-auth`,`width=800,height=600,left=200,top=100`),n=t=>{try{let n=JSON.parse(t.data);n.token&&(i(),Pn({url:e,auth:`token`,token:n.token,serverPassword:v()||void 0,storage:null}))}catch{}},r=setInterval(()=>{t?.closed&&i()},500),i=()=>{clearInterval(r),window.removeEventListener(`message`,n)};window.addEventListener(`message`,n),y(i)},te=async e=>{e.preventDefault(),await Pn({url:s(),auth:i(),email:d()||void 0,password:p()||void 0,token:g()||void 0,serverPassword:v()||void 0,storage:null})},ne=async e=>{e.preventDefault(),await Pn({url:s(),auth:`guest`,serverPassword:v()||void 0,storage:null})},re=async(e,t)=>{try{await Pn({url:s(),auth:`password`,email:e,password:t,serverPassword:v()||void 0,storage:null})}catch{r(`login`),a(`password`),f(e),h(t)}},k=()=>ln()===`connecting`;return(()=>{var y=oi(),x=y.firstChild;return z(y,m(u,{get when(){return T()},get children(){var e=Xr();return o(()=>e.innerHTML=T()),e}}),x),z(x,m(u,{get when(){return n()===`register`},get children(){return m(hi,{get url(){return s()},get serverPassword(){return v()},onSuccess:re,onCancel:()=>r(`login`)})}}),null),z(x,m(u,{get when(){return n()===`login`},get children(){var n=ii(),l=n.firstChild;l.firstChild;var y=l.nextSibling,x=y.firstChild;x.firstChild.nextSibling;var S=x.nextSibling,C=y.nextSibling;return n.addEventListener(`submit`,te),z(l,m(u,{get when(){return D()},get children(){var e=Zr();return e.$$click=()=>r(`register`),e}}),null),z(n,m(u,{when:!e,get children(){var e=Qr(),t=e.firstChild,n=t.nextSibling;return t.$$click=()=>a(`password`),n.$$click=()=>a(`token`),o(e=>{var r=i()===`password`?`#238636`:`transparent`,a=i()===`token`?`#238636`:`transparent`;return r!==e.e&&R(t,`background`,e.e=r),a!==e.t&&R(n,`background`,e.t=a),e},{e:void 0,t:void 0}),e}}),y),z(n,m(u,{when:!e,get children(){return[(()=>{var e=$r(),t=e.firstChild.nextSibling;return t.$$input=e=>c(e.currentTarget.value),o(e=>L(t,di,e)),o(()=>t.value=s()),e})(),m(u,{get when(){return w()},get children(){var e=ei();return z(e,w),e}})]}}),y),z(n,(()=>{var e=N(()=>i()===`password`);return()=>e()?[(()=>{var e=si(),t=e.firstChild.nextSibling;return t.$$input=e=>f(e.currentTarget.value),o(e=>L(t,di,e)),o(()=>t.value=d()),e})(),(()=>{var e=ci(),t=e.firstChild.nextSibling;return t.$$input=e=>h(e.currentTarget.value),o(e=>L(t,di,e)),o(()=>t.value=p()),e})()]:(()=>{var e=li(),t=e.firstChild.nextSibling;return t.$$input=e=>_(e.currentTarget.value),o(e=>L(t,di,e)),o(()=>t.value=g()),e})()})(),y),S.$$input=e=>b(e.currentTarget.value),z(n,(()=>{var e=N(()=>!!dn());return()=>e()&&(()=>{var e=Yr();return z(e,dn),e})()})(),C),z(C,()=>k()?`Connecting…`:`Connect`),z(n,m(u,{get when(){return ee()},get children(){return[(()=>{var e=ti();return e.firstChild.nextSibling.nextSibling,e})(),(()=>{var e=ni();return e.$$click=O,o(t=>{var n=k(),r=k()?`not-allowed`:`pointer`,i=k()?.6:1;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&R(e,`cursor`,t.t=r),i!==t.a&&R(e,`opacity`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e})()]}}),null),z(n,m(u,{when:!e||t,get children(){var e=ri();return e.addEventListener(`mouseleave`,e=>{e.currentTarget.style.borderColor=`#30363d`}),e.addEventListener(`mouseenter`,e=>{k()||(e.currentTarget.style.borderColor=`#8b949e`)}),e.$$click=ne,o(t=>{var n=k(),r=k()?`not-allowed`:`pointer`,i=k()?.6:1;return n!==t.e&&(e.disabled=t.e=n),r!==t.t&&R(e,`cursor`,t.t=r),i!==t.a&&R(e,`opacity`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e}}),null),o(e=>{var t=di,n=k(),r=k()?`not-allowed`:`pointer`,i=k()?.6:1;return e.e=L(S,t,e.e),n!==e.t&&(C.disabled=e.t=n),r!==e.a&&R(C,`cursor`,e.a=r),i!==e.o&&R(C,`opacity`,e.o=i),e},{e:void 0,t:void 0,a:void 0,o:void 0}),o(()=>S.value=v()),n}}),null),z(y,m(u,{get when(){return E().length>0},get children(){var e=ai(),t=e.firstChild.nextSibling;return z(t,m(l,{get each(){return E()},children:e=>(()=>{var t=ui();return z(t,()=>e.name,null),z(t,(()=>{var t=N(()=>!!e.version);return()=>t()?` ${e.version}`:``})(),null),t})()})),e}}),null),y})()}F([`input`,`click`]);var _i=P(`<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 vi(){return(()=>{var e=_i();return e.firstChild.nextSibling,e})()}var yi=P(`<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`),bi=P(`<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 xi(){let e=()=>{switch(ln()){case`connected`:return`#238636`;case`connecting`:return`#d29922`;case`error`:return`#f85149`;default:return`#8b949e`}};return(()=>{var t=bi(),n=t.firstChild.firstChild,r=n.nextSibling;return z(r,(()=>{var e=N(()=>ln()===`connected`);return()=>e()?`Online`:ln()})()),z(t,m(u,{get when(){return K()},get children(){return yi()}}),null),o(t=>R(n,`background-color`,e())),t})()}var Si=class{container;hoverGraphics;pendingGraphics;selectionContainer;selectionGraphics=new Map;selectionTypes=new Map;selectionVisuals=new Map;ticker=null;tickerCallback=null;constructor(e){this.container=new j,this.container.label=`hoverHighlight`,this.container.eventMode=`none`,this.hoverGraphics=new D,this.hoverGraphics.eventMode=`none`,this.container.addChild(this.hoverGraphics),this.pendingGraphics=new D,this.pendingGraphics.eventMode=`none`,this.container.addChild(this.pendingGraphics),this.selectionContainer=new j,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 D;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()}},J=48,Ci=128,wi={terrain:0,objects:10,animations:20,darkOverlay:30,visuals:40,hover:50,nav:60},Ti=new Set([`road`,`constructedWall`,`rampart`]),Ei=class e{app;world;hoverLayer;darkOverlay;lightLayer;overlayCanvas;overlayCtx;overlayTexture;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 j({sortableChildren:!0}),this.app.stage.addChild(this.world),this.overlayCanvas=document.createElement(`canvas`),this.overlayCanvas.width=600,this.overlayCanvas.height=600,this.overlayCtx=this.overlayCanvas.getContext(`2d`),this.redrawOverlayCanvas([]),this.overlayTexture=E.from(this.overlayCanvas),this.darkOverlay=new O(this.overlayTexture),this.darkOverlay.label=`darkOverlay`,this.darkOverlay.zIndex=wi.darkOverlay,this.world.addChild(this.darkOverlay),this.lightLayer=new j,this.lightLayer.label=`lightLayer`,this.hoverLayer=new Si(e.ticker),this.hoverLayer.container.zIndex=wi.hover,this.world.addChild(this.hoverLayer.container),this.navOverlay=new j,this.navOverlay.zIndex=wi.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 T;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?Ci:0;if(t<=n){let r=n/2-t/2;e?this.world.x=Math.min(r+Ci,Math.max(r-Ci,this.world.x)):this.world.x=r}else{let e=n-t-J-i,r=J+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+Ci,Math.max(n-Ci,this.world.y)):this.world.y=n}else{let e=r-t-J-i,n=J+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-J,i=J;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-J,r=J;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 k(0,0),n=new k(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 k(u.clientX,u.clientY),n=new k(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 k(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 D;o.x=e,o.y=t,o.hitArea=new ee(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,J,600,[18,300,J-6,282,J-6,318],e.west),t(600,0,J,600,[J-18,300,6,282,6,318],e.east),t(0,-48,600,J,[300,18,282,J-6,318,J-6],e.north),t(0,600,600,J,[300,J-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.redrawOverlayCanvas([]),this.overlayTexture.source.update()}updateLighting(e){let t=[];for(let n of Object.values(e))typeof n.type==`string`&&Ti.has(n.type)||typeof n.x!=`number`||typeof n.y!=`number`||t.push({x:n.x,y:n.y});this.redrawOverlayCanvas(t),this.overlayTexture.source.update()}redrawOverlayCanvas(e){let t=this.overlayCtx;if(t.clearRect(0,0,600,600),t.fillStyle=`rgba(0,0,0,0.2)`,t.fillRect(0,0,600,600),e.length>0){t.globalCompositeOperation=`destination-out`;for(let{x:n,y:r}of e){let e=(n+.5)*12,i=(r+.5)*12,a=t.createRadialGradient(e,i,0,e,i,36);a.addColorStop(0,`rgba(0,0,0,1)`),a.addColorStop(1,`rgba(0,0,0,0)`),t.fillStyle=a,t.beginPath(),t.arc(e,i,36,0,Math.PI*2),t.fill()}t.globalCompositeOperation=`source-over`}}destroy(){this.destroyed||(this.destroyed=!0,this.cancelBounce(),this.cancelWheelTimeout(),this.resizeObserver?.disconnect(),this.resizeObserver=null,this.hoverLayer.destroy(),this.overlayTexture.destroy(!0),this.app.destroy(!0,{children:!0}))}},Di=856343,Oi=1448738,ki=1843496,Ai=Di,ji=7039337,Mi=3159613,Ni={tough:5000268,move:11122630,work:16770413,carry:7829367,attack:16332866,ranged_attack:6127794,heal:6684002,claim:12164347},Pi=5809919,Fi=7979263,Ii=4176208,Li=9147550,Ri=13801762,zi=10711543,Bi=16218298,Vi=16273737,Hi=15763518,Ui=2172461,Wi=ji,Gi=12283502,Ki=[16777215,16711680,8388736,255,65535,32768,16776960,16753920,10824234,8421504,16777215],qi={creep:Hi,spawn:Pi,extension:Fi,tower:Ii,container:Li,storage:Ri,link:zi,rampart:Pi,road:Wi,constructedWall:Ui,extractor:Li,lab:Bi,terminal:Ri,observer:Fi,powerSpawn:Hi,nuker:Vi,factory:Li,invaderCore:Vi,source:Ri,mineral:Fi,deposit:Ri,controller:Pi,powerBank:Hi,portal:zi},Ji=16771195,Yi=Ji,Xi=Fi,Zi=Ji,Qi=Ji,$i=9419667,ea=7245682,ta=12116924,na=12283502,ra=9787480,ia=14721184,aa=ki,oa=13684944,Y=1579032,sa=5592405,ca=11184810,la=9419667,ua=16771195,da=16069959,fa=4410435;function pa(e){return e}function ma(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 ha(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 ga(e,t){let n=ji,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)!==et.Wall&&r(e,0,`up`),t.get(e,49)!==et.Wall&&r(e,49,`down`);for(let e=0;e<50;e++)t.get(0,e)!==et.Wall&&r(0,e,`left`),t.get(49,e)!==et.Wall&&r(49,e,`right`)}function _a(e){let t=new D;return t.rect(0,0,600,600),t.fill(e.floorColor),t}function va(e,t){let n=new D,r={color:t.swampBorderColor,width:12*t.swampBorderWidth,alignment:0,cap:`round`,join:`round`};return ha(n,e,et.Swamp,e=>e.stroke(r)),ha(n,e,et.Swamp,e=>e.fill(t.swampFillColor)),n}function ya(e,t){let n=new D,r={color:t.wallBorderColor,width:12*t.wallBorderWidth,alignment:0,cap:`round`,join:`round`};return ha(n,e,et.Wall,e=>e.stroke(r)),ha(n,e,et.Wall,e=>e.fill(t.wallFillColor)),ga(n,e),n.rect(0,0,600,600),n.stroke({width:1,color:Mi}),n}function ba(e,t){let n=new D;return n.label=`swampGlow`,ha(n,e,et.Swamp,e=>e.fill(t.swampGlowColor)),n.alpha=.45,n.filters=[new re({strength:5,quality:3})],n}function xa(e,t,n){let r=new D;ha(r,e,et.Wall,e=>e.fill(n.wallNoiseColor)),r.alpha=.5,r.filters=[new w({noise:.12,seed:1})],r.filterArea=new ee(0,0,600,600);let i=t.generateTexture({target:r,frame:r.filterArea});r.filters=null,r.destroy();let a=new O(i);return a.label=`wallNoise`,a}function Sa(e,t,n){let r=ma(n),i=new j,a=xa(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(_a(r)),i.addChild(va(e,r)),i.addChild(ya(e,r)),i.addChild(ba(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;ae.load(pa(e)).then(e=>{if(i.destroyed)return;let n=new ie({texture:e,width:600,height:600});n.tint=t,n.alpha=r,n.tileScale.set(a),i.addChildAt(n,2)}).catch(()=>{})}if(n?.wallTextureUrl){let{wallTextureUrl:t,wallTextureTint:r=16777215,wallTextureAlpha:a=1,wallTextureTileScale:o=1}=n;ae.load(pa(t)).then(t=>{if(i.destroyed)return;let n=new ie({texture:t,width:600,height:600});n.tint=r,n.alpha=a,n.tileScale.set(o);let s=new D;ha(s,e,et.Wall,e=>e.fill(16777215)),i.addChild(s),n.mask=s,i.addChild(n)}).catch(()=>{})}return i}function Ca(e,t){e.getChildByLabel(`swampGlow`).visible=t,e.getChildByLabel(`wallNoise`).visible=t}function wa(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 Ta(e){return parseInt(e.replace(`#`,``),16)}function Ea(e,t){if(e==null)return t;let n=Number(e);return isNaN(n)?t:n}function Da(e,t,n){let r=n.terrain??{};e.floorBackgroundColor&&(r.floorColor=wa(e.floorBackgroundColor,Ea(e.floorBackgroundBrightness,1))),e.swampColor&&(r.swampFillColor=Ta(e.swampColor)),e.swampStrokeColor&&(r.swampBorderColor=Ta(e.swampStrokeColor)),e.swampStrokeWidth!=null&&(r.swampBorderWidth=Ea(e.swampStrokeWidth,50)/250),e.roadsColor&&(n.roadColor=wa(e.roadsColor,Ea(e.roadsBrightness,1))),t.floorForegroundUrl&&(r.floorTextureUrl=t.floorForegroundUrl,e.floorForegroundColor&&(r.floorTextureTint=wa(e.floorForegroundColor,Ea(e.floorForegroundBrightness,1))),r.floorTextureAlpha=Ea(e.floorForegroundAlpha,1),r.floorTextureTileScale=Ea(e.tileScale??t.tileScale,1)),n.terrain=r}function Oa(e,t,n){let r=n.terrain??{};e.backgroundColor&&(r.wallFillColor=wa(e.backgroundColor,Ea(e.backgroundBrightness,1))),e.strokeColor&&(r.wallBorderColor=wa(e.strokeColor,Ea(e.strokeBrightness,1))),e.strokeWidth!=null&&(r.wallBorderWidth=Ea(e.strokeWidth,10)/250),t.foregroundUrl&&(r.wallTextureUrl=t.foregroundUrl,e.foregroundColor&&(r.wallTextureTint=wa(e.foregroundColor,Ea(e.foregroundBrightness,1))),r.wallTextureAlpha=Ea(e.foregroundAlpha,1),r.wallTextureTileScale=Ea(e.tileScale??t.tileScale,1)),n.terrain=r}function ka(e){let t={};for(let n of e.decorations){let e=n.decoration.type;e===`floorLandscape`?Da(n.active,n.decoration,t):e===`wallLandscape`&&Oa(n.active,n.decoration,t)}return t}function Aa(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>t(r),r.onerror=n,r.src=e})}var ja=class{cache=new Map;pending=new Map;getKey(e){return JSON.stringify(e)}has(e){return this.cache.has(this.getKey(e))}getOrCreate(e){let t=this.getKey(e),n=this.cache.get(t);if(n)return Promise.resolve(n);let r=this.pending.get(t);if(r)return r;let i=this.buildTexture(e,t);return this.pending.set(t,i),i.then(()=>{this.pending.delete(t)}).catch(()=>{this.pending.delete(t)}),i}async buildTexture(e,t){let n=Lt(e),r=new Blob([n],{type:`image/svg+xml;charset=utf-8`}),i=URL.createObjectURL(r);try{let e=window.devicePixelRatio||1,n=128*Math.max(2,e),r=await Aa(i),a=document.createElement(`canvas`);a.width=n,a.height=n,a.getContext(`2d`).drawImage(r,0,0,n,n);let o=E.from(a);return this.cache.set(t,o),o}finally{URL.revokeObjectURL(i)}}destroy(){for(let e of this.cache.values())e.destroyed||e.destroy(!0);this.cache.clear(),this.pending.clear()}},Ma={1:200,2:45e3,3:135e3,4:405e3,5:1215e3,6:3645e3,7:10935e3},Na={1:2e4,2:1e4,3:2e4,4:4e4,5:8e4,6:12e4,7:15e4,8:2e5},Pa=new ja,Fa=12*.44,Ia=12*.28,La=50,Ra=32,za=12/Ra,Ba=12/2-12*.44,Va=2,Ha=12*1.2/Ra,Ua=5,Wa=2.5,Ga=2,Ka=2.6,qa=2,Ja=12,Ya=15790320,Xa=1710618,Za=12*.42,Qa=12*.3,$a=1,eo={H:13421772,O:16777215,U:5822457,L:62626,K:10514943,Z:16631694,X:11568379},to={H:2236962,O:2236962},no=12*.42,ro=32,io=9/ro,ao=8,oo=12*.28,so=1600,co=16776428;function lo(e,t){if(t<=0)return ao;let n=Math.max(0,Math.min(1,e/t));return oo+(ao-oo)*n}function uo(e,t,n=ua){let r=t/2,i=t*.25;e.clear(),e.roundRect(6-r,6-r,t,t,i),e.fill(n)}function fo(e,t){let n=e.__sourceGraphics;n&&(e.__sourceSize=t,uo(n,t,po(performance.now())))}function po(e){let t=e%so/so;return bo(ua,co,.5-.5*Math.cos(t*Math.PI*2))}function mo(e){return{energy:typeof e.energy==`number`?e.energy:0,capacity:typeof e.energyCapacity==`number`?e.energyCapacity:3e3}}var ho=12*.3,go=1.44,_o=ho-go/2,vo=12*.42,yo=1500;function bo(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 xo(e,t){e.clear(),e.circle(12/2,12/2,ho),e.stroke({width:go,color:t,alpha:.95})}function So(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})}function Co(e,t,n){return n.flatMap(([n,r])=>[e+n*12,t+r*12])}function wo(e,t,n,r){n-t<.001||(e.moveTo(Fa*Math.cos(t),Fa*Math.sin(t)),e.arc(0,0,Fa,t,n),e.lineTo(Ia*Math.cos(n),Ia*Math.sin(n)),e.arc(0,0,Ia,n,t,!0),e.closePath(),e.fill(r))}function To(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 Eo(e,t){return t<=0||e<=0?0:Ia*.8*Math.min(1,e/t)}function Do(e,t){let n=e.__creepFillGraphics;n&&(n.clear(),t>0&&(n.circle(0,0,t),n.fill(Ji)))}function Oo(e){return qi[e]??13226457}function ko(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 Ao(e){return e>=200?1.15:e>=100?.85:.7}function jo(e,t){return t<=0||e<=0?0:Qa*Ao(t)*Math.min(1,e/t)}function Mo(e,t,n,r){let i=Ao(n),a=new D;a.circle(6,6,Za*i),a.fill(Y),a.circle(6,6,Za*i),a.stroke({width:$a*i,color:r}),a.circle(6,6,Qa*i),a.fill(ca),e.addChild(a);let o=new D,s=jo(t,n);s>0&&(o.circle(6,6,s),o.fill(ua)),e.addChild(o),e.__fillGraphics=o}function No(e,t){let n=e.__fillGraphics;n&&(n.clear(),t>0&&(n.circle(6,6,t),n.fill(ua)))}var Po=-12*.4,Fo=-12*.3,Io=12*.8,Lo=12*.6,Ro=12*.45,zo=12*.6,Bo=12*.275,Vo=12*.2;function Ho(e,t){return t<=0||e<=0?0:Lo*Math.min(1,e/t)}function Uo(e,t){let n=e.__towerFillGraphics;if(n&&(n.clear(),t>0)){let e=.5;n.rect(Po+e,Fo+Lo-t+e,Io-e*2,t-e*2),n.fill(ua)}}var Wo=0,Go=-12*.1,Ko=12,qo=12*1.2;function Jo(e){let t=typeof e.storeCapacity==`number`?e.storeCapacity:0;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)}}return{used:n,capacity:t}}function Yo(e,t){return t<=0||e<=0?0:zo*Math.min(1,e/t)}function Xo(e,t){let n=e.__containerFillG;if(n&&(n.clear(),t>0)){let e=.5;n.rect(Bo+e,Vo+zo-t+e,Ro-e*2,t-e*2),n.fill(ua)}}function Zo(e,t){return t<=0||e<=0?0:qo*Math.min(1,e/t)}function Qo(e,t){let n=e.__storageFillG;n&&(n.clear(),t>0&&(n.rect(Wo,Go+qo-t,Ko,t),n.fill(ua)))}var $o=12*.65,es=$o,ts=12*.42;function ns(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 rs(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 is(e,t){let n=e.user;return typeof n!=`string`||!t?!1:n!==t}function as(e,t=!0,n,r,i,a,o,s){let c=new j,l=new D,u=Oo(e.type),d=typeof e.user==`string`?e.user:void 0,f=d!==void 0&&n!==void 0&&d!==n?Gi:la;switch(e.type){case`creep`:{let t=2*Math.PI,r=new j;r.position.set(6,6),r.rotation=-Math.PI/2;let o=is(e,n);if(o){let e=new D;e.circle(0,0,Fa+.75),e.stroke({width:1.5,color:Gi}),r.addChild(e)}let s=new D;s.circle(0,0,Fa),s.fill(Di),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/La*t,g=d/La*t,_=f/La*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 D;h>0&&wo(w,-h/2,v,Ni.work??16770413);let T=v;for(let e of p){let n=(m[e]??0)/La*t/2;wo(w,T,T+n,Ni[e]??7829367),T+=n}wo(w,y,b,aa),g>0&&wo(w,b,x,Ni.move??11122630),wo(w,x,S,aa);let E=C;for(let e of p){let n=(m[e]??0)/La*t/2;wo(w,E-n,E,Ni[e]??7829367),E-=n}r.addChild(w);let ee=new D;ee.circle(0,0,Ia),ee.fill(Oi),r.addChild(ee);let te=typeof e.user==`string`?e.user:void 0,ne=te?a?.[te]?.badge:void 0;if(ne&&i){let e=new O;e.anchor.set(.5,.5);let t=Ia*2;e.width=t,e.height=t,e.rotation=Math.PI/2,r.addChild(e),c.__creepBadgeSprite=e,i.getOrCreate(ne).then(t=>{e.destroyed||(e.texture=t)}).catch(()=>{})}else if(o){let e=new D;e.circle(0,0,Ia*.82),e.fill({color:Gi,alpha:.9}),r.addChild(e),c.__creepForeignMark=e}let{used:re,capacity:k}=To(e),ie=Eo(re,k),ae=new D;ie>0&&(ae.circle(0,0,ie),ae.fill(Ji)),r.addChild(ae),c.__creepFillGraphics=ae,c.__creepUsed=re,c.__creepCapacity=k;let A=(Fa+Ia)/2,oe=(Fa-Ia)*.45,M=new D;M.moveTo(Fa,0),M.lineTo(A,-oe),M.lineTo(A,oe),M.closePath(),M.fill(oa),r.addChild(M),c.addChild(r),c.__bodyContainer=r;break}case`extension`:{let{energy:t,capacity:n}=ko(e);Mo(c,t,n,f),c.__extEnergy=t,c.__extCapacity=n;break}case`spawn`:l.circle(6,6,12*.65),l.fill(Y),l.circle(6,6,12*.65),l.stroke({width:12*.1,color:13421772}),l.circle(6,6,12*.4),l.fill(ua);break;case`powerSpawn`:l.circle(6,6,12*.65),l.fill(Y),l.circle(6,6,12*.65),l.stroke({width:12*.1,color:da}),l.circle(6,6,12*.4),l.fill(ua);break;case`source`:{let{energy:t,capacity:n}=mo(e),r=lo(t,n),i=new D;uo(i,r,po(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?$i:na,a=r?ea:ra,o=r?ta:ia,s=typeof e.progress==`number`?e.progress:0,l=typeof e.progressTotal==`number`?e.progressTotal:1,u=new D;c.addChild(u),c.__csBuildGlow=u;let d=new D;So(d,6,6,_o,s,l,i),c.addChild(d),c.__csFillGraphics=d;let f=new D;xo(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=eo[t]??7979263,r=to[t]??16777215,i=new D;i.circle(6,6,no),i.fill(n),c.addChild(i);let a=new A({text:t,style:{fontSize:ro,fill:r,fontWeight:`bold`}});a.anchor.set(.5,.5),a.scale.set(io),a.position.set(6,6),c.addChild(a);break}case`deposit`:l.rect(2,2,8,8),l.fill(u);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 O;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 O;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,rs(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]??E.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]??E.EMPTY;for(let e of l)e.destroyed||(e.texture=t)}).catch(()=>{})}else{let e=new D,i=[];for(let e=0;e<8;e++){let t=-Math.PI/2+e*Math.PI/4;i.push(6+$o*Math.cos(t),6+$o*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 D;ns(a,6,6,es,ts,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 D;if(d?(p.circle(6,6,ts),p.fill(Y)):(p.circle(6,6,ts),p.fill(3028031),p.circle(6,6,ts),p.stroke({width:12*.04,color:8027781}),p.circle(6,6,12*.16),p.fill(10133672)),c.addChild(p),d&&i){let e=new O;e.anchor.set(.5,.5),e.width=ts*2,e.height=ts*2,e.position.set(6,6);let t=new D;t.circle(6,6,ts),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(ua);break;case`road`:break;case`constructedWall`:break;case`rampart`:break;case`tower`:{let{energy:t,capacity:n}=ko(e),r=new D;r.circle(6,6,12*.6),r.fill(Y),r.circle(6,6,12*.6),r.stroke({width:12*.05,color:f}),c.addChild(r);let i=new j;i.position.set(6,6);let a=new D;a.rect(Po,Fo,Io,Lo),a.fill(Y),i.addChild(a);let o=new D;i.addChild(o),c.__towerFillGraphics=o,c.__towerEnergy=t,c.__towerCapacity=n,Uo(c,Ho(t,n));let s=new D;s.rect(Po,Fo,Io,Lo),s.stroke({width:1,color:sa}),i.addChild(s);let l=new D;l.rect(-12*.2,-12*.9,12*.4,12*.5),l.fill(ca),l.rect(-12*.2,-12*.9,12*.4,12*.5),l.stroke({width:12*.07,color:Y}),i.addChild(l),c.addChild(i),c.__barrelContainer=i;break}case`storage`:{let t=o?.sprites.storage;if(t&&s){let{used:n,capacity:r}=Jo(e),i=12*t.tileScale,a=(e,t)=>{e.texture=t,e.width=i,e.height=i};for(let e of t.layers){let t=new O;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?a(t,n):s.getOrLoad(o.atlasUrl).then(n=>{t.destroyed||a(t,n.textures[e.frame]??E.EMPTY)}).catch(()=>{})}let l=new D;c.addChild(l),c.__storageFillG=l,c.__storageUsed=n,c.__storageCapacity=r,Qo(c,Zo(n,r));break}let{used:n,capacity:r}=Jo(e),i=Co(6,6,[[-.6,-.7],[0,-.8],[.6,-.7],[.65,0],[.6,.7],[0,.8],[-.6,.7],[-.65,0],[-.6,-.7]]);l.poly(i),l.fill(Y),l.poly(i),l.stroke({width:12*.05,color:f}),l.rect(6-12*.5,6-12*.6,12,12*1.2),l.fill(sa),c.addChild(l);let a=new D;c.addChild(a),c.__storageFillG=a,c.__storageUsed=n,c.__storageCapacity=r,Qo(c,Zo(n,r));let u=new D;u.rect(6-12*.5,6-12*.6,12,12*1.2),u.stroke({width:12*.1,color:Y}),c.addChild(u);break}case`terminal`:{let e=Co(6,6,[[0,-.8],[.55,-.55],[.8,0],[.55,.55],[0,.8],[-.55,.55],[-.8,0],[-.55,-.55],[0,-.8]]),t=Co(6,6,[[0,-.65],[.45,-.45],[.65,0],[.45,.45],[0,.65],[-.45,.45],[-.65,0],[-.45,-.45],[0,-.65]]);l.poly(e),l.fill(Y),l.poly(e),l.stroke({width:12*.05,color:f}),l.poly(t),l.fill(ca),l.rect(6-12*.45,6-12*.45,12*.9,12*.9),l.fill(sa),l.rect(6-12*.45,6-12*.45,12*.9,12*.9),l.stroke({width:12*.1,color:Y});break}case`link`:{let e=Co(6,6,[[0,-.5],[.4,0],[0,.5],[-.4,0],[0,-.5]]),t=Co(6,6,[[0,-.3],[.25,0],[0,.3],[-.25,0],[0,-.3]]);l.poly(e),l.fill(Y),l.poly(e),l.stroke({width:12*.05,color:f}),l.poly(t),l.fill(sa);break}case`lab`:{let e=6-12*.025;l.circle(6,e,12*.55),l.fill(Y),l.circle(6,e,12*.55),l.stroke({width:12*.05,color:f}),l.circle(6,e,12*.4),l.fill(sa),l.rect(6-12*.45,9.6,12*.9,12*.25),l.fill(Y),l.poly(Co(6,6,[[-.45,.3],[-.45,.55],[.45,.55],[.45,.3]])),l.stroke({width:12*.05,color:f});break}case`container`:{let{used:t,capacity:n}=Jo(e);l.rect(Bo,Vo,Ro,zo),l.fill(Y),c.addChild(l);let r=new D;c.addChild(r),c.__containerFillG=r,c.__containerUsed=t,c.__containerCapacity=n,Xo(c,Yo(t,n));let i=new D;i.rect(Bo,Vo,Ro,zo),i.stroke({width:12*.1,color:Y}),c.addChild(i);break}case`observer`:l.circle(6,6,12*.45),l.fill(Y),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 e=Co(6,6,[[0,-1],[-.47,.2],[-.5,.5],[.5,.5],[.47,.2],[0,-1]]),t=Co(6,6,[[0,-.8],[-.4,.2],[.4,.2],[0,-.8]]);l.poly(e),l.fill(Y),l.poly(e),l.stroke({width:12*.05,color:f}),l.poly(t),l.fill(sa),l.poly(t),l.stroke({width:12*.01,color:f});break}case`factory`:case`extractor`:case`invaderCore`:l.circle(6,6,12*.45),l.fill(Y),l.circle(6,6,12*.45),l.stroke({width:12*.05,color:f}),l.circle(6,6,12*.35),l.fill(sa);break;case`flag`:{let n=typeof e.color==`number`?e.color:0,r=typeof e.secondaryColor==`number`?e.secondaryColor:0,i=Ki[n]??Ki[0],a=Ki[r]??Ki[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 O;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]??E.EMPTY)}).catch(()=>{}),r!==n){let e=new O;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]??E.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 A({text:e.name,style:{fontSize:Ra,fill:16777215}});n.scale.set(za),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?$i:Gi,i=12*.42,a=Math.PI/5,o=new D;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 D;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?$i:Gi,i=o?.tombstone;if(i&&s){let e=12*i.tileScale,t=()=>s.getOrLoad(o.atlasUrl),n=new O;n.anchor.set(.5,.5),n.x=6,n.y=6,n.width=e,n.height=e,c.addChild(n);let a=new O;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]??E.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]??E.EMPTY)}).catch(()=>{})}else{let e=12*.62,t=6-e/2,n=e/2,i=new D;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(Y),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 D;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}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`&&c.addChild(l),e.type===`creep`&&typeof e.name==`string`){let r=is(e,n),i;if(r){let t=typeof e.user==`string`?e.user:void 0;i=t?a?.[t]?.username??t:`Hostile`}else i=e.name;let o=new A({text:i,style:{fontSize:Ra,fill:r?Gi:16777215}});o.scale.set(za),o.anchor.set(.5,1),o.x=6,o.y=Ba-Va,o.visible=t,c.__nameLabel=o,c.addChild(o)}return c.zIndex=(e.type===`creep`?100:e.type===`flag`?200:0)+(e.type===`flag`?o?.flag?.zIndex??0:e.type===`controller`?o?.controller?.zIndex??0:e.type===`tombstone`?o?.tombstone?.zIndex??0:o?.sprites[e.type]?.zIndex??0),c.position.set(e.x*12,e.y*12),c}function os(e){e.destroy({children:!0})}function ss(e){let t=new A({text:e.length>Ja?e.slice(0,Ja):e,style:{fontSize:Ra,fill:Xa,fontWeight:`600`}});t.scale.set(Ha),t.anchor.set(.5,.5);let n=t.width,r=t.height,i=n+Ua*2,a=r+Wa*2,o=a/2,s=new D;s.roundRect(-i/2,-a/2,i,a,o),s.fill(Ya),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+Ka),s.lineTo(Ga,a/2-.1),s.closePath(),s.fill(Ya),s.moveTo(-2,a/2-.1),s.lineTo(0,a/2+Ka),s.lineTo(Ga,a/2-.1),s.stroke({width:.4,color:1118481,alpha:.55});let c=new j;return c.addChild(s),c.addChild(t),c.pivot.set(0,a/2+Ka),c}var cs=class{container;objects=new Map;rawObjects=new Map;roadGraphics;rampartGraphics;wallGraphics;wallMarkGraphics;ticker=null;tickerCallback=null;extAnimations=new Map;creepFillAnimations=new Map;towerFillAnimations=new Map;storageFillAnimations=new Map;containerFillAnimations=new Map;sourceAnimations=new Map;buildGlowAnimations=new Map;ctrlFlashAnimations=new Map;currentGameTime=0;sayBubbles=new Set;moveDuration=600;EXT_ANIM_DURATION=300;instantMode=!1;lastWorldScale=1;showLabels;currentUserId;badge;badgeCache=Pa;users;activeTheme=null;atlasCache=null;roadColor=Wi;constructor(e,t=!0,n,r,i){this.showLabels=t,this.currentUserId=n,this.badge=r,this.users=i,this.container=new j,this.container.sortableChildren=!0,this.wallGraphics=new D,this.wallGraphics.zIndex=-3,this.container.addChild(this.wallGraphics),this.wallMarkGraphics=new D,this.wallMarkGraphics.zIndex=-2,this.container.addChild(this.wallMarkGraphics),this.rampartGraphics=new D,this.rampartGraphics.zIndex=-1,this.container.addChild(this.rampartGraphics),this.roadGraphics=new D,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()}tick(){let e=performance.now();for(let t of this.objects.values()){if(t.__targetX===void 0||t.__targetY===void 0)continue;let n=t.__moveDur??0,r=e-(t.__moveStartT??e);if(n<=0||r>=n){t.position.set(t.__targetX,t.__targetY),t.__targetX=void 0,t.__targetY=void 0,t.__moveStartX=void 0,t.__moveStartY=void 0,t.__moveStartT=void 0,t.__moveDur=void 0;continue}let i=r/n,a=t.__moveStartX??t.x,o=t.__moveStartY??t.y;t.x=a+(t.__targetX-a)*i,t.y=o+(t.__targetY-o)*i}let t=this.container.parent?.scale.x??1;if(t!==this.lastWorldScale){this.lastWorldScale=t;for(let e of this.objects.values())this.applyLabelScale(e)}let n=performance.now(),r=n/1e3,i=.5+.5*Math.sin(n*2*Math.PI/yo);for(let e of this.objects.values())e.__barrelContainer&&(e.__barrelContainer.rotation=r*.4),e.__csRingGraphics&&e.__csColorDark!==void 0&&e.__csColorLight!==void 0&&xo(e.__csRingGraphics,bo(e.__csColorDark,e.__csColorLight,i));for(let[e,t]of this.extAnimations){let r=n-t.startTime,i=Math.min(1,r/this.EXT_ANIM_DURATION),a=i<.5?2*i*i:1-(-2*i+2)**2/2;No(t.visual,t.fromRadius+(t.toRadius-t.fromRadius)*a),i>=1&&this.extAnimations.delete(e)}for(let[e,t]of this.creepFillAnimations){let r=n-t.startTime,i=Math.min(1,r/this.EXT_ANIM_DURATION),a=i<.5?2*i*i:1-(-2*i+2)**2/2;Do(t.visual,t.fromRadius+(t.toRadius-t.fromRadius)*a),i>=1&&this.creepFillAnimations.delete(e)}for(let[e,t]of this.towerFillAnimations){let r=n-t.startTime,i=Math.min(1,r/this.EXT_ANIM_DURATION),a=i<.5?2*i*i:1-(-2*i+2)**2/2;Uo(t.visual,t.fromRadius+(t.toRadius-t.fromRadius)*a),i>=1&&this.towerFillAnimations.delete(e)}for(let[e,t]of this.storageFillAnimations){let r=n-t.startTime,i=Math.min(1,r/this.EXT_ANIM_DURATION),a=i<.5?2*i*i:1-(-2*i+2)**2/2;Qo(t.visual,t.fromRadius+(t.toRadius-t.fromRadius)*a),i>=1&&this.storageFillAnimations.delete(e)}for(let[e,t]of this.containerFillAnimations){let r=n-t.startTime,i=Math.min(1,r/this.EXT_ANIM_DURATION),a=i<.5?2*i*i:1-(-2*i+2)**2/2;Xo(t.visual,t.fromRadius+(t.toRadius-t.fromRadius)*a),i>=1&&this.containerFillAnimations.delete(e)}for(let[e,t]of this.sourceAnimations){let r=n-t.startTime,i=Math.min(1,r/this.EXT_ANIM_DURATION),a=i<.5?2*i*i:1-(-2*i+2)**2/2;fo(t.visual,t.fromRadius+(t.toRadius-t.fromRadius)*a),i>=1&&this.sourceAnimations.delete(e)}let a=po(n);for(let e of this.objects.values()){let t=e.__sourceGraphics;t&&uo(t,e.__sourceSize??ao,a)}for(let[e,t]of this.buildGlowAnimations){let r=this.objects.get(e),i=r?.__csBuildGlow;if(!r||!i){this.buildGlowAnimations.delete(e);continue}let a=(n-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,vo),i.fill({color:ua,alpha:o*.75})),a>=1&&this.buildGlowAnimations.delete(e)}for(let[e,t]of this.ctrlFlashAnimations){let r=this.objects.get(e),i=r?.__ctrlSegSprites;if(!r||!i){this.ctrlFlashAnimations.delete(e);continue}let a=Math.min(1,(n-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,r=e.__ctrlSegSprites;if(!t||!r)continue;let i=e.__ctrlDowngradeTime;if(!i){for(let e=0;e<t;e++){let t=r[e];t&&!t.destroyed&&(t.tint=16777215)}continue}let a=Na[t]??2e4,o=1-Math.max(0,i-this.currentGameTime)/a;if(o<=.2){for(let e=0;e<t;e++){let t=r[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*n/1e3),u=bo(16777215,bo(16768477,16720418,s),s*l);for(let e=0;e<t;e++){let t=r[e];t&&!t.destroyed&&(t.tint=u)}}}startExtAnimation(e,t,n,r,i,a){let o=jo(i,a);if(this.instantMode){No(t,o);return}let s=jo(n,r);s!==o&&this.extAnimations.set(e,{visual:t,fromRadius:s,toRadius:o,startTime:performance.now()})}startCreepFillAnimation(e,t,n,r,i,a){let o=Eo(i,a);if(this.instantMode){Do(t,o);return}let s=Eo(n,r);s!==o&&this.creepFillAnimations.set(e,{visual:t,fromRadius:s,toRadius:o,startTime:performance.now()})}startTowerFillAnimation(e,t,n,r,i,a){let o=Ho(i,a);if(this.instantMode){Uo(t,o);return}let s=Ho(n,r);s!==o&&this.towerFillAnimations.set(e,{visual:t,fromRadius:s,toRadius:o,startTime:performance.now()})}startStorageFillAnimation(e,t,n,r,i,a){let o=Zo(i,a);if(this.instantMode){Qo(t,o);return}let s=Zo(n,r);s!==o&&this.storageFillAnimations.set(e,{visual:t,fromRadius:s,toRadius:o,startTime:performance.now()})}startContainerFillAnimation(e,t,n,r,i,a){let o=Yo(i,a);if(this.instantMode){Xo(t,o);return}let s=Yo(n,r);s!==o&&this.containerFillAnimations.set(e,{visual:t,fromRadius:s,toRadius:o,startTime:performance.now()})}startSourceAnimation(e,t,n,r,i,a){let o=lo(i,a);if(this.instantMode){fo(t,o);return}let s=lo(n,r);s!==o&&this.sourceAnimations.set(e,{visual:t,fromRadius:s,toRadius:o,startTime:performance.now()})}update(e,t,n,r){n&&(this.users=n),r!==void 0&&(this.currentGameTime=r);let i=!1;if(t)for(let n in t)if(t[n]===null){let e=this.rawObjects.get(n);e&&e.type===`road`&&(i=!0);let t=this.objects.get(n);t&&(this.container.removeChild(t),os(t),this.objects.delete(n),this.rawObjects.delete(n),this.extAnimations.delete(n),this.creepFillAnimations.delete(n),this.towerFillAnimations.delete(n),this.storageFillAnimations.delete(n),this.containerFillAnimations.delete(n),this.sourceAnimations.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)}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}=To(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)}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),os(r),this.objects.delete(n);let e=as(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}=ko(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===`tower`){let{energy:e,capacity:i}=ko(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{used:e,capacity:i}=Jo(t);(r.__storageUsed!==e||r.__storageCapacity!==i)&&(this.startStorageFillAnimation(n,r,r.__storageUsed??0,r.__storageCapacity??i,e,i),r.__storageUsed=e,r.__storageCapacity=i)}if(t.type===`container`){let{used:e,capacity:i}=Jo(t);(r.__containerUsed!==e||r.__containerCapacity!==i)&&(this.startContainerFillAnimation(n,r,r.__containerUsed??0,r.__containerCapacity??i,e,i),r.__containerUsed=e,r.__containerCapacity=i)}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),os(r),this.objects.delete(n);let e=as(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}),rs(r,e,i,a)):r.__ctrlSegGraphics&&ns(r.__ctrlSegGraphics,12/2,12/2,es,ts,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}=mo(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&&So(r.__csFillGraphics,12/2,12/2,_o,e,n,r.__csColor??9419667),r.__csProgress=e,r.__csProgressTotal=n)}}else{let e=as(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}=To(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)}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),os(i),this.objects.delete(n);let e=as(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}=ko(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===`tower`){let{energy:e,capacity:t}=ko(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),os(i),this.objects.delete(n);let e=as(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}),rs(i,e,t,a)):i.__ctrlSegGraphics&&ns(i.__ctrlSegGraphics,12/2,12/2,es,ts,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}=mo(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&&So(i.__csFillGraphics,12/2,12/2,_o,e,t,i.__csColor??9419667),i.__csProgress=e,i.__csProgressTotal=t)}}else{let e=as(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),os(n),this.objects.delete(e),this.rawObjects.delete(e),this.extAnimations.delete(e),this.creepFillAnimations.delete(e),this.towerFillAnimations.delete(e),this.sourceAnimations.delete(e),this.buildGlowAnimations.delete(e),this.ctrlFlashAnimations.delete(e),this.sayBubbles.delete(e));i=!0}this.redrawWalls(),this.redrawRamparts(),i&&this.redrawRoads(),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(Y);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();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:fa,alpha:.7}:{color:7807522,alpha:.5};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)}}}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(za/t),e.__nameLabel.anchor.y===0?e.__nameLabel.y=12.600000000000001:e.__nameLabel.y=Ba-Va/t),e.__sayBubble&&!e.__sayBubble.destroyed&&(e.__sayBubble.scale.set(1/t),e.__sayBubble.position.set(12/2,Ba-qa/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||!is(n,this.currentUserId))continue;let r=typeof n.user==`string`?n.user:void 0,i=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`||!is(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 O;o.anchor.set(.5,.5);let s=Ia*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}}}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=ss(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)}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.extAnimations.values())No(e.visual,e.toRadius);this.extAnimations.clear();for(let e of this.creepFillAnimations.values())Do(e.visual,e.toRadius);this.creepFillAnimations.clear();for(let e of this.towerFillAnimations.values())Uo(e.visual,e.toRadius);this.towerFillAnimations.clear();for(let e of this.sourceAnimations.values())fo(e.visual,e.toRadius);this.sourceAnimations.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())os(e);this.objects.clear(),this.rawObjects.clear(),this.extAnimations.clear(),this.creepFillAnimations.clear(),this.towerFillAnimations.clear(),this.sourceAnimations.clear(),this.buildGlowAnimations.clear(),this.ctrlFlashAnimations.clear(),this.sayBubbles.clear(),this.roadGraphics.clear(),this.rampartGraphics.clear(),this.container.removeChildren(),this.container.addChild(this.rampartGraphics),this.container.addChild(this.roadGraphics)}destroy(){this.clear(),this.ticker&&this.tickerCallback&&this.ticker.remove(this.tickerCallback),this.ticker=null,this.tickerCallback=null}},ls=2;function us(e,t){return{cx:e*12+12/2,cy:t*12+12/2}}var ds=class{container;graphics;animations=[];ticker=null;tickerCallback=null;constructor(e){this.container=new j,this.graphics=new D,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=us(e,t),o=us(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:Yi,width:ls})}addUpgradeController(e,t,n,r,i){let a=us(e,t),o=us(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:Xi,width:ls})}addTransfer(e,t,n,r,i){let a=us(e,t),o=us(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:Qi,width:ls})}addBuild(e,t,n,r,i){let a=us(e,t),o=us(n,r);this.animations.push({fromX:a.cx,fromY:a.cy,toX:o.cx,toY:o.cy,startTime:performance.now(),duration:i,color:Zi,width:ls})}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}this.graphics.moveTo(o,s),this.graphics.lineTo(c,l),this.graphics.stroke({width:r.width,color:r.color}),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()}},X=e=>(e+.5)*12,fs={dashed:[.3*12,.25*12],dotted:[.1*12,.2*12]},ps=2400;function ms(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 hs(e){if(typeof e!=`string`)return`sans-serif`;let t=e.match(/^[0-9.]+(px)?\s+(.+)$/);return t?t[2]:`sans-serif`}var gs=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=E.from(this.canvas,!0),this.lastPhysSize=r,this.sprite=new O(this.texture),this.sprite.scale.set(600/r),this.container=new j,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),ps)}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=E.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`?fs.dotted:t.lineStyle===`dashed`?fs.dashed:[]),r.beginPath(),r.moveTo(X(e.x1),X(e.y1)),r.lineTo(X(e.x2),X(e.y2)),r.stroke(),r.restore()}drawCircle(e,t,n){let{ctx:r}=this;r.save(),r.globalAlpha=n,r.setLineDash(t.lineStyle===`dotted`?fs.dotted:t.lineStyle===`dashed`?fs.dashed:[]),r.beginPath(),r.arc(X(e.x),X(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`?fs.dotted:t.lineStyle===`dashed`?fs.dashed:[]),r.beginPath(),r.rect(X(e.x),X(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`?fs.dotted:t.lineStyle===`dashed`?fs.dashed:[]),r.beginPath(),r.moveTo(X(e.points[0][0]),X(e.points[0][1]));for(let t=1;t<e.points.length;t++)r.lineTo(X(e.points[t][0]),X(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=ms(t.font)*12,a=hs(t.font),o=t.align??`left`,s=X(e.x),c=X(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})}};function _s(e,t){let n=localStorage.getItem(e),[r,i]=x(n===null?t:n===`true`);return[r,t=>{i(t),localStorage.setItem(e,String(t))}]}function vs(e,t){let[n,r]=x(localStorage.getItem(e)??t);return[n,t=>{r(t),localStorage.setItem(e,t)}]}var[ys,bs]=_s(H.widescreenMode,!0),[xs,Ss]=_s(H.showCreepLabels,!0),[Cs,ws]=_s(H.showMapRoomNames,!1),[Ts,Es]=_s(H.showUnclaimableRooms,!0),[Ds,Os]=_s(H.terrainEffects,!0),[ks,As]=_s(H.showRoomDecorations,!1),[js,Ms]=_s(H.roomDarkOverlay,!0),[Ns,Ps]=_s(H.showRoomVisuals,!0),[Fs,Is]=vs(H.spriteTheme,`default`),[Ls,Rs]=_s(H.verboseCreepDetails,!0),[zs,Bs]=_s(H.showMapVisuals,!0),Vs={id:`default`,name:`Default`,atlasUrl:`${qt()}/themes/default/test.json`,sprites:{storage:{layers:[{frame:`storage/shell`,tint:`owner`},{frame:`storage/fill`}],tileScale:1.75}},controller:{backgroundFrame:`controller/background`,segmentFrame:`controller/segment`,tileScale:2},flag:{mainFrame:`flag/main`,secondFrame:`flag/second`,tileScale:3,zIndex:5},tombstone:{shellFrame:`grave/shell`,crossFrame:`grave/cross`,tileScale:1,zIndex:4}},Hs=new class{cache=new Map;pending=new Map;getOrLoad(e){let t=this.cache.get(e);if(t)return Promise.resolve(t);let n=this.pending.get(e);if(n)return n;let r=ae.load(e).then(t=>(this.cache.set(e,t),this.pending.delete(e),t)).catch(t=>{throw this.pending.delete(e),t});return this.pending.set(e,r),r}getTexture(e,t){return this.cache.get(e)?.textures?.[t]}destroy(){for(let[,e]of this.cache)e.destroy(!0);this.cache.clear(),this.pending.clear()}},Us=Symbol(`store-raw`),Ws=Symbol(`store-node`),Gs=Symbol(`store-has`),Ks=Symbol(`store-self`),qs={onStoreNodeUpdate:null};function Js(e){let t=e[c];if(!t&&(Object.defineProperty(e,c,{value:t=new Proxy(e,nc)}),!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 Ys(e){let t;return typeof e==`object`&&!!e&&(e[c]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function Xs(e,t=new Set){let n,r,i,a;if(n=e!=null&&e[Us])return n;if(!Ys(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=Xs(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=Xs(i,t))!==i&&(e[a]=r))}return e}function Zs(e,t){let n=e[t];return n||Object.defineProperty(e,t,{value:n=Object.create(null)}),n}function Qs(e,t,n){if(e[t])return e[t];let[r,i]=x(n,{equals:!1,internal:!0});return r.$=i,e[t]=r}function $s(e,t){let n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||!n.configurable||t===c||t===Ws?n:(delete n.value,delete n.writable,n.get=()=>e[c][t],n)}function ec(e){s()&&Qs(Zs(e,Ws),Ks)()}function tc(e){return ec(e),Reflect.ownKeys(e)}var nc={get(e,t,n){if(t===Us)return e;if(t===c)return n;if(t===p)return ec(e),n;let r=Zs(e,Ws),i=r[t],a=i?i():e[t];if(t===Ws||t===Gs||t===`__proto__`)return a;if(!i){let n=Object.getOwnPropertyDescriptor(e,t);s()&&(typeof a!=`function`||e.hasOwnProperty(t))&&!(n&&n.get)&&(a=Qs(r,t,a)())}return Ys(a)?Js(a):a},has(e,t){return t===Us||t===c||t===p||t===Ws||t===Gs||t===`__proto__`?!0:(s()&&Qs(Zs(e,Gs),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:tc,getOwnPropertyDescriptor:$s};function rc(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;qs.onStoreNodeUpdate&&qs.onStoreNodeUpdate(e,t,n,i),n===void 0?(delete e[t],e[Gs]&&e[Gs][t]&&i!==void 0&&e[Gs][t].$()):(e[t]=n,e[Gs]&&e[Gs][t]&&i===void 0&&e[Gs][t].$());let o=Zs(e,Ws),s;if((s=Qs(o,t,i))&&s.$(()=>n),Array.isArray(e)&&e.length!==a){for(let t=e.length;t<a;t++)(s=o[t])&&s.$();(s=Qs(o,`length`,a))&&s.$(e.length)}(s=o[Ks])&&s.$()}function ic(e,t){let n=Object.keys(t);for(let r=0;r<n.length;r+=1){let i=n[r];ac(i)||rc(e,i,t[i])}}function ac(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function oc(e,t){if(typeof t==`function`&&(t=t(e)),t=Xs(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&&rc(e,n,r)}rc(e,`length`,r)}else ic(e,t)}function sc(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&&ac(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++)sc(e,[r[i]].concat(t),n);return}else if(o&&a===`function`){for(let i=0;i<e.length;i++)r(e[i],i)&&sc(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)sc(e,[r].concat(t),n);return}else if(t.length>1){sc(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=Xs(a),r===void 0||Ys(i)&&Ys(a)&&!Array.isArray(a)?ic(i,a):rc(e,r,a))}function cc(...[e,t]){let n=Xs(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=Js(n);_.registerGraph({value:n,name:t&&t.name});function a(...e){h(()=>{r&&e.length===1?oc(n,e[0]):sc(n,e)})}return[i,a]}var lc=Symbol(`store-root`);function uc(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function dc(e,t,n,r,i){if(uc(n))return;let a=t[n];if(e===a)return;let o=Array.isArray(e);if(n!==lc&&(!Ys(e)||!Ys(a)||o!==Array.isArray(a)||i&&e[i]!==a[i])){rc(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++)dc(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++)rc(a,n,e[n]);for(;n<e.length;n++)rc(a,n,f[n]),dc(e[n],a,n,r,i);a.length>e.length&&rc(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?(rc(a,n,f[n]),dc(e[n],a,n,r,i)):rc(a,n,e[n])}else for(let t=0,n=e.length;t<n;t++)dc(e[t],a,t,r,i);a.length>e.length&&rc(a,`length`,e.length);return}let s=Object.keys(e);for(let t=0,n=s.length;t<n;t++)uc(s[t])||dc(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&&rc(a,c[t],void 0)}function fc(e,t={}){let{merge:n,key:r=`id`}=t,i=Xs(e);return e=>{if(!Ys(e)||!Ys(i))return i;let t=dc(i,{[lc]:e},lc,n,r);return t===void 0?e:t}}var pc=new WeakMap;function mc(e,t){let[n,r]=cc(t),i={id:e,type:t.type,raw:n};return pc.set(i,e=>r(fc(e,{key:`_id`,merge:!1}))),i}var[hc,gc]=x([]);function _c(){gc([])}function vc(e){gc(t=>t.filter(t=>t.id!==e))}function yc(e,t){let n=hc(),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&&pc.get(a)?.(e)}i.push(a)}r&&gc(i)}function bc(e){let t=hc();if(t.length===0)return;let n=!1,r=[];for(let i of t){let t=e[i.id];if(!t){n=!0;continue}pc.get(i)?.(t),r.push(i)}n&&gc(r)}var[xc,Sc]=x(null),[Cc,wc]=x(null),[Tc,Ec]=x(null),[Dc,Oc]=x(null),[kc,Ac]=x(null),[jc,Mc]=x({}),[Nc,Pc]=x(null),[Fc,Ic]=x(null),[Lc,Rc]=x(null);function zc(e,t,n){return isNaN(n.minX)||isNaN(n.maxX)||isNaN(n.minY)||isNaN(n.maxY)?!0:e>=n.minX&&e<=n.maxX&&t>=n.minY&&t<=n.maxY}function Bc(e){let t=e.match(/^([WE])(\d+)([NS])(\d+)$/);if(!t)return null;let[,n,r,i,a]=t;return{x:n===`W`?-(parseInt(r,10)+1):parseInt(r,10),y:i===`N`?-(parseInt(a,10)+1):parseInt(a,10)}}function Vc(e,t){let n=e<0?`W`:`E`,r=t<0?`N`:`S`;return`${n}${e<0?-e-1:e}${r}${t<0?-t-1:t}`}function Hc(e){return e===0||e<0&&(e+1)%10==0||e>0&&e%10==0}function Uc(e,t){return Hc(e)||Hc(t)}function Wc(e,t){let n=e<0?Math.abs(e+1)%10:Math.abs(e)%10,r=t<0?Math.abs(t+1)%10:Math.abs(t)%10;return n>=4&&n<=6&&r>=4&&r<=6}function Gc(e){let t=e;if(!t)return!1;let n=t.tagName??``;return n===`INPUT`||n===`TEXTAREA`?!0:t.isContentEditable===!0}function Kc(e){let t=t=>{if(Gc(t.target))return;let n=e.currentRoom(),r=n?Bc(n):null;if(!r)return;let i=e.worldBounds(),a=(e,t)=>!i||zc(e,t,i);switch(t.key){case`ArrowLeft`:t.preventDefault(),a(r.x-1,r.y)&&e.onMove(r.x-1,r.y);break;case`ArrowRight`:t.preventDefault(),a(r.x+1,r.y)&&e.onMove(r.x+1,r.y);break;case`ArrowUp`:t.preventDefault(),a(r.x,r.y-1)&&e.onMove(r.x,r.y-1);break;case`ArrowDown`:t.preventDefault(),a(r.x,r.y+1)&&e.onMove(r.x,r.y+1);break}};window.addEventListener(`keydown`,t),y(()=>window.removeEventListener(`keydown`,t))}var[Z,qc]=x(!1),[Jc,Yc]=x(0),[Xc,Zc]=x(0),[Qc,$c]=x(0),[el,tl]=x(!1),[nl,rl]=x(1),[il,al]=x(!1),ol=null;function sl(){ol!==null&&(clearInterval(ol),ol=null)}function cl(){sl(),ol=setInterval(()=>{let e=Jc()+1;e>Qc()?(sl(),tl(!1)):Yc(e)},Math.max(50,Math.round(1e3/nl())))}function ll(e){let t=e,n=Math.max(0,t-2e5);$c(t),Zc(n),Yc(e),tl(!1),sl(),qc(!0)}function ul(){sl(),tl(!1),qc(!1)}function dl(e){Yc(Math.max(Xc(),Math.min(Qc(),e)))}function fl(e){dl(Jc()+e)}function pl(){el()?(sl(),tl(!1)):(tl(!0),cl())}function ml(e){rl(e),el()&&cl()}var hl=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{let i=t-this.chunkSize;if(i<0)throw Error(`No history data available before tick ${t}`);n=await this.loadChunk(i),t=i;let a=Object.keys(n.ticks).map(Number).filter(e=>e>=t),o=a.length>0?Math.max(...a):t;r=o,e=o}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}}},gl=P(`<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`),_l=P(`<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`),vl=P(`<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`),yl=P(`<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`),bl=P(`<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`),xl=P(`<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:Sl,warn:Cl,error:wl}=Jt(`build`),Tl={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},El={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}},[Dl,Ol]=x(`view`),[kl,Al]=x({name:``,color:`COLOR_WHITE`,secondaryColor:`COLOR_WHITE`}),[jl,Ml]=x(null),[Nl,Pl]=x(null),[Fl,Il]=x({structureType:``,structureName:``});v(()=>{f(()=>{let e=Fl().structureType;if(!e)return;let t=Tc()??0,n=El[e];if(!n)return;let r=Tn()===`empty`&&e===`spawn`?Math.max(n[t]??0,1):n[t]??0;r!==2500&&(jc()[e]??0)>=r&&(Il({structureType:``,structureName:``}),Ll())})});function Ll(){Ml(null)}function Rl(){Pl(null)}function zl(){Il({structureType:``,structureName:``})}function Bl(e,t){let n=W(),r=Fl(),i=jl();if(!n||!r.structureType||!i){Cl(`missing requirements`,{hasClient:!!n,structureType:r.structureType,pending:i});return}if(Tn()===`empty`&&r.structureType===`spawn`){Sl(`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(()=>(Sl(`spawn placed`),V(`Spawn placed successfully`,`success`),Ll(),n.stores.user.refreshWorldStatus())).catch(e=>{wl(`place spawn failed:`,e),V(`Failed to place spawn: ${e.message}`,`error`)});return}Sl(`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(()=>{Sl(`construction site created`),V(`Construction site for ${r.structureType} created`,`success`),Ll()}).catch(e=>{wl(`create construction failed:`,e),V(`Failed to create construction site: ${e.message}`,`error`)})}function Vl(){Ol(`view`),Ll(),Rl(),zl()}function Hl(){Ol(`view`),Ll(),r(Nl)?.type!==`moveFlag`&&Rl(),zl()}function Ul(){let e=Dl(),t=jl(),n=Nl(),r=Tn();if(r===`empty`)return(()=>{var e=gl(),t=e.firstChild.nextSibling;return t.$$click=()=>{Ol(`build`),Il({structureType:`spawn`,structureName:``})},e})();if(r===`lost`)return(()=>{var e=_l(),t=e.firstChild.nextSibling;return t.$$click=()=>{let e=W();e&&e.http.user.respawn().then(()=>{V(`Respawn successful`,`success`),e.stores.user.refreshWorldStatus()}).catch(e=>{V(`Respawn failed: ${e.message}`,`error`)})},e})();if(n?.type===`moveFlag`)return(()=>{var e=vl(),t=e.firstChild,r=t.firstChild.nextSibling;return r.nextSibling,t.nextSibling,z(t,()=>n.name,r),z(t,()=>n.targetRoom,null),e})();if(e===`flag`)return(()=>{var e=yl(),n=e.firstChild;return n.nextSibling,z(n,t?`Click again to confirm position`:`Click to choose flag position`),e})();if(e===`build`){let e=Fl(),t=Tc(),n=jc(),r=e.structureType;if(!r)return(()=>{var e=bl();return e.firstChild.nextSibling.nextSibling,e})();let i=El[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=xl(),t=e.firstChild;return t.nextSibling.nextSibling,z(t,`Click to build ${o} (${s})`),e})()}return null}F([`click`]);var Wl=P(`<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>`),Gl=P(`<div style=width:100%;height:100%;position:relative><div style=width:100%;height:100%>`),Kl=P(`<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">`),ql=P(`<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:Jl,error:Yl}=Jt(`room`);function Xl(e){let t=e=>e==="default"?Vs:null,n,i=null,s=null,c=null,l=null,d=null,[p,h]=x(null),[g,_]=x(null),[v,b]=x(null),[S,C]=x(null),[w,T]=x(``),[E,ee]=x(Jc());f(()=>ee(Jc()));let D=null;return a(async()=>{n&&h(await Ei.create(n))}),y(()=>{D!==null&&clearTimeout(D),i?.destroy(),i=null,c?.destroy(),c=null,l?.destroy(),l=null;let e=p();e&&e.destroy()}),f(()=>{let t=W();if(!t||Z())return;let n=e.room,i=e.shard;Jl(`navigate → ${n} (shard=${i??`default`})`),_(null),b(null),C(null),T(``),_n(null),_c(),Rc(n),Ic(i),Sc(null),wc(null),Ec(null),Oc(null),Ac(null),Mc({}),Pc(null);let a=new _t,o=!1;t.stores.room.terrain(n,i).then(e=>{o||(Jl(`terrain loaded — ${n}`),_({room:n,data:e}))}).catch(e=>{o||Yl(`terrain load failed for ${n}:`,e)}),r(ks)&&t.http.game.roomDecorations(n,i).then(e=>{o||(Jl(`decorations loaded — ${n}: ${e.decorations.length} item(s)`),b({room:n,decoration:ka(e)}))}).catch(e=>{o||Jl(`no decorations for ${n}: ${e}`)}),a.add(t.stores.room.subscribe(n,i)),a.add(t.stores.room.on(`room:error`,e=>{V(`Room subscription error (${e.room}): ${e.message}`,`error`,8e3)})),a.add(t.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||Jl(`objects loaded — ${n}: ${t} objects, tick=${e.gameTime}`),C({objects:e.objects,diff:e.diff,users:e.users}),T(e.visual),_n(e.gameTime??null),jn(e.gameTime),Sc(t),wc(o),Ec(i||null),Oc(a),Ac(s),Mc(r),Pc(e.users??null)})),y(()=>{Jl(`leaving ${n}`),o=!0,a.dispose()})}),f(()=>{let t=W();if(!t||!Z())return;T(``);let n=e.room,i=e.shard,a=Nn()??!0,o=hn()?.serverData?.historyChunkSize??(a?20:100),s=r(Nc)??void 0,c=new hl(n,i,t.http,o);f(()=>{let e=Jc(),t=!1;al(!0),c.getStateAtTick(e).then(e=>{if(t)return;if(al(!1),e.clampedTo!==void 0){$c(e.clampedTo),dl(e.clampedTo);return}C({objects:e.objects,diff:void 0,users:s}),_n(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})}}Sc(n),wc(o),Ec(i||null),Oc(a),Ac(c),Mc(r)}).catch(n=>{t||(al(!1),V(`History load failed for tick ${e}: ${n.message}`,`error`,5e3))}),y(()=>{t=!0})})}),f(()=>{let t=p();if(!t)return;e.room,e.shard,Hl(),t.hoverLayer.clearPendingTile();let n=r(Nl);n?.type===`moveFlag`?Pl({...n,targetRoom:e.room}):t.resetView(),d?.destroy(),d=null,t.clear(),t.resetView(),i?.destroy(),i=null,c?.destroy(),c=null,l?.destroy(),l=null;let a=r(g);if(a&&a.room===e.room){Jl(`terrain applied immediately (pre-loaded) — ${e.room}`);let n=r(v);d=Sa(a.data,t.app.renderer,n?.room===e.room?n.decoration.terrain:void 0),Ca(d,r(Ds)),d.zIndex=wi.terrain,t.world.addChild(d),t.bringNavOverlayToTop()}let o=e.room,s=e.shard,u=Bc(o),f=r(()=>e.onNavigate),m=r(xn);if(u&&f){let e=(e,t)=>!m||zc(e,t,m),n=e=>{Jl(`navigate requested: ${o} → ${e}`),f(e,s)};t.setupNavigationZones({west:e(u.x-1,u.y)?()=>n(Vc(u.x-1,u.y)):void 0,east:e(u.x+1,u.y)?()=>n(Vc(u.x+1,u.y)):void 0,north:e(u.x,u.y-1)?()=>n(Vc(u.x,u.y-1)):void 0,south:e(u.x,u.y+1)?()=>n(Vc(u.x,u.y+1)):void 0})}}),f(()=>{let t=p();if(!t)return;let n=r(()=>e.room),i=r(()=>e.shard),a=Bc(n);if(a&&e.onNavigate){let r=e.onNavigate,o=xn(),s=(e,t)=>!o||zc(e,t,o),c=e=>{Jl(`navigate requested: ${n} → ${e}`),r(e,i)};Kc({currentRoom:()=>e.room,worldBounds:xn,onMove:(e,t)=>c(Vc(e,t))}),t.setupNavigationZones({west:s(a.x-1,a.y)?()=>c(Vc(a.x-1,a.y)):void 0,east:s(a.x+1,a.y)?()=>c(Vc(a.x+1,a.y)):void 0,north:s(a.x,a.y-1)?()=>c(Vc(a.x,a.y-1)):void 0,south:s(a.x,a.y+1)?()=>c(Vc(a.x,a.y+1)):void 0})}}),f(()=>{let e=Dl(),t=p();e===`view`&&t&&(Ll(),t.hoverLayer.clearPendingTile())}),f(()=>{let e=p(),t=jl();e&&(t?e.hoverLayer.setPendingTile(t.tx,t.ty):e.hoverLayer.clearPendingTile())}),f(()=>{let t=p(),n=g();if(!t||!n||n.room!==e.room)return;if(d?.parent){Jl(`terrain already in scene, skipping — ${e.room}`);return}Jl(`terrain applied (async) — ${e.room}`);let i=r(v);d=Sa(n.data,t.app.renderer,i?.room===e.room?i.decoration.terrain:void 0),Ca(d,r(Ds)),t.world.addChildAt(d,0),t.bringNavOverlayToTop()}),f(()=>{if(ks())return;b(null);let t=r(p),n=r(g);!t||!n||n.room!==e.room||d?.parent&&(d.destroy(),d=Sa(n.data,t.app.renderer),Ca(d,r(Ds)),t.world.addChildAt(d,0),t.bringNavOverlayToTop(),i?.setRoadColor(Wi))}),f(()=>{let t=p(),n=v(),a=r(g);!t||!n||n.room!==e.room||!a||a.room!==e.room||d?.parent&&(Jl(`decoration arrived, rebuilding terrain layer — ${e.room}`),d.destroy(),d=Sa(a.data,t.app.renderer,n.decoration.terrain),Ca(d,r(Ds)),t.world.addChildAt(d,0),t.bringNavOverlayToTop(),i&&n.decoration.roadColor!=null&&i.setRoadColor(n.decoration.roadColor))}),f(()=>{let n=p(),a=S();if(!n)return;if(!a){i?.clear(),c?.clear(),n.clearLighting();return}let{objects:o,diff:u,users:d}=a;if(!i){Jl(`object layer created — ${e.room}`),i=new cs(n.app.ticker,xs(),pn()?._id,pn()?.badge,d),i.setTheme(t(r(Fs)),Hs),i.setInstantMode(r(Z));let a=r(v);a?.room===e.room&&a.decoration.roadColor!=null&&i.setRoadColor(a.decoration.roadColor),i.container.label=`objects`,i.container.zIndex=wi.objects,n.world.addChild(i.container),c=new ds(n.app.ticker),c.container.label=`animations`,c.container.zIndex=wi.animations,n.world.addChild(c.container),l=new gs(n.app.renderer,n.world,n.app.ticker),l.container.zIndex=wi.visuals,n.world.addChild(l.container),n.setTileHandlers((e,t)=>{},(t,r,a)=>{let o=e.room,s=e.shard,c=Dl(),l=Nl();if(l?.type===`moveFlag`){let e=W();if(!e)return;let{name:n,room:i,color:a,secondaryColor:o,targetRoom:c}=l;e.http.game.removeFlag(i,n).then(()=>e.http.game.createFlag(c,t,r,n,a,o,s??void 0)).then(()=>{V(`Flag "${n}" moved`,`success`),Rl()}).catch(e=>{Yl(`move flag failed:`,e),V(`Failed to move flag "${n}"`,`error`),Rl()});return}if(c===`flag`){let e=jl();if(!e||e.tx!==t||e.ty!==r){Ml({tx:t,ty:r}),n.hoverLayer.setPendingTile(t,r);return}let i=W();if(!i)return;let a=kl(),c=a.name.trim();if(!c){V(`Flag name is required`,`error`);return}let l=Tl[a.color]??0,u=Tl[a.secondaryColor]??0;i.http.game.createFlag(o,t,r,c,l,u,s??void 0).then(()=>{V(`Flag "${c}" created`,`success`),Ll(),n.hoverLayer.clearPendingTile(),i.http.game.genUniqueFlagName().then(e=>Al(t=>({...t,name:e.name}))).catch(e=>Yl(`gen unique flag name failed:`,e))}).catch(e=>Yl(`create flag failed:`,e));return}if(c===`build`){if(!a&&!Fl().structureType){V(`Select a structure type first`,`error`);return}if(a){if(!i)return;let e=i.getObjectsAtTile(t,r).filter(({obj:e})=>e.type===`constructionSite`);if(e.length===0){V(`No construction sites on this tile`,`error`);return}let a=W();if(!a)return;a.http.game.removeConstructionSite(o,e.map(({id:e})=>e),s??void 0).then(()=>{V(`Removed ${e.length} construction site${e.length>1?`s`:``}`,`success`),Ll(),n.hoverLayer.clearPendingTile()}).catch(e=>{Yl(`remove construction sites failed:`,e),V(`Failed to remove construction sites: ${e.message}`,`error`)});return}Ml({tx:t,ty:r}),n.hoverLayer.setPendingTile(t,r),Bl(o,s);return}if(Ll(),n.hoverLayer.clearPendingTile(),!i)return;let u=i.getObjectsAtTile(t,r);if(u.length===0){a||(gc([]),n.hoverLayer.clearSelection());return}let d=[...hc()];if(a){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})=>mc(e,t));d=[...d,...e]}}else d=u.map(({id:e,obj:t})=>mc(e,t));gc(d);let f=d.map(({id:e,type:t})=>({id:e,type:t,visual:i.getVisualById(e)})).filter(e=>e.visual!=null);n.hoverLayer.setSelectedObjects(f)},()=>{let e=Dl();(e===`build`||e===`flag`||Nl()?.type===`moveFlag`)&&(Vl(),n.hoverLayer.clearPendingTile())})}u?yc(u,o):bc(o);let f=Z()?Math.round(1e3/r(nl)):vn()??2e3,m=f*.6,h=Math.round(f*.9);i.setMoveDuration(h),s={objects:o,users:d},i.update(o,u,d,G()??void 0),i.setShowLabels(r(xs));let g=new Set;if(c){c.clear();for(let e in o){let t=o[e];if(!t||t.type!==`creep`)continue;let n=t.actionLog;if(!n)continue;let r=n.harvest;r&&c.addHarvest(r.x,r.y,t.x,t.y,m);let a=n.upgradeController;a&&c.addUpgradeController(t.x,t.y,a.x,a.y,m);let s=n.build;s&&(c.addBuild(t.x,t.y,s.x,s.y,m),i?.triggerBuildAt(s.x,s.y,m));let l=n.transfer;l&&c.addTransfer(t.x,t.y,l.x,l.y,m);let u=n.say;u&&typeof u.message==`string`&&u.message.length>0&&(i?.triggerSay(e,u.message),g.add(e))}}i.pruneSayBubblesExcept(g),r(js)&&n.updateLighting(o)}),f(()=>{let e=w();l?.update(Ns()?e:``)}),f(()=>{i?.setInstantMode(Z())}),f(()=>{let e=Ds();d&&Ca(d,e)}),f(()=>{let e=p();if(!e)return;let t=js();e.darkOverlay.visible=t,e.lightLayer.visible=t,t||e.clearLighting()}),f(()=>{let e=t(Fs());i&&(i.setTheme(e,Hs),s&&(i.clear(),i.update(s.objects,void 0,s.users)))}),(()=>{var e=Gl(),t=e.firstChild;return Se(e=>n=e,t),z(e,(()=>{var e=N(()=>!!Ul());return()=>e()&&(()=>{var e=Kl();return z(e,Ul),o(t=>R(e,`pointer-events`,Tn()===`empty`||Tn()===`lost`?`auto`:`none`)),e})()})(),null),z(e,(()=>{var e=N(()=>!Z()&&G()!==null);return()=>e()&&(()=>{var e=ql();return e.firstChild,z(e,G,null),e})()})(),null),z(e,m(u,{get when(){return Z()},get children(){var e=Wl(),t=e.firstChild,n=t.nextSibling.firstChild,r=n.nextSibling,i=r.nextSibling;return t.$$input=e=>{let t=parseInt(e.currentTarget.value,10);ee(t),D!==null&&clearTimeout(D),D=setTimeout(()=>{D=null,dl(t)},150)},z(n,Xc),z(r,(()=>{var e=N(()=>!!il());return()=>e()?`Loading…`:`Tick ${Jc()}`})()),z(i,Qc),o(e=>{var n=Xc(),i=Qc(),a=il()?`#f0883e`:`#8b949e`;return n!==e.e&&I(t,`min`,e.e=n),i!==e.t&&I(t,`max`,e.t=i),a!==e.a&&R(r,`color`,e.a=a),e},{e:void 0,t:void 0,a:void 0}),o(()=>t.value=E()),e}}),null),e})()}F([`input`]);var Zl=P(`<div style=position:fixed;bottom:16px;right:16px;display:flex;flex-direction:column;gap:8px;z-index:9999;pointer-events:none>`),Ql=P(`<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 $l(){return(()=>{var e=Zl();return z(e,m(l,{get each(){return Rt()},children:e=>(()=>{var t=Ql();return z(t,()=>e.message),o(n=>R(t,`background`,e.type===`error`?`#da3633`:`#238636`)),t})()})),e})()}var[eu,tu]=x(!0),[nu,ru]=x(!0),[iu,au]=x(!1),[ou,su]=x(``),cu;function lu(e){cu=e}function uu(e){su(e),ru(!0),requestAnimationFrame(()=>{cu?.focus();let t=e.length;cu?.setSelectionRange(t,t)})}function du(){tu(e=>!e)}function fu(){ru(e=>!e)}function pu(){au(e=>!e)}var[mu,hu]=x(en(H.memoryWatches,[])),[gu,_u]=x(null),[vu,yu]=cc({});function bu(e){let t=e.trim();t&&(hu(e=>e.includes(t)?e:[...e,t]),tn(H.memoryWatches,mu()))}function xu(e){hu(t=>t.filter(t=>t!==e)),tn(H.memoryWatches,mu())}function Su(){_u(null)}function Cu(e,t){_u({creepId:e,name:t})}function wu(e,t){let n=[...t];if(e){let t=`creeps.${e.name}`;n.includes(t)||n.push(t)}return n}function Tu(e){let t=new Map,n=()=>{let n=W();if(!n)return;let r=new Set(wu(gu(),mu()));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))};f(()=>{mu(),gu(),n()});let r=W(),i=null;return r?i=r.stores.user.on(`user:memory`,e=>{console.log(`[memoryStore] user:memory received`,e.path,e.value),yu(e.path,e.value),console.log(`[memoryStore] memoryValues after set:`,JSON.stringify(vu))}):console.warn(`[memoryStore] no client available when initMemorySubscriptions called`),y(()=>{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()}}v(()=>{f(()=>{let e=gu();e&&(hc().some(t=>t.id===e.creepId)||Su())})});var Eu=P(`<button style=color:#8b949e>`),Du=P(`<span style=width:18px;flex-shrink:0>`),Ou=P(`<span style=color:#484f58;font-style:italic>{…}`),ku=P(`<span style=color:#484f58;font-style:italic>`),Au=P(`<button title=Reload>`),ju=P(`<span title="Click to edit"style=cursor:text;flex:1>`),Mu=P(`<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">`),Nu=P(`<button title=Save style=color:#3fb950>`),Pu=P(`<button title=Discard style=color:#f85149>`),Fu=P(`<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:Iu}=Jt(`MemoryTree`);function Lu(e){return typeof e==`object`&&!!e&&`__screeps_object__`in e}var Ru={"font-family":`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,"font-size":`12px`,"line-height":`1.5`},zu={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 Bu(e){return e.replace(/^Memory\.?/,``)}function Vu(e){let[t,n]=x((e.depth??0)<2),r=()=>e.depth??0,[i,s]=x(!1),[c,d]=x(``),[f,p]=x(!1),[h,g]=x(void 0),_=()=>Lu(e.value)&&h()!==void 0?h():e.value,v=()=>{let e=_();return!Lu(e)&&typeof e==`object`&&!!e},y=()=>v()?Object.entries(_()):[],b=()=>y().length,S=async()=>{p(!0);try{let t=W();if(!t)return;let n=Bu(e.path),r=await t.http.user.memory.get(n,e.shard);g(r.data===`[object Object]`?{__screeps_object__:!0}:r.data)}catch(e){Iu(`fetch memory failed`,e)}finally{p(!1)}},C=()=>{g(void 0),S()};a(()=>{t()&&Lu(e.value)&&h()===void 0&&S()});let w=async()=>{if(Lu(e.value)&&h()===void 0){await S(),n(!0);return}t()&&g(void 0),n(e=>!e)},T=async()=>{let t=c().trim(),n;if(t===`null`)n=null;else if(t===`true`)n=!0;else if(t===`false`)n=!1;else{let e=Number(t);if(!Number.isNaN(e)&&t!==``)n=e;else try{n=JSON.parse(t)}catch{n=t}}let r=W();if(!r)return;let i=Bu(e.path);try{await r.http.user.memory.set(i,n,e.shard)}catch(e){Iu(`set memory failed`,e),s(!1);return}s(!1),e.onRefresh?.()},E=()=>{let e=_();return v()?`#c9d1d9`:typeof e==`string`?`#3fb950`:typeof e==`number`?`#79c0ff`:typeof e==`boolean`?`#a371f7`:`#8b949e`},ee=()=>{let e=_();return e===null?`null`:e===void 0?`undefined`:typeof e==`string`?JSON.stringify(e):String(e)};return(()=>{var n=Fu(),a=n.firstChild,p=a.firstChild,h=p.nextSibling.nextSibling;return z(a,m(u,{get when(){return v()||Lu(_())},get children(){var e=Eu();return e.$$click=()=>void w(),z(e,m(u,{get when(){return f()},get children(){return m(mr,{size:12,style:{animation:`spin 1s linear infinite`}})}}),null),z(e,m(u,{get when(){return!f()},get children(){return m(u,{get when(){return t()},get fallback(){return m(Qn,{size:12})},get children(){return m(Xn,{size:12})}})}}),null),o(n=>{var r={...zu},i=t()?`Collapse`:`Expand`,a=f();return n.e=L(e,r,n.e),i!==n.t&&I(e,`title`,n.t=i),a!==n.a&&(e.disabled=n.a=a),n},{e:void 0,t:void 0,a:void 0}),e}}),p),z(a,m(u,{get when(){return N(()=>!v())()&&!Lu(_())},get children(){return Du()}}),p),z(p,()=>e.label),z(a,m(u,{get when(){return Lu(_())},get children(){return Ou()}}),h),z(a,m(u,{get when(){return v()},get children(){var e=ku();return z(e,(()=>{var e=N(()=>!!Array.isArray(_()));return()=>e()?`[${b()}]`:`{${b()}}`})()),e}}),h),z(a,m(u,{get when(){return N(()=>!!Lu(e.value))()&&!f()},get children(){var e=Au();return e.$$click=()=>C(),z(e,m(Ar,{size:11})),o(t=>L(e,zu,t)),e}}),h),z(a,m(u,{get when(){return N(()=>!v())()&&!Lu(_())},get children(){return[m(u,{get when(){return!i()},get children(){var e=ju();return e.$$click=()=>{d(ee()),s(!0)},z(e,ee),o(t=>R(e,`color`,E())),e}}),m(u,{get when(){return i()},get children(){return[(()=>{var e=Mu();return e.$$keydown=e=>{e.key===`Enter`&&T(),e.key===`Escape`&&s(!1)},e.$$input=e=>d(e.currentTarget.value),o(()=>e.value=c()),e})(),(()=>{var e=Nu();return e.$$mousedown=e=>{e.preventDefault(),T()},z(e,m(Jn,{size:12})),o(t=>L(e,{...zu},t)),e})(),(()=>{var e=Pu();return e.$$mousedown=e=>{e.preventDefault(),s(!1)},z(e,m(Rr,{size:12})),o(t=>L(e,{...zu},t)),e})()]}})]}}),h),h.$$click=()=>uu(`Memory.${Bu(e.path)} = `),z(h,m(Pr,{size:11})),z(n,m(u,{get when(){return N(()=>!!v())()&&t()},get children(){return m(l,{get each(){return y()},children:([t,n])=>m(Vu,{value:n,path:Array.isArray(_())?`${e.path}[${t}]`:`${e.path}.${t}`,label:t,get shard(){return e.shard},get depth(){return r()+1},get onRefresh(){return N(()=>!!Lu(e.value))()?C:e.onRefresh}})})}}),null),o(t=>{var i={"padding-left":r()>0?`14px`:`0`,...Ru},a=zu,o=`Insert Memory.${Bu(e.path)} = into console`;return t.e=L(n,i,t.e),t.t=L(h,a,t.t),o!==t.a&&I(h,`title`,t.a=o),t},{e:void 0,t:void 0,a:void 0}),n})()}function Hu(e){return m(Vu,{get value(){return e.value},get path(){return e.path},get label(){return e.label},get shard(){return e.shard},depth:0})}F([`click`,`input`,`keydown`,`mousedown`]);var Uu=P(`<div style=color:#484f58;font-style:italic>No paths watched — add one below.`),Wu=P(`<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`),Gu=P(`<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">`),Ku=P(`<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">`),qu=P(`<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>`),Ju=P(`<div style=width:4px;flex-shrink:0;cursor:col-resize>`),Yu=P(`<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`),Xu=P(`<div style=flex:1;display:flex;overflow:hidden>`),Zu=P(`<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>
|
|
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
|
+
`),Qu=P(`<div style=color:#484f58;font-style:italic>No log output yet…`),$u=P(`<div style=margin-bottom:4px;color:#f85149;white-space:pre-wrap;word-break:break-word>`),ed=P(`<div style=margin-bottom:4px;color:#c9d1d9;white-space:pre-wrap;word-break:break-word>`),td=P(`<div style=color:#484f58;font-style:italic>No command results yet…`),nd=P(`<div style=margin-bottom:4px;color:#58a6ff;white-space:pre-wrap;word-break:break-word>`),{error:rd}=Jt(`console`);function id(e){let[t,n]=x(``),r=()=>e.shard??Fc();a(()=>{Tu(r())});let i={"font-family":`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,"font-size":`12px`,"line-height":`1.5`},s={background:`transparent`,border:`none`,color:`#8b949e`,cursor:`pointer`,padding:`4px`,"border-radius":`4px`,display:`flex`,"align-items":`center`,"justify-content":`center`};return(()=>{var a=Wu(),c=a.firstChild,d=c.nextSibling,f=d.firstChild,p=f.nextSibling,h=p.firstChild;return z(c,m(u,{get when(){return gu()},children:e=>{let t=`creeps.${e().name}`;return(()=>{var e=Gu(),n=e.firstChild.firstChild,i=n.nextSibling.nextSibling;return z(n,t),ye(i,`click`,Su,!0),z(i,m(Rr,{size:12})),z(e,m(Hu,{get value(){return vu[t]},path:`Memory.${t}`,label:t,get shard(){return r()}}),null),o(e=>L(i,s,e)),e})()}}),null),z(c,m(l,{get each(){return mu()},children:e=>(()=>{var t=Ku(),n=t.firstChild.firstChild,i=n.nextSibling;return z(n,e),i.$$click=()=>xu(e),z(i,m(Rr,{size:12})),z(t,m(Hu,{get value(){return vu[e]},path:`Memory.${e}`,label:e,get shard(){return r()}}),null),o(e=>L(i,s,e)),t})()}),null),z(c,m(u,{get when(){return N(()=>mu().length===0)()&&!gu()},get children(){return Uu()}}),null),d.addEventListener(`submit`,e=>{e.preventDefault(),bu(t()),n(``)}),f.$$input=e=>n(e.currentTarget.value),z(p,m(Or,{size:14}),h),o(t=>{var n=`${e.width*100}%`,r={...i};return n!==t.e&&R(a,`width`,t.e=n),t.t=L(c,r,t.t),t},{e:void 0,t:void 0}),o(()=>f.value=t()),a})()}function ad(e){let[t,n]=x([]),[r,i]=x(!0),[s,c]=x(en(H.consoleWeights,[1,1,1])),[d,p]=x(null),h,g,_,v=0;a(()=>{let e=W();if(!e)return;let t=new _t;t.add(e.stores.user.subscribe(`console`)),t.add(e.stores.user.on(`user:console`,e=>{let t=e.messages,r={id:v++,log:t.log??[],results:t.results??[],error:t.error??[]};n(e=>{let t=[...e,r];return t.length>200?t.slice(t.length-200):t})})),y(()=>t.dispose())}),f(()=>{t(),r()&&requestAnimationFrame(()=>{eu()&&h&&(h.scrollTop=h.scrollHeight),nu()&&g&&(g.scrollTop=g.scrollHeight)})});let b=(t,n,r)=>{let i=!t&&!n&&!r;i&&!e.isCollapsed&&e.onToggle?.(),!i&&e.isCollapsed&&e.onToggle?.()};f(()=>{b(eu(),nu(),iu())});let S=()=>{let e=s(),t=[eu(),nu(),iu()],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)};f(()=>{tn(H.consoleWeights,s())});let C=e=>t=>{t.preventDefault(),t.stopPropagation(),p(e),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,w),window.addEventListener(`pointerup`,T,{once:!0})},w=e=>{let t=d();if(t===null)return;let n=_;if(!n)return;let r=n.getBoundingClientRect(),i=Math.max(.02,Math.min(.98,(e.clientX-r.left)/r.width)),a=[...s()],o=[eu(),nu(),iu()];if(t===0){let e=o[0],t=o[1];if(!e||!t)return;a[0]=i/(1-i),a[1]=1,c(a)}else{let e=o[1],t=o[2];if(!e||!t)return;a[1]=i/(1-i),a[2]=1,c(a)}},T=()=>{p(null),document.body.style.cursor=``,document.body.style.userSelect=``,window.removeEventListener(`pointermove`,w)},[E,ee]=x([]),[D,O]=x(null),[te,ne]=x(``),re=e=>{let t=E();if(t.length!==0){if(e.key===`ArrowUp`){e.preventDefault();let n=D();n===null?(ne(ou()),O(t.length-1),su(t[t.length-1])):n>0&&(O(n-1),su(t[n-1]))}else if(e.key===`ArrowDown`){e.preventDefault();let n=D();if(n===null)return;n<t.length-1?(O(n+1),su(t[n+1])):(O(null),su(te()))}}},k=async t=>{t.preventDefault();let n=W(),r=ou().trim();if(!(!n||!r))try{await n.http.user.console(r,e.shard??`shard0`),ee(e=>[...e,r]),O(null),ne(``),su(``)}catch(e){rd(`command failed:`,e)}},ie=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`}),ae=()=>t().flatMap(e=>e.log),A=()=>t().flatMap(e=>e.error),j=()=>t().flatMap(e=>e.results),oe={"font-family":`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,"font-size":`12px`,"line-height":`1.5`},M={background:`transparent`,border:`none`,color:`#8b949e`,cursor:`pointer`,padding:`4px`,"border-radius":`4px`,display:`flex`,"align-items":`center`,"justify-content":`center`},se=()=>{i(!0),requestAnimationFrame(()=>{eu()&&h&&(h.scrollTop=h.scrollHeight),nu()&&g&&(g.scrollTop=g.scrollHeight)})};return(()=>{var t=Zu(),a=t.firstChild,s=a.firstChild,c=s.nextSibling,f=c.nextSibling;return a.nextSibling,ye(s,`click`,du,!0),ye(c,`click`,fu,!0),ye(f,`click`,pu,!0),z(t,m(u,{get when(){return!e.isCollapsed},get children(){var t=Xu();return Se(e=>_=e,t),z(t,m(u,{get when(){return eu()},get children(){var e=qu(),t=e.firstChild,a=t.firstChild,s=a.nextSibling,c=t.nextSibling;a.$$click=()=>r()?i(!1):se(),z(a,(()=>{var e=N(()=>!!r());return()=>e()?m(wr,{size:16}):m(Er,{size:16})})()),s.$$click=()=>n([]),z(s,m(Ir,{size:16})),c.addEventListener(`scroll`,()=>{h&&i(h.scrollHeight-h.scrollTop-h.clientHeight<20)});var u=h;return typeof u==`function`?Se(u,c):h=c,z(c,(()=>{var e=N(()=>ae().length===0&&A().length===0);return()=>e()&&Qu()})(),null),z(c,m(l,{get each(){return A()},children:e=>(()=>{var t=$u();return t.innerHTML=e,t})()}),null),z(c,m(l,{get each(){return ae()},children:e=>(()=>{var t=ed();return t.innerHTML=e,t})()}),null),o(t=>{var n=`${S()[0]*100}%`,i=r()?`Pause scrolling`:`Resume scrolling`,o=M,l=M,u={...oe};return n!==t.e&&R(e,`width`,t.e=n),i!==t.t&&I(a,`title`,t.t=i),t.a=L(a,o,t.a),t.o=L(s,l,t.o),t.i=L(c,u,t.i),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}}),null),z(t,m(u,{get when(){return N(()=>!!eu())()&&nu()},get children(){var e=Ju();return ye(e,`pointerdown`,C(0),!0),o(t=>R(e,`background`,d()===0?`#388bfd`:`#21262d`)),e}}),null),z(t,m(u,{get when(){return nu()},get children(){var e=Yu(),t=e.firstChild,n=t.nextSibling,r=n.firstChild.nextSibling;r.nextSibling,t.addEventListener(`scroll`,()=>{g&&i(g.scrollHeight-g.scrollTop-g.clientHeight<20)});var a=g;return typeof a==`function`?Se(a,t):g=t,z(t,(()=>{var e=N(()=>j().length===0);return()=>e()&&td()})(),null),z(t,m(l,{get each(){return j()},children:e=>(()=>{var t=nd();return t.innerHTML=e,t})()}),null),n.addEventListener(`submit`,k),r.$$keydown=re,r.$$input=e=>{O(null),su(e.currentTarget.value)},Se(e=>lu(e),r),o(n=>{var r=`${S()[1]*100}%`,i={...oe};return r!==n.e&&R(e,`width`,n.e=r),n.t=L(t,i,n.t),n},{e:void 0,t:void 0}),o(()=>r.value=ou()),e}}),null),z(t,m(u,{get when(){return N(()=>!!nu())()&&iu()},get children(){var e=Ju();return ye(e,`pointerdown`,C(1),!0),o(t=>R(e,`background`,d()===1?`#388bfd`:`#21262d`)),e}}),null),z(t,m(u,{get when(){return iu()},get children(){return m(id,{get shard(){return e.shard??null},get width(){return S()[2]}})}}),null),o(e=>R(t,`user-select`,d()===null?`auto`:`none`)),t}}),null),o(e=>{var t=ie(eu()),n=ie(nu()),r=ie(iu());return e.e=L(s,t,e.e),e.t=L(c,n,e.t),e.a=L(f,r,e.a),e},{e:void 0,t:void 0,a:void 0}),t})()}F([`input`,`click`,`pointerdown`,`keydown`]);var od=P(`<div style=display:flex;gap:5px;flex-wrap:wrap>`),sd=P(`<div style=width:18px;height:18px;border-radius:50%;cursor:pointer;flex-shrink:0>`),cd=[{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 ld(e){return(()=>{var t=od();return z(t,m(l,{each:cd,children:t=>(()=>{var n=sd();return n.$$click=()=>e.onChange(t.value),o(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&&I(n,`title`,r.e=i),a!==r.t&&R(n,`background`,r.t=a),o!==r.a&&R(n,`box-shadow`,r.a=o),r},{e:void 0,t:void 0,a:void 0}),n})()})),t})()}F([`click`]);var ud=P(`<div>`),dd=P(`<div style=font-variant-numeric:tabular-nums>`),fd=P(`<span style=font-variant-numeric:tabular-nums;font-weight:400> / `),pd=P(`<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">`),md=P(`<div style="padding:3px 8px;background:#0d1117;color:#8b949e">`),hd=P(`<div style="padding:3px 8px;background:#0d1117;color:#c9d1d9;font-variant-numeric:tabular-nums">`),gd=P(`<div>Owner`),_d=P(`<div>Hits`),vd=P(`<div style=font-variant-numeric:tabular-nums> / `),yd=P(`<div>Time to live`),bd=P(`<div>Fatigue`),xd=P(`<div style="display:flex;flex-wrap:wrap;gap:2px 10px;padding:0 8px 8px;background:#0d1117">`),Sd=P(`<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>`),Cd=P(`<div><div>`),wd=P(`<div style=width:11px;height:11px;border-radius:50%;flex-shrink:0>`),Td=P(`<span style=font-size:10px;font-variant-numeric:tabular-nums><span style=color:#8b949e>×</span><span>`),Ed=P(`<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">`),Dd=P(`<div style=padding:8px;display:flex;flex-direction:column;gap:8px;background:#0d1117><label>Primary color</label><label>Secondary color`),Od=P(`<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`),kd=P(`<div>Reserved by`),Ad=P(`<div>Reservation`),jd=P(`<div style=font-variant-numeric:tabular-nums> ticks`),Md=P(`<div>Level`),Nd=P(`<div>Safe modes`),Pd=P(`<div>Power`),Fd=P(`<div>Downgrade in`),Id=P(`<div>Safe mode active`),Ld=P(`<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>`),Rd=P(`<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">`),zd=P(`<div><div><div>Owner</div><div>`),Bd=P(`<div>Notify when attacked`),Vd=P(`<div style=display:flex;align-items:center><button style=background:transparent;border:none;cursor:pointer;padding:0;display:flex;align-items:center>`),Hd=P(`<div><div>Energy</div><div style=font-variant-numeric:tabular-nums> / `),Ud=P(`<div><div>Hits</div><div style=font-variant-numeric:tabular-nums> / `),Wd=P(`<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>`),Gd=P(`<div>Decay in`),Kd=P(`<div>Energy cap`),qd=P(`<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>`),Jd=P(`<div style=width:8px;height:8px;border-radius:50%;flex-shrink:0>`),Yd=P(`<button style="background:transparent;border:none;cursor:pointer;padding:0 2px;display:flex;align-items:center;justify-content:center;flex-shrink:0">`),Xd=P(`<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">`),Zd=P(`<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">×`),Qd=P(`<span style=font-weight:400;color:#8b949e>`),$d=P(`<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">`),ef=P(`<div style=flex:1;overflow:auto;min-height:0;padding:8px>`),tf=P(`<div style=color:#484f58;font-style:italic;font-size:12px>Click a tile to select objects…`),{log:nf,error:rf}=Jt(`SelectionList`),af={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`,energy:`#d29922`},of={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`,energy:`Energy`,flag:`Flag`},sf=new Set([`x`,`y`,`type`,`id`,`name`,`user`,`_id`,`room`,`hitsMax`,`energyCapacity`,`body`,`storeCapacity`,`storeCapacityResource`,`invaderHarvested`,`ticksToRegeneration`]),cf=new Set([`hits`,`energy`,`energyCapacity`,`store`,`progress`,`progressTotal`,`nextDecayTime`,`ticksToRegeneration`,`nextRegenerationTime`]),lf={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 uf(e){return lf[e]?lf[e]:e.replace(/([A-Z])/g,` $1`).replace(/^./,e=>e.toUpperCase()).trim()}function df(e){return typeof e==`number`?String(e):typeof e==`string`?e:typeof e==`boolean`?e?`Yes`:`No`:null}function ff(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 Q=(e=!1)=>({padding:`3px 8px`,background:`#0d1117`,color:e?`#8b949e`:`#c9d1d9`,overflow:`hidden`,"text-overflow":`ellipsis`,"white-space":`nowrap`}),pf={display:`grid`,"grid-template-columns":`1fr 1fr`,gap:`1px`,background:`#21262d`,"font-size":`10px`};function mf(e){let t=()=>{let t=e.item.raw,n=[];for(let e in t){if(sf.has(e))continue;let r=t[e],i=df(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=G();e!==null&&(i=String(r-e))}if(e===`nextRegenerationTime`&&typeof r==`number`){let e=G();e!==null&&(i=String(r-e))}i!==null&&n.push({key:e,label:uf(e),value:i})}}return n.sort((e,t)=>!cf.has(e.key)-+!cf.has(t.key)),n};return m(u,{get when(){return t().length>0},get children(){var e=ud();return z(e,m(l,{get each(){return t()},children:e=>[(()=>{var t=ud();return z(t,()=>e.label),o(e=>L(t,Q(!0),e)),t})(),(()=>{var t=dd();return z(t,()=>e.value),o(e=>L(t,{...Q()},e)),t})()]})),o(t=>L(e,pf,t)),e}})}function hf(e){let t=()=>{let t=e.store||{},n=[];for(let e in t)n.push([e,t[e]]);return n},n=()=>{let t=e.store||{},n=0;for(let e in t)n+=t[e];return n};return m(u,{get when(){return t().length>0},get children(){var r=pd(),i=r.firstChild;i.firstChild;var a=i.nextSibling;return z(i,m(u,{get when(){return e.capacity!=null},get children(){var t=fd(),r=t.firstChild;return z(t,n,r),z(t,()=>e.capacity,null),t}}),null),z(a,m(l,{get each(){return t()},children:([e,t])=>[(()=>{var t=md();return z(t,e),t})(),(()=>{var e=hd();return z(e,t),e})()]})),r}})}var gf={tough:`#4c4c4c`,move:`#a9b7c6`,work:`#ffe56d`,carry:`#777777`,attack:`#f93842`,ranged_attack:`#5d80b2`,heal:`#65fd62`,claim:`#b99cfb`};function _f(e){let t=()=>e.item.raw,n=()=>typeof t().user==`string`?t().user:null,r=()=>{let e=n();return e?Nc()?.[e]?.username??e:null},i=()=>typeof t().hits==`number`?t().hits:null,a=()=>typeof t().hitsMax==`number`?t().hitsMax:null,s=()=>{let e=t().ageTime,n=G();return typeof e==`number`&&n!==null?Math.max(0,e-n):null},c=()=>typeof t().fatigue==`number`?t().fatigue:null,d=()=>t().store,f=()=>typeof t().storeCapacity==`number`?t().storeCapacity:null,p=()=>t().body??[],h=()=>{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=Cd(),t=e.firstChild;return z(t,m(u,{get when(){return r()},get children(){return[(()=>{var e=gd();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=ud();return z(e,r),o(t=>L(e,Q(),t)),e})()]}}),null),z(t,m(u,{get when(){return N(()=>i()!==null)()&&a()!==null},get children(){return[(()=>{var e=_d();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=vd(),t=e.firstChild;return z(e,i,t),z(e,a,null),o(t=>L(e,{...Q()},t)),e})()]}}),null),z(t,m(u,{get when(){return s()!==null},get children(){return[(()=>{var e=yd();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=dd();return z(e,s),o(t=>L(e,{...Q()},t)),e})()]}}),null),z(t,m(u,{get when(){return c()!==null},get children(){return[(()=>{var e=bd();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=dd();return z(e,c),o(t=>L(e,{...Q(),color:c()>0?`#e3b341`:void 0},t)),e})()]}}),null),z(e,m(hf,{get store(){return d()},get capacity(){return f()}}),null),z(e,m(u,{get when(){return p().length>0},get children(){var e=Sd(),t=e.firstChild,n=t.firstChild.nextSibling;n.nextSibling;var r=t.nextSibling;return z(t,()=>p().length,n),z(r,m(l,{get each(){return p()},children:e=>(()=>{var t=wd();return o(n=>{var r=e.type.replace(`_`,` `),i=gf[e.type]??`#484f58`,a=e.hits===0?.25:1;return r!==n.e&&I(t,`title`,n.e=r),i!==n.t&&R(t,`background`,n.t=i),a!==n.a&&R(t,`opacity`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),t})()})),z(e,m(u,{get when(){return Ls()},get children(){var e=xd();return z(e,m(l,{get each(){return h()},children:({type:e,count:t})=>(()=>{var n=Td(),r=n.firstChild,i=r.firstChild,a=r.nextSibling;return z(r,t,i),z(a,()=>e.replace(`_`,` `).toUpperCase()),o(t=>R(a,`color`,gf[e]??`#484f58`)),n})()})),e}}),null),e}}),null),o(e=>L(t,pf,e)),e})()}function vf(e){let t=()=>e.item.raw,n=()=>typeof t().name==`string`?t().name:``,r=()=>typeof t().room==`string`?t().room:``,i=()=>typeof t().color==`number`?t().color:1,a=()=>typeof t().secondaryColor==`number`?t().secondaryColor:1,[s,c]=x(i()),[l,d]=x(a());f(()=>{c(i()),d(a())});let p=()=>s()!==i()||l()!==a(),h=()=>{let e=W();if(!e)return;let t=s(),i=l();nf(`changeFlagColor: name="${n()}" room=${r()} primary=${t} secondary=${i}`),e.http.game.changeFlagColor(r(),n(),t,i).then(()=>nf(`changeFlagColor OK`)).catch(e=>rf(`changeFlagColor FAILED:`,e))},g=()=>{let t=Nl();return t?.type===`moveFlag`&&t.id===e.item.id},_=()=>{if(g()){Pl(null);return}Pl({type:`moveFlag`,id:e.item.id,name:n(),room:r(),color:s(),secondaryColor:l(),targetRoom:Lc()??r()})},v=()=>{let t=Nl();return t?.type===`moveFlag`&&t.id===e.item.id?t:null},y={display:`flex`,"flex-direction":`column`,gap:`5px`,"font-size":`11px`,color:`#8b949e`};return(()=>{var e=Dd(),t=e.firstChild;t.firstChild;var n=t.nextSibling;return n.firstChild,z(t,m(ld,{get value(){return s()},onChange:c}),null),z(n,m(ld,{get value(){return l()},onChange:d}),null),z(e,m(u,{get when(){return!Z()},get children(){return[(()=>{var e=Ed(),t=e.firstChild,n=t.nextSibling;return t.addEventListener(`mouseleave`,e=>{p()&&(e.currentTarget.style.background=`#238636`)}),t.addEventListener(`mouseenter`,e=>{p()&&(e.currentTarget.style.background=`#2ea043`)}),t.$$click=h,n.addEventListener(`mouseleave`,e=>{e.currentTarget.style.color=g()?`#c9d1d9`:`#8b949e`}),n.addEventListener(`mouseenter`,e=>{e.currentTarget.style.color=`#c9d1d9`}),n.$$click=_,z(n,(()=>{var e=N(()=>!!g());return()=>e()?m(Rr,{size:13}):m(Sr,{size:13})})()),o(e=>{var r=!p(),i=p()?`#238636`:`#161b22`,a=p()?`#fff`:`#484f58`,o=`1px solid ${p()?`#238636`:`#30363d`}`,s=p()?`pointer`:`not-allowed`,c=g()?`Abort move`:`Move flag`,l=g()?`#30363d`:`#21262d`,u=g()?`#c9d1d9`:`#8b949e`,d=`1px solid ${g()?`#8b949e`:`#30363d`}`;return r!==e.e&&(t.disabled=e.e=r),i!==e.t&&R(t,`background`,e.t=i),a!==e.a&&R(t,`color`,e.a=a),o!==e.o&&R(t,`border`,e.o=o),s!==e.i&&R(t,`cursor`,e.i=s),c!==e.n&&I(n,`title`,e.n=c),l!==e.s&&R(n,`background`,e.s=l),u!==e.h&&R(n,`color`,e.h=u),d!==e.r&&R(n,`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})(),m(u,{get when(){return v()},children:e=>(()=>{var t=Od(),n=t.firstChild.nextSibling;return n.nextSibling,n.$$input=t=>Pl({...e(),targetRoom:t.currentTarget.value.toUpperCase()}),o(e=>L(t,y,e)),o(()=>n.value=e().targetRoom),t})()})]}}),null),o(e=>{var r=y,i=y;return e.e=L(t,r,e.e),e.t=L(n,i,e.t),e},{e:void 0,t:void 0}),e})()}function yf(e){let t=()=>e.item.raw,n=()=>typeof t().level==`number`?t().level:0,r=()=>typeof t().progress==`number`?t().progress:null,i=()=>typeof t().progressTotal==`number`?t().progressTotal:Ma[n()]??null,a=()=>typeof t().downgradeTime==`number`?t().downgradeTime:null,s=()=>typeof t().safeModeAvailable==`number`?t().safeModeAvailable:0,c=()=>typeof t().safeMode==`number`?t().safeMode:null,l=()=>t().isPowerEnabled===!0,d=()=>t().reservation,f=()=>typeof t().user==`string`?t().user:null,p=()=>{let e=f();return e?Cc()?.username??e:null},h=()=>{let e=a(),t=G();return e!==null&&t!==null?Math.max(0,e-t):null},g=()=>{let e=h();if(e===null)return`—`;let t=Na[n()];return t!==void 0&&e>=t?`Max`:String(e)},_=()=>f()!==null&&f()===pn()?._id,[v,y]=x(!1),b=null,S=()=>{let n=W();n&&n.http.game.addObjectIntent(e.item.id,Lc()??t().room??``,`activateSafeMode`,{id:e.item.id},Fc()).catch(e=>rf(`activateSafeMode failed:`,e))},C=()=>{if(!v()){y(!0),b=setTimeout(()=>y(!1),3e3);return}b&&=(clearTimeout(b),null),y(!1);let n=W();n&&n.http.game.addObjectIntent(e.item.id,Lc()??t().room??``,`unclaim`,{id:e.item.id},Fc()).catch(e=>rf(`unclaim failed:`,e))};return(()=>{var e=zd(),t=e.firstChild,a=t.firstChild,f=a.nextSibling;return z(f,()=>p()??`None`),z(t,m(u,{get when(){return d()},get children(){return[(()=>{var e=kd();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=ud();return z(e,()=>Nc()?.[d().user]?.username??d().user),o(t=>L(e,Q(),t)),e})(),(()=>{var e=Ad();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=jd(),t=e.firstChild;return z(e,(()=>{var e=N(()=>G()!==null);return()=>e()?Math.max(0,d().endTime-G()):d().endTime})(),t),o(t=>L(e,{...Q()},t)),e})()]}}),null),z(t,m(u,{get when(){return n()>0},get children(){return[(()=>{var e=Md();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=ud();return z(e,n),o(t=>L(e,Q(),t)),e})(),(()=>{var e=Nd();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=ud();return z(e,s),o(t=>L(e,Q(),t)),e})(),(()=>{var e=Pd();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=ud();return z(e,()=>l()?`Enabled`:`Disabled`),o(t=>L(e,Q(),t)),e})(),(()=>{var e=Fd();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=dd();return z(e,g),o(t=>L(e,{...Q(),color:g()===`Max`?`#3fb950`:void 0},t)),e})()]}}),null),z(t,m(u,{get when(){return c()!==null},get children(){return[(()=>{var e=Id();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=jd(),t=e.firstChild;return z(e,c,t),o(t=>L(e,{...Q()},t)),e})()]}}),null),z(e,m(u,{get when(){return N(()=>n()>0&&n()<8&&r()!==null)()&&i()!==null},get children(){var e=Ld(),t=e.firstChild,a=t.firstChild,s=a.firstChild.nextSibling;s.nextSibling;var c=a.nextSibling,l=c.firstChild,u=l.nextSibling,d=u.nextSibling.nextSibling;d.nextSibling;var f=t.nextSibling.firstChild;return z(a,n,s),z(a,()=>n()+1,null),z(c,()=>ff(r()),l),z(c,()=>ff(i()),u),z(c,()=>(r()/i()*100).toFixed(1),d),o(e=>R(f,`width`,`${Math.min(100,r()/i()*100)}%`)),e}}),null),z(e,m(u,{get when(){return N(()=>!!_())()&&!Z()},get children(){var e=Rd(),t=e.firstChild,n=t.nextSibling;return t.addEventListener(`mouseleave`,e=>{s()>0&&(e.currentTarget.style.background=`#1f6feb`)}),t.addEventListener(`mouseenter`,e=>{s()>0&&(e.currentTarget.style.background=`#388bfd`)}),t.$$click=S,n.addEventListener(`mouseleave`,e=>{v()||(e.currentTarget.style.background=`#f85149`)}),n.addEventListener(`mouseenter`,e=>{v()||(e.currentTarget.style.background=`#da3633`)}),n.$$click=C,z(n,()=>v()?`Confirm unclaim`:`Unclaim`),o(e=>{var r=s()===0,i=s()>0?`#1f6feb`:`#161b22`,a=s()>0?`pointer`:`not-allowed`,o=s()>0?1:.5,c=v()?`#da3633`:`#f85149`;return r!==e.e&&(t.disabled=e.e=r),i!==e.t&&R(t,`background`,e.t=i),a!==e.a&&R(t,`cursor`,e.a=a),o!==e.o&&R(t,`opacity`,e.o=o),c!==e.i&&R(n,`background`,e.i=c),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}}),null),o(e=>{var n=pf,r=Q(!0),i=Q();return e.e=L(t,n,e.e),e.t=L(a,r,e.t),e.a=L(f,i,e.a),e},{e:void 0,t:void 0,a:void 0}),e})()}function bf(e){let t=()=>e.item.raw,n=()=>t().store?.energy??0,r=()=>t().storeCapacityResource?.energy??0,i=()=>typeof t().hits==`number`?t().hits:null,a=()=>typeof t().hitsMax==`number`?t().hitsMax:null,s=()=>t().notifyWhenAttacked===!0,c=()=>typeof t().user==`string`?t().user:null,l=()=>c()!==null&&c()===pn()?._id,d=()=>{let n=W();n&&n.http.game.addObjectIntent(e.item.id,t().room,`notifyWhenAttacked`,{enabled:!s()}).catch(e=>rf(`notifyWhenAttacked failed:`,e))};return(()=>{var e=Hd(),t=e.firstChild,c=t.nextSibling,f=c.firstChild;return z(c,n,f),z(c,r,null),z(e,m(u,{get when(){return N(()=>i()!==null)()&&a()!==null},get children(){return[(()=>{var e=_d();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=vd(),t=e.firstChild;return z(e,i,t),z(e,a,null),o(t=>L(e,{...Q()},t)),e})()]}}),null),z(e,m(u,{get when(){return N(()=>!!l())()&&!Z()},get children(){return[(()=>{var e=Bd();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=Vd(),t=e.firstChild;return t.addEventListener(`mouseleave`,e=>{e.currentTarget.style.color=s()?`#3fb950`:`#484f58`}),t.addEventListener(`mouseenter`,e=>{e.currentTarget.style.color=s()?`#56d364`:`#8b949e`}),t.$$click=d,z(t,(()=>{var e=N(()=>!!s());return()=>e()?m(Kn,{size:12}):m(Wn,{size:12})})()),o(n=>{var r={...Q()},i=s()?`Notifications on — click to disable`:`Notifications off — click to enable`,a=s()?`#3fb950`:`#484f58`;return n.e=L(e,r,n.e),i!==n.t&&I(t,`title`,n.t=i),a!==n.a&&R(t,`color`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),e})()]}}),null),o(n=>{var r=pf,i=Q(!0),a={...Q()};return n.e=L(e,r,n.e),n.t=L(t,i,n.t),n.a=L(c,a,n.a),n},{e:void 0,t:void 0,a:void 0}),e})()}function xf(e){let t=()=>e.item.raw,n=()=>typeof t().hits==`number`?t().hits:null,r=()=>typeof t().hitsMax==`number`?t().hitsMax:null,i=()=>t().store,a=()=>{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},s=()=>{let e=i();if(!e)return 0;let t=0;for(let n in e)t+=e[n];return t},c=()=>{let e=a();return!e||e===0?0:Math.min(100,s()/e*100)};return(()=>{var e=ud();return z(e,m(u,{get when(){return N(()=>n()!==null)()&&r()!==null},get children(){var e=Ud(),t=e.firstChild,i=t.nextSibling,a=i.firstChild;return z(i,n,a),z(i,r,null),o(n=>{var r=pf,a=Q(!0),o={...Q()};return n.e=L(e,r,n.e),n.t=L(t,a,n.t),n.a=L(i,o,n.a),n},{e:void 0,t:void 0,a:void 0}),e}}),null),z(e,m(u,{get when(){return a()!==null},get children(){var e=Wd(),t=e.firstChild,n=t.firstChild.nextSibling,r=n.firstChild,i=r.nextSibling,l=i.nextSibling.nextSibling;l.nextSibling;var u=t.nextSibling.firstChild;return z(n,()=>ff(s()),r),z(n,()=>ff(a()),i),z(n,()=>c().toFixed(1),l),o(e=>R(u,`width`,`${c()}%`)),e}}),null),z(e,m(hf,{get store(){return i()},capacity:null}),null),e})()}function Sf(e){let t=()=>e.item.raw,n=()=>{let e=t().decayTime;if(typeof e!=`number`)return null;let n=G();return n===null?e:Math.max(0,e-n)},r=()=>typeof t().user==`string`?t().user:null,i=()=>{let e=r();return e?Nc()?.[e]?.username??e:null},a=()=>t().structure,s=()=>typeof a()?.type==`string`?a().type:null,c=()=>typeof a()?.hits==`number`?a().hits:null,l=()=>typeof a()?.hitsMax==`number`?a().hitsMax:null,d=()=>typeof a()?.level==`number`?a().level:null,f=()=>typeof a()?.energy==`number`?a().energy:null,p=()=>typeof a()?.energyCapacity==`number`?a().energyCapacity:null,h=()=>t().store,g=()=>typeof t().storeCapacity==`number`?t().storeCapacity:null;return(()=>{var e=Cd(),t=e.firstChild;return z(t,m(u,{get when(){return n()!==null},get children(){return[(()=>{var e=Gd();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=dd();return z(e,n),o(t=>L(e,{...Q()},t)),e})()]}}),null),z(t,m(u,{get when(){return i()},get children(){return[(()=>{var e=gd();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=ud();return z(e,i),o(t=>L(e,Q(),t)),e})()]}}),null),z(e,m(u,{get when(){return s()},get children(){var e=qd(),t=e.firstChild;t.firstChild;var n=t.nextSibling;return z(t,s,null),z(n,m(u,{get when(){return l()!==null},get children(){return[(()=>{var e=_d();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=vd(),t=e.firstChild;return z(e,()=>c()??0,t),z(e,l,null),o(t=>L(e,{...Q()},t)),e})()]}}),null),z(n,m(u,{get when(){return d()!==null},get children(){return[(()=>{var e=Md();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=dd();return z(e,d),o(t=>L(e,{...Q()},t)),e})()]}}),null),z(n,m(u,{get when(){return p()!==null},get children(){return[(()=>{var e=Kd();return o(t=>L(e,Q(!0),t)),e})(),(()=>{var e=vd(),t=e.firstChild;return z(e,()=>f()??0,t),z(e,p,null),o(t=>L(e,{...Q()},t)),e})()]}}),null),o(e=>L(n,pf,e)),e}}),null),z(e,m(hf,{get store(){return h()},get capacity(){return g()}}),null),o(e=>L(t,pf,e)),e})()}var Cf={creep:_f,flag:vf,controller:yf,extension:bf,tower:bf,storage:xf,terminal:xf,container:xf,lab:xf,factory:xf,nuker:xf,powerSpawn:xf,ruin:Sf};function wf(e){let t=()=>af[e.item.type]??`#c9d1d9`,n=()=>of[e.item.type]??e.item.type,r=()=>e.item.type===`creep`,i=()=>e.item.type===`flag`,a=()=>{if(!r())return!1;let t=e.item.raw,n=typeof t.user==`string`?t.user:null;return n!==null&&n===pn()?._id},s=()=>{if(r()||i()||e.item.type===`controller`)return!1;let t=e.item.raw,n=typeof t.user==`string`?t.user:null;return n===null?Cc()?.userId===pn()?._id:n===pn()?._id},c=()=>Cf[e.item.type]||mf,[l,d]=x(!1),f=null,[p,h]=x(!1),g=null,[_,v]=x(!1),y=null,b=t=>{if(t.stopPropagation(),!_()){v(!0),y=setTimeout(()=>v(!1),3e3);return}y&&=(clearTimeout(y),null),v(!1);let n=W();if(!n)return;let r=e.item.id,i=e.item.raw;n.http.game.removeFlag(i.room,i.name).then(()=>vc(r)).catch(()=>{})},S=t=>{if(t.stopPropagation(),!p()){h(!0),g=setTimeout(()=>h(!1),3e3);return}g&&=(clearTimeout(g),null),h(!1);let n=W();if(!n)return;let r=e.item.id,i=e.item.raw,a=(typeof i.room==`string`?i.room:null)??Lc()??``;if(e.item.type===`constructionSite`)n.http.game.removeConstructionSite(a,[r],Fc()??void 0).then(()=>vc(r)).catch(e=>rf(`removeConstructionSite failed:`,e));else{let e=typeof i.user==`string`?i.user:Cc()?.userId??``;n.http.game.addObjectIntent(`room`,a,`destroyStructure`,[{id:r,roomName:a,user:e}],Fc()).then(()=>vc(r)).catch(e=>rf(`destroyStructure failed:`,e))}},C=t=>{if(t.stopPropagation(),!l()){d(!0),f=setTimeout(()=>d(!1),3e3);return}f&&=(clearTimeout(f),null),d(!1);let n=W();if(!n)return;let r=e.item.id;n.http.game.addObjectIntent(r,Lc()??e.item.raw.room??``,`suicide`,{id:r},Fc()).then(()=>vc(r)).catch(e=>rf(`suicide failed:`,e))};return(()=>{var d=Zd(),f=d.firstChild,h=f.firstChild,g=h.nextSibling,v=g.firstChild.nextSibling,y=v.nextSibling.nextSibling;y.nextSibling;var x=g.nextSibling;return z(f,m(u,{get when(){return N(()=>!r())()&&!i()},get children(){var e=Jd();return o(n=>R(e,`background`,t())),e}}),h),z(h,m(u,{get when(){return i()},get fallback(){return N(n)},get children(){return m(cr,{size:12})}}),null),z(h,m(u,{get when(){return N(()=>typeof e.item.raw.name==`string`)()&&e.item.raw.name},children:e=>(()=>{var t=Qd();return z(t,()=>e()),t})()}),null),z(g,()=>e.item.raw.x,v),z(g,()=>e.item.raw.y,y),z(f,m(u,{get when(){return N(()=>!!a())()&&!Z()},get children(){return[(()=>{var e=Yd();return e.addEventListener(`mouseleave`,e=>{l()||(e.currentTarget.style.color=`#8b949e`)}),e.addEventListener(`mouseenter`,e=>{l()||(e.currentTarget.style.color=`#f85149`)}),e.$$click=C,z(e,m(Ir,{size:13})),o(t=>{var n=l()?`Click again to confirm suicide`:`Suicide`,r=l()?`#f85149`:`#8b949e`;return n!==t.e&&I(e,`title`,t.e=n),r!==t.t&&R(e,`color`,t.t=r),t},{e:void 0,t:void 0}),e})(),(()=>{var t=Xd();return t.addEventListener(`mouseleave`,e=>e.currentTarget.style.color=`#8b949e`),t.addEventListener(`mouseenter`,e=>e.currentTarget.style.color=`#58a6ff`),t.$$click=()=>{Cu(e.item.id,e.item.raw.name),au(!0)},z(t,m(or,{size:13})),t})()]}}),x),z(f,m(u,{get when(){return N(()=>!!s())()&&!Z()},get children(){var t=Yd();return t.addEventListener(`mouseleave`,e=>{p()||(e.currentTarget.style.color=`#8b949e`)}),t.addEventListener(`mouseenter`,e=>{p()||(e.currentTarget.style.color=`#f85149`)}),t.$$click=S,z(t,m(Ir,{size:13})),o(n=>{var r=p()?`Click again to confirm`:e.item.type===`constructionSite`?`Remove construction site`:`Destroy structure`,i=p()?`#f85149`:`#8b949e`;return r!==n.e&&I(t,`title`,n.e=r),i!==n.t&&R(t,`color`,n.t=i),n},{e:void 0,t:void 0}),t}}),x),z(f,m(u,{get when(){return N(()=>!!i())()&&!Z()},get children(){var e=Yd();return e.addEventListener(`mouseleave`,e=>{_()||(e.currentTarget.style.color=`#8b949e`)}),e.addEventListener(`mouseenter`,e=>{_()||(e.currentTarget.style.color=`#f85149`)}),e.$$click=b,z(e,m(Ir,{size:13})),o(t=>{var n=_()?`Click again to confirm deletion`:`Delete flag`,r=_()?`#f85149`:`#8b949e`;return n!==t.e&&I(e,`title`,t.e=n),r!==t.t&&R(e,`color`,t.t=r),t},{e:void 0,t:void 0}),e}}),x),x.addEventListener(`mouseleave`,e=>e.currentTarget.style.color=`#8b949e`),x.addEventListener(`mouseenter`,e=>e.currentTarget.style.color=`#fff`),x.$$click=()=>vc(e.item.id),z(d,m(Re,{get component(){return c()},get item(){return e.item}}),null),z(d,m(u,{get when(){return e.item.id},children:e=>(()=>{var t=$d();return t.$$click=()=>navigator.clipboard?.writeText(e()),z(t,e),o(()=>I(t,`title`,e())),t})()}),null),o(e=>R(d,`border`,`1px solid ${a()&&l()||p()||_()?`#f85149`:`#30363d`}`)),d})()}function Tf(){return(()=>{var e=ef();return z(e,m(u,{get when(){return hc().length>0},get fallback(){return tf()},get children(){return m(l,{get each(){return hc()},children:e=>m(wf,{item:e})})}})),e})()}F([`click`,`input`]);var Ef=P(`<div style="padding:3px 0;color:#8b949e">Reserved by`),Df=P(`<div style="padding:3px 0;color:#c9d1d9">`),Of=P(`<div style="padding:3px 0;color:#8b949e">Expires in`),kf=P(`<div style="padding:3px 0;color:#c9d1d9;font-variant-numeric:tabular-nums"> ticks`),Af=P(`<div style="padding:3px 0;color:#8b949e">RCL`),jf=P(`<span style=color:#8b949e>(<!>%)`),Mf=P(`<div style="padding:3px 0;color:#c9d1d9;font-variant-numeric:tabular-nums">`),Nf=P(`<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></label></div><div style=display:grid;gap:4px;margin-top:8px><button type=button title=History style="padding:5px 8px;border-radius:6px;display:flex;align-items:center;justify-content:center">`),Pf=P(`<span>`),Ff=P(`<button type=button style="padding:5px 8px;border-radius:6px;cursor:pointer;display:flex;align-items:center;justify-content:center">`),If=[{mode:`view`,label:`View`,icon:()=>m(or,{size:14})},{mode:`flag`,label:`Flag`,icon:()=>m(cr,{size:14})},{mode:`build`,label:`Build`,icon:()=>m(ur,{size:14})}];function Lf(e){return(()=>{var t=Nf(),n=t.firstChild,r=n.firstChild.nextSibling,i=r.nextSibling,a=i.firstChild.nextSibling,s=a.nextSibling.nextSibling,c=s.nextSibling.nextSibling,d=c.nextSibling.nextSibling,f=d.nextSibling.nextSibling,p=i.nextSibling,h=p.firstChild.nextSibling,g=p.nextSibling.firstChild.nextSibling,_=n.nextSibling,v=_.firstChild;return z(r,()=>e.room),z(a,()=>e.shard??`—`),z(s,()=>G()??`—`),z(c,(()=>{var e=N(()=>!!vn());return()=>e()?`${vn()}ms`:`—`})()),z(d,()=>xc()??`—`),z(f,()=>Cc()?.username??`—`),z(i,m(u,{get when(){return N(()=>!Cc())()&&kc()},get children(){return[Ef(),(()=>{var e=Df();return z(e,()=>Nc()?.[kc().user]?.username??kc().user),e})(),Of(),(()=>{var e=kf(),t=e.firstChild;return z(e,(()=>{var e=N(()=>G()!==null);return()=>e()?Math.max(0,kc().endTime-G()):`—`})(),t),e})()]}}),null),z(i,m(u,{get when(){return N(()=>Tc()!==null)()&&Tc()>0},get children(){return[Af(),(()=>{var e=Mf();return z(e,m(u,{get when(){return N(()=>Tc()<8)()&&Dc()!==null},get fallback(){return(()=>{var e=Pf();return z(e,Tc),e})()},get children(){return[N(()=>Tc()),` → `,N(()=>Tc()+1),`\xA0`,(()=>{var e=jf(),t=e.firstChild.nextSibling;return t.nextSibling,z(e,()=>(Dc()/(Ma[Tc()]??1)*100).toFixed(1),t),e})()]}})),e})()]}}),null),h.addEventListener(`change`,e=>Ss(e.currentTarget.checked)),g.addEventListener(`change`,e=>Ps(e.currentTarget.checked)),z(_,m(u,{get when(){return!K()},get children(){return m(l,{each:If,children:e=>{let t=()=>!Z()&&Dl()===e.mode;return(()=>{var n=Ff();return n.$$click=()=>{Z()&&ul(),Ol(e.mode)},z(n,()=>e.icon()),o(r=>{var i=e.label,a=`1px solid ${t()?`#58a6ff`:`#30363d`}`,o=t()?`#1f6feb33`:`#161b22`,s=t()?`#c9d1d9`:`#8b949e`;return i!==r.e&&I(n,`title`,r.e=i),a!==r.t&&R(n,`border`,r.t=a),o!==r.a&&R(n,`background`,r.a=o),s!==r.o&&R(n,`color`,r.o=s),r},{e:void 0,t:void 0,a:void 0,o:void 0}),n})()}})}}),v),v.$$click=()=>Z()?ul():G()!==null&&ll(G()),z(v,m(nr,{size:14})),o(e=>{var t=`repeat(${K()?2:4}, 1fr)`,n=!Z()&&G()===null,r=K()?`span 2`:void 0,i=`1px solid ${Z()?`#58a6ff`:`#30363d`}`,a=Z()?`#1f6feb33`:`#161b22`,o=Z()?`#c9d1d9`:`#8b949e`,s=!Z()&&G()===null?`not-allowed`:`pointer`,c=!Z()&&G()===null?.4:1;return t!==e.e&&R(_,`grid-template-columns`,e.e=t),n!==e.t&&(v.disabled=e.t=n),r!==e.a&&R(v,`grid-column`,e.a=r),i!==e.o&&R(v,`border`,e.o=i),a!==e.i&&R(v,`background`,e.i=a),o!==e.n&&R(v,`color`,e.n=o),s!==e.s&&R(v,`cursor`,e.s=s),c!==e.h&&R(v,`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}),o(()=>h.checked=xs()),o(()=>g.checked=Ns()),t})()}F([`click`]);var[Rf,zf]=x(`owner`),$=3,Bf=$*50,Vf=4;function Hf(e,t,n){let r=Bc(e);return r?[r.x*Bf+t*$,r.y*Bf+n*$]:null}var Uf=3*$,Wf=2.5*$,Gf=1*$,Kf=2*$;function qf(e,t,n,r){let i=!0,a=n;for(let o=0;o<t.length-1;o++){let[s,c]=t[o],[l,u]=t[o+1],d=l-s,f=u-c,p=Math.sqrt(d*d+f*f);if(p<.001)continue;let m=d/p,h=f/p,g=0;for(;g<p;){let t=Math.min(a,p-g);if(i){let n=s+m*g,r=c+h*g;e.moveTo(n,r),e.lineTo(n+m*t,r+h*t)}g+=t,a-=t,a<.001&&(i=!i,a=i?n:r)}}}function Jf(e,t,n){let r=Math.max(32,Math.ceil(2*Math.PI*n/2)),i=[];for(let a=0;a<=r;a++){let o=a/r*2*Math.PI;i.push([e+Math.cos(o)*n,t+Math.sin(o)*n])}return i}var Yf=class{container;g;constructor(){this.container=new j,this.container.label=`mapVisuals`,this.g=new D,this.container.addChild(this.g)}update(e){let t=this.container.removeChildren();for(let e of t)e!==this.g&&e.destroy();if(this.g.clear(),this.container.addChild(this.g),!e)return;let n=this.g;for(let t of e.split(`
|
|
19
|
+
`)){if(!t.trim())continue;let e;try{e=JSON.parse(t)}catch{continue}let r=e.s??{},i=r.opacity??.5;switch(e.t){case`l`:this.drawLine(n,e,r,i);break;case`c`:this.drawCircle(n,e,r,i);break;case`r`:this.drawRect(n,e,r,i);break;case`p`:this.drawPoly(n,e,r,i);break;case`t`:this.drawText(e,r,i);break}}}clear(){let e=this.container.removeChildren();for(let t of e)t!==this.g&&t.destroy();this.g.clear(),this.container.addChild(this.g)}drawLine(e,t,n,r){let i=Hf(t.n1,t.x1,t.y1),a=Hf(t.n2,t.x2,t.y2);if(!i||!a)return;let o=n.color??`#ffffff`,s=(n.width??.5)*$;n.lineStyle===`dashed`?qf(e,[i,a],Uf*(n.width??.5),Wf*(n.width??.5)):n.lineStyle===`dotted`?qf(e,[i,a],Gf*(n.width??.5),Kf*(n.width??.5)):(e.moveTo(i[0],i[1]),e.lineTo(a[0],a[1])),e.stroke({color:o,width:s,alpha:r})}drawCircle(e,t,n,r){let i=Hf(t.n,t.x,t.y);if(!i)return;let[a,o]=i,s=(n.radius??10)*$,c=!!(n.fill&&n.fill!==`transparent`),l=!!(n.stroke&&n.strokeWidth),u=(n.strokeWidth??.5)*$;c&&(e.circle(a,o,s),e.fill({color:n.fill,alpha:r})),l&&(n.lineStyle===`dashed`?qf(e,Jf(a,o,s),Uf*(n.strokeWidth??.5),Wf*(n.strokeWidth??.5)):n.lineStyle===`dotted`?qf(e,Jf(a,o,s),Gf*(n.strokeWidth??.5),Kf*(n.strokeWidth??.5)):e.circle(a,o,s),e.stroke({color:n.stroke,width:u,alpha:r}))}drawRect(e,t,n,r){let i=Hf(t.n,t.x,t.y),a=Hf(t.n,t.x+t.w,t.y),o=Hf(t.n,t.x+t.w,t.y+t.h),s=Hf(t.n,t.x,t.y+t.h);if(!i||!a||!o||!s)return;let c=!!(n.fill&&n.fill!==`transparent`),l=!!(n.stroke&&n.strokeWidth),u=[i,a,o,s,i],d=u.flatMap(e=>e),f=(n.strokeWidth??.5)*$;c&&(e.poly(d.slice(0,8),!0),e.fill({color:n.fill,alpha:r})),l&&(n.lineStyle===`dashed`?qf(e,u,Uf*(n.strokeWidth??.5),Wf*(n.strokeWidth??.5)):n.lineStyle===`dotted`?qf(e,u,Gf*(n.strokeWidth??.5),Kf*(n.strokeWidth??.5)):e.poly(d.slice(0,8),!0),e.stroke({color:n.stroke,width:f,alpha:r}))}drawPoly(e,t,n,r){if(!t.points||t.points.length===0)return;let i=!!(n.fill&&n.fill!==`transparent`),a=!!(n.stroke&&n.strokeWidth);if(!i&&!a)return;let o=[];for(let{n:e,x:n,y:r}of t.points){let t=Hf(e,n,r);if(!t)return;o.push(t)}let s=o.flatMap(e=>e),c=(n.strokeWidth??.5)*$;if(i&&(e.poly(s,!0),e.fill({color:n.fill,alpha:r})),a){if(n.lineStyle===`dashed`){let t=o[0],r=o[o.length-1];qf(e,t[0]===r[0]&&t[1]===r[1]?o:[...o,t],Uf*(n.strokeWidth??.5),Wf*(n.strokeWidth??.5))}else if(n.lineStyle===`dotted`){let t=o[0],r=o[o.length-1];qf(e,t[0]===r[0]&&t[1]===r[1]?o:[...o,t],Gf*(n.strokeWidth??.5),Kf*(n.strokeWidth??.5))}else e.poly(s,!0);e.stroke({color:n.stroke,width:c,alpha:r})}}drawText(e,t,n){let r=Hf(e.n,e.x,e.y);if(!r)return;let[i,a]=r,o=t.fontSize??10,s=t.fontFamily??`sans-serif`,c=o*$,l=t.align??`center`,u=new ne({fill:t.color??`#ffffff`,fontSize:c*Vf,fontFamily:s,align:l,...t.fontStyle?{fontStyle:t.fontStyle}:{},...t.fontVariant?{fontVariant:t.fontVariant}:{},...t.stroke&&t.strokeWidth?{stroke:{color:t.stroke,width:t.strokeWidth*$*Vf}}:{}});if(t.backgroundColor&&t.backgroundColor!==`transparent`){let r=(t.backgroundPadding??2)*$,o=new A({text:e.text,style:u});o.scale.set(1/Vf);let s=o.width,c=o.height;o.destroy();let d=i-(l===`center`?.5:+(l===`right`))*s-r,f=a-c/2-r,p=new D;p.rect(d,f,s+r*2,c+r*2),p.fill({color:t.backgroundColor,alpha:n}),this.container.addChild(p)}let d=new A({text:e.text,style:u});d.scale.set(1/Vf),d.anchor.x=l===`center`?.5:+(l===`right`),d.anchor.y=.5,d.position.set(i,a),d.alpha=n,this.container.addChild(d)}destroy(){let e=this.container.removeChildren();for(let t of e)t!==this.g&&t.destroy();this.g.destroy(),this.container.destroy()}},{warn:Xf}=Jt(`terrainCache`),Zf=`screeps-terrain-v1`;async function Qf(e,t,n){try{let r=await caches.open(Zf),i=`/terrain/${e}_${t}_z${n}.webp`,a=new Request(i),o=await r.match(a);if(o)return await o.blob()}catch(e){Xf(`get failed:`,e)}return null}async function $f(e,t,n,r){try{let i=await caches.open(Zf),a=`/terrain/${e}_${t}_z${n}.webp`,o=new Request(a),s=new Response(r);await i.put(o,s)}catch(e){Xf(`save failed:`,e)}}async function ep(e){let t=new OffscreenCanvas(e.width,e.height),n=t.getContext(`2d`);if(!n)throw Error(`OffscreenCanvas 2D context not available`);return n.drawImage(e,0,0),await t.convertToBlob({type:`image/webp`})}var tp=null;async function np(e){if(tp!==!1)try{let t=await createImageBitmap(e);return tp=!0,t}catch(e){if(tp===!0)throw e;tp=!1}let t=URL.createObjectURL(e);try{let e=new Image;return e.src=t,await e.decode(),await createImageBitmap(e)}finally{URL.revokeObjectURL(t)}}function rp(e){return new Worker(`/_client/terrain.worker-BgNTQAMk.js`,{name:e?.name})}var{warn:ip}=Jt(`MapRenderer`),ap=[50,60,70,80,90,100,105,120],op=1,sp=.5,cp=50,lp=2600,up=5,dp=.2,fp=5,pp=Ji,mp=16777215,hp=Fi,gp=Hi,_p=Ii,vp=Gi,yp=4486980,bp=8921634,xp=new Set([`w`,`r`,`pb`,`p`,`s`,`c`,`m`,`k`]),Sp={H:13421772,O:13421772,U:5809919,L:4176208,K:10711543,Z:13801762,X:16273737},Cp=[16,24,32,40],wp=class{app;world;boundsGraphics=null;selectionGraphics=null;safeModeGraphics=null;mapVisualLayer=null;safeModeRooms=new Set;activeRooms=new Map;roomPool=[];terrainBaked=new Set;terrainData=new Map;worker;pendingBakes=new Map;nextBakeId=0;currentShard=`shard0`;callbacks;resizeObserver=null;_destroyed=!1;showRoomNames=!1;worldBoundsSet=null;lastVisibleBounds=null;animTargetX=0;animTargetY=0;isAnimating=!1;overlayMode=`owner`;showUnclaimableOverlay=!0;isDragging=!1;hasDragged=!1;dragStartX=0;dragStartY=0;dragWorldX=0;dragWorldY=0;isPinching=!1;pinchPivotWorldX=0;pinchPivotWorldY=0;pinchStartDist=0;pinchStartScale=0;lastVisibleKey=``;visibleDebounceTimer=null;selectedRoom=null;currentUserId=null;badgeCache=new ja;constructor(e){this.app=new T,this.callbacks=e,this.worker=new rp,this.worker.onmessage=e=>{let{id:t,bitmap:n}=e.data,r=this.pendingBakes.get(t);r&&(this.pendingBakes.delete(t),r.resolve(n))}}async init(e){let t=e.parentElement??e,{width:n,height:r}=t.getBoundingClientRect();await this.app.init({canvas:e,width:n,height:r,background:Ai,antialias:!1,preference:`webgl`}),this.resizeObserver=new ResizeObserver(e=>{let{width:t,height:n}=e[0].contentRect,r=this.app.screen.width,i=this.app.screen.height;this.app.renderer.resize(t,n),this.world.x+=(t-r)/2,this.world.y+=(n-i)/2}),this.resizeObserver.observe(t),this.world=new j,this.app.stage.addChild(this.world),this.boundsGraphics=new D,this.world.addChild(this.boundsGraphics),this.selectionGraphics=new D,this.world.addChild(this.selectionGraphics),this.safeModeGraphics=new D,this.world.addChild(this.safeModeGraphics),this.mapVisualLayer=new Yf,this.world.addChild(this.mapVisualLayer.container),this.setupInteraction(),this.app.ticker.add(()=>{if(this.isAnimating){let e=this.animTargetX-this.world.x,t=this.animTargetY-this.world.y;Math.abs(e)<.5&&Math.abs(t)<.5?(this.world.x=this.animTargetX,this.world.y=this.animTargetY,this.isAnimating=!1):(this.world.x+=e*.2,this.world.y+=t*.2)}this.checkVisibleRooms()})}get zoom(){return this.world?.scale.x??1}setZoom(e){if(!this.world||(e=Math.max(dp,Math.min(fp,e)),e===this.world.scale.x))return;let t=this.app.screen.width/2,n=this.app.screen.height/2;this.applyZoomAt(e,t,n)}applyZoomAt(e,t,n){let r=this.world.scale.x,i=this.getLOD(),a=this.zoom>=op,o=this.zoom>=sp,s=(t-this.world.x)/r,c=(n-this.world.y)/r;this.world.scale.set(e),this.world.x=t-s*e,this.world.y=n-c*e,this.getLOD()!==i&&this.applyLOD(),(e>=op!==a||e>=.5!==o)&&this.updateAllNameLabels(),this.updateAllRoomScales(e),this.callbacks.onZoomChanged?.(e),this.setSelectedRoom(this.selectedRoom),this.redrawSafeMode()}centerOn(e,t,n=!1){let r=e*150+150/2,i=t*150+150/2,a=this.world.scale.x,o=this.app.screen.width/2-r*a,s=this.app.screen.height/2-i*a;n?(this.animTargetX=o,this.animTargetY=s,this.isAnimating=!0):(this.isAnimating=!1,this.world.x=o,this.world.y=s)}async getTerrainBitmap(e,t,n){let r=this.currentShard;try{let i=await Qf(r,e,t);if(i)return await np(i);let a=this.nextBakeId++,o=new Promise((n,r)=>{this.pendingBakes.set(a,{roomName:e,lod:t,resolve:n,reject:r})});this.worker.postMessage({id:a,roomName:e,lod:t,raw:n});let s=await o;return ep(s).then(n=>{$f(r,e,t,n)}).catch(e=>ip(`failed to save to terrainCache:`,e)),s}catch(e){return ip(`error getting terrain bitmap:`,e),null}}async setRoomTerrain(e,t){let n=t.raw,r=!1;for(let e=0;e<n.length;e++)if(n[e]!==0){r=!0;break}if(!r){this.terrainBaked.add(e);return}let i=this.getOrCreate(e),a=this.getLOD();a===0&&this.terrainData.set(e,n);let o=await this.getTerrainBitmap(e,a,n);if(!o)return;if(!this.activeRooms.has(e)){o.close();return}let s=E.from(o);a===0?(i.texLo&&!i.texLo.destroyed&&(i.terrainSprite.texture===i.texLo&&(i.terrainSprite.texture=E.EMPTY),i.texLo.destroy(!0)),i.texLo=s,this.getLOD()===0&&(i.terrainSprite.texture=s)):(i.texHi&&!i.texHi.destroyed&&(i.terrainSprite.texture===i.texHi&&(i.terrainSprite.texture=E.EMPTY),i.texHi.destroy(!0)),i.texHi=s,this.getLOD()===1&&(i.terrainSprite.texture=s)),i.terrainSprite.width=150,i.terrainSprite.height=150,this.terrainBaked.add(e)}getLOD(){return this.zoom<op?0:1}async applyLOD(){let e=this.getLOD()===1,t=[];for(let[n,r]of this.activeRooms)if(this.terrainBaked.has(n))if(e&&!r.texHi){let e=this.terrainData.get(n);e&&(this.terrainData.delete(n),t.push(this.getTerrainBitmap(n,1,e).then(e=>{e&&this.activeRooms.has(n)?(r.texHi=E.from(e),this.getLOD()===1&&(r.terrainSprite.texture=r.texHi)):e&&e.close()})))}else{let t=e?r.texHi:r.texLo;t&&!t.destroyed&&(r.terrainSprite.texture=t)}await Promise.all(t)}setRoomMap2(e,t,n=`live`){let r=this.getOrCreate(e);r.lastMap2Data=t,r.lastMap2Source=n,this.drawMap2(r,t,n)}drawMap2(e,t,n){let r=e.map2Graphics;r.alpha=n===`cache`?.6:1,r.clear();let i=t.r??[];for(let[e,t]of i)r.rect(e*3,t*3,3,3);i.length&&r.fill(ji);let a=t.w??[];for(let[e,t]of a)r.rect(e*3+.5,t*3+.5,2,2);a.length&&r.fill(e.ownerState===`other`?bp:yp);let o=t.s??[];for(let[e,t]of o)r.circle((e+.5)*3,(t+.5)*3,2.5);o.length&&r.fill(pp);let s=t.c??[];for(let[e,t]of s)r.circle((e+.5)*3,(t+.5)*3,2);s.length&&r.fill(mp);let c=t.m??[];for(let[e,t]of c)r.circle((e+.5)*3,(t+.5)*3,2);c.length&&r.fill(hp);let l=t.k??[];for(let[e,t]of l)r.circle((e+.5)*3,(t+.5)*3,2);l.length&&r.fill(gp);let u=t.pb??[];for(let[e,t]of u)r.circle((e+.5)*3,(t+.5)*3,1.5);u.length&&r.fill(Hi);let d=t;for(let e in d){if(xp.has(e))continue;let t=d[e];if(!Array.isArray(t)||t.length===0)continue;for(let[e,n]of t)r.circle((e+.5)*3,(n+.5)*3,1);let n=e===this.currentUserId?_p:vp;r.fill(n)}}clearRoomMap2(e){this.activeRooms.get(e)?.map2Graphics.clear()}clearAllMap2(){for(let e of this.activeRooms.values())e.map2Graphics.clear()}setRoomOwned(e,t){let n=this.activeRooms.get(e);if(!n)return;n.ownerState!==t&&(n.ownerState=t,n.lastMap2Data&&this.drawMap2(n,n.lastMap2Data,n.lastMap2Source??`live`));let r=n.ownerOverlay;r.clear(),t===`other`?(r.rect(0,0,150,150),r.fill({color:10027008,alpha:.18})):t===`own`&&(r.rect(0,0,150,150),r.fill({color:102,alpha:.35})),r.visible=this.showUnclaimableOverlay}setUnclaimableOverlayVisible(e){if(this.showUnclaimableOverlay!==e){this.showUnclaimableOverlay=e;for(let t of this.activeRooms.values())t.ownerOverlay.visible=e}}async setRoomBadge(e,t,n){let r=this.activeRooms.get(e);if(r){if(!t){r.badgeSprite&&=(r.container.removeChild(r.badgeSprite),r.badgeSprite.destroy(),void 0),r.badgeLevel=void 0;return}try{let i=await this.badgeCache.getOrCreate(t);if(!this.activeRooms.has(e))return;if(r.badgeSprite){if(r.badgeSprite.texture===i){r.badgeLevel=n,this.applyBadgeSize(r,this.zoom),this.applyOverlayMode(r);return}r.badgeSprite.texture=i}else{let e=new O(i);e.anchor.set(.5),e.x=150/2,e.y=150/2;let t=r.container.getChildIndex(r.nameLabel);r.container.addChildAt(e,t),r.badgeSprite=e}r.badgeLevel=n,this.applyBadgeSize(r,this.zoom),this.applyOverlayMode(r)}catch(t){ip(`failed to load badge for`,e,t)}}}applyBadgeSize(e,t){if(!e.badgeSprite||e.badgeLevel===void 0)return;let n=(ap[e.badgeLevel-1]??24)*Math.min(1,t);e.badgeSprite.width=n/t,e.badgeSprite.height=n/t}setOverlayMode(e){if(this.overlayMode!==e){this.overlayMode=e;for(let e of this.activeRooms.values())this.applyOverlayMode(e)}}setRoomMineral(e,t,n){let r=this.activeRooms.get(e);if(!r)return;if(!t||!n){r.mineralCircle&&=(r.container.removeChild(r.mineralCircle),r.mineralCircle.destroy(),void 0),r.mineralLabel&&=(r.container.removeChild(r.mineralLabel),r.mineralLabel.destroy(),void 0),r.mineralDensity=void 0;return}let i=Sp[t]??7979263;if(r.mineralDensity=n,r.mineralColor=i,!r.mineralCircle){let e=new D;e.x=150/2,e.y=150/2;let t=r.container.getChildIndex(r.nameLabel);r.container.addChildAt(e,t),r.mineralCircle=e}if(r.mineralLabel)r.mineralLabel.text=t;else{let e=new A({text:t,style:{fontSize:36,fill:16777215,fontFamily:`ui-monospace, monospace`,fontWeight:`bold`}});e.anchor.set(.5),e.x=150/2,e.y=150/2,r.container.addChild(e),r.mineralLabel=e}this.applyMineralSize(r,this.zoom),this.applyOverlayMode(r)}applyOverlayMode(e){e.badgeSprite&&(e.badgeSprite.visible=this.overlayMode===`owner`),e.mineralCircle&&(e.mineralCircle.visible=this.overlayMode===`mineral`),e.mineralLabel&&(e.mineralLabel.visible=this.overlayMode===`mineral`)}applyMineralSize(e,t){if(!e.mineralCircle||!e.mineralLabel||e.mineralDensity===void 0||e.mineralColor===void 0)return;let n=Math.max(.5,Math.min(1.5,t)),r=(Cp[e.mineralDensity-1]??24)*n,i=r/2/t;e.mineralCircle.clear(),e.mineralCircle.circle(0,0,1),e.mineralCircle.fill(e.mineralColor);let a=2/t;e.mineralCircle.stroke({color:0,width:a/i}),e.mineralCircle.scale.set(i);let o=r*.55/36/t;e.mineralLabel.scale.set(o)}updateNameLabelScale(e,t){let n=.3/Math.sqrt(t),r=12/(36*t);e.nameLabel.scale.set(Math.max(n,r))}updateAllRoomScales(e){for(let t of this.activeRooms.values())this.applyBadgeSize(t,e),this.updateNameLabelScale(t,e),this.applyMineralSize(t,e)}setCurrentUser(e){this.currentUserId=e}setMapVisual(e){this.mapVisualLayer?.update(e),this.mapVisualLayer&&(this.world.removeChild(this.mapVisualLayer.container),this.world.addChild(this.mapVisualLayer.container))}clearMapVisual(){this.mapVisualLayer?.clear()}setMapVisualVisible(e){this.mapVisualLayer&&(this.mapVisualLayer.container.visible=e)}setSelectedRoom(e){if(this.selectedRoom=e,!this.selectionGraphics||(this.selectionGraphics.clear(),this.world.removeChild(this.selectionGraphics),this.world.addChild(this.selectionGraphics),!e))return;let t=Bc(e);if(!t)return;let n=t.x*150,r=t.y*150;this.selectionGraphics.rect(n,r,150,150);let i=Math.max(2,Math.ceil(2/this.zoom));this.selectionGraphics.stroke({color:16777215,width:i,alignment:0})}setRoomSafeMode(e,t){t?this.safeModeRooms.add(e):this.safeModeRooms.delete(e),this.redrawSafeMode()}redrawSafeMode(){if(!this.safeModeGraphics||(this.safeModeGraphics.clear(),this.safeModeRooms.size===0))return;let e=Math.max(1,Math.ceil(1/this.zoom));for(let t of this.safeModeRooms){let n=Bc(t);if(!n)continue;let r=n.x*150,i=n.y*150;this.safeModeGraphics.rect(r,i,150,150),this.safeModeGraphics.stroke({color:16776960,width:e,alignment:1,alpha:.5})}this.world.removeChild(this.safeModeGraphics),this.world.addChild(this.safeModeGraphics)}setBounds(e,t,n,r){if(!this.boundsGraphics)return;this.worldBoundsSet={minX:e,maxX:t,minY:n,maxY:r},this.boundsGraphics.clear();let i=e*150,a=n*150,o=(t-e+1)*150,s=(r-n+1)*150;this.boundsGraphics.rect(i,a,o,s),this.boundsGraphics.stroke({color:Mi,width:6,alignment:0}),this.updateAllNameLabels()}clearBounds(){this.worldBoundsSet=null,this.boundsGraphics?.clear(),this.updateAllNameLabels()}setShowRoomNames(e){this.showRoomNames=e,this.updateAllNameLabels()}hasRoom(e){return this.terrainBaked.has(e)}markRoomFetched(e){this.terrainBaked.add(e)}clearRoom(e){let t=this.activeRooms.get(e);t&&(t.texLo&&!t.texLo.destroyed&&t.texLo.destroy(!0),t.texHi&&!t.texHi.destroyed&&t.texHi.destroy(!0),t.texLo=null,t.texHi=null,t.terrainSprite.texture=E.EMPTY,t.map2Graphics.clear(),t.ownerOverlay.clear(),t.badgeSprite&&=(t.container.removeChild(t.badgeSprite),t.badgeSprite.destroy(),void 0),t.mineralCircle&&=(t.container.removeChild(t.mineralCircle),t.mineralCircle.destroy(),void 0),t.mineralLabel&&=(t.container.removeChild(t.mineralLabel),t.mineralLabel.destroy(),void 0),t.mineralDensity=void 0,t.mineralColor=void 0,t.container.visible=!1,this.safeModeRooms.delete(e),this.terrainBaked.delete(e),this.terrainData.delete(e),this.activeRooms.delete(e),this.roomPool.length<lp?this.roomPool.push(t):(this.world.removeChild(t.container),t.container.destroy({children:!0,context:!0})))}clearInvisibleRooms(e){let t=this.lastVisibleBounds;for(let n of[...this.activeRooms.keys()])if(!e.has(n)){if(t){let e=Bc(n);if(e&&e.x>=t.rxMin-cp&&e.x<=t.rxMax+cp&&e.y>=t.ryMin-cp&&e.y<=t.ryMax+cp)continue}this.clearRoom(n)}}destroy(){if(!this._destroyed){this._destroyed=!0,this.resizeObserver?.disconnect(),this.resizeObserver=null,this.visibleDebounceTimer!==null&&(clearTimeout(this.visibleDebounceTimer),this.visibleDebounceTimer=null);for(let[,e]of this.activeRooms)e.texLo&&!e.texLo.destroyed&&e.texLo.destroy(!0),e.texHi&&!e.texHi.destroyed&&e.texHi.destroy(!0);this.activeRooms.clear(),this.safeModeRooms.clear();for(let e of this.roomPool)e.texLo&&!e.texLo.destroyed&&e.texLo.destroy(!0),e.texHi&&!e.texHi.destroyed&&e.texHi.destroy(!0);this.roomPool.length=0,this.terrainBaked.clear(),this.terrainData.clear(),this.worker.terminate(),this.pendingBakes.clear(),this.badgeCache.destroy(),this.mapVisualLayer?.destroy(),this.mapVisualLayer=null;try{this.app.destroy(!1,{children:!0,context:!0})}catch(e){ip(`destroy error (ignored):`,e)}}}getOrCreate(e){let t=this.activeRooms.get(e);if(t)return t;let n=Bc(e);if(!n)throw Error(`MapRenderer: invalid room "${e}"`);let r;if(this.roomPool.length>0)r=this.roomPool.pop();else{let e=new j;e.cullable=!0;let t=new O(E.EMPTY),n=new D,i=new D;e.addChild(t),e.addChild(n),e.addChild(i);let a=new A({text:``,style:{fontSize:36,fill:9147550,fontFamily:`ui-monospace, monospace`}});a.scale.set(.25),a.x=2,a.y=2,e.addChild(a),this.world.addChild(e),r={container:e,terrainSprite:t,texLo:null,texHi:null,map2Graphics:n,ownerOverlay:i,ownerState:`none`,nameLabel:a}}return r.container.x=n.x*150,r.container.y=n.y*150,r.container.visible=!0,r.nameLabel.text=e,r.nameLabel.visible=this.showRoomNames&&this.zoom>=.5&&this.nameLabelShouldShow(n.x,n.y),this.updateNameLabelScale(r,this.zoom),r.badgeSprite&&(r.container.removeChild(r.badgeSprite),r.badgeSprite.destroy(),r.badgeSprite=void 0),r.mineralCircle&&(r.container.removeChild(r.mineralCircle),r.mineralCircle.destroy(),r.mineralCircle=void 0),r.mineralLabel&&(r.container.removeChild(r.mineralLabel),r.mineralLabel.destroy(),r.mineralLabel=void 0),r.mineralDensity=void 0,r.mineralColor=void 0,this.safeModeGraphics&&(this.world.removeChild(this.safeModeGraphics),this.world.addChild(this.safeModeGraphics)),this.selectionGraphics&&(this.world.removeChild(this.selectionGraphics),this.world.addChild(this.selectionGraphics)),this.activeRooms.set(e,r),r}nameLabelShouldShow(e,t){let n=this.worldBoundsSet;return!(n&&(e<n.minX||e>n.maxX||t<n.minY||t>n.maxY))}updateAllNameLabels(){let e=this.showRoomNames&&this.zoom>=.5;for(let[t,n]of this.activeRooms){if(!e){n.nameLabel.visible=!1;continue}let r=Bc(t);r&&(n.nameLabel.visible=this.nameLabelShouldShow(r.x,r.y))}}setupInteraction(){let e=this.app.canvas;e.style.touchAction=`none`,e.style.userSelect=`none`;let t=new Map;e.addEventListener(`pointermove`,n=>{if(!t.has(n.pointerId)){if(!this.isDragging&&!this.isPinching){let t=e.getBoundingClientRect();this.emitHover(n.clientX-t.left,n.clientY-t.top)}return}if(t.set(n.pointerId,{x:n.clientX,y:n.clientY}),this.isPinching&&t.size===2){let n=[...t.values()],r=e.getBoundingClientRect(),i=(n[0].x+n[1].x)/2-r.left,a=(n[0].y+n[1].y)/2-r.top,o=Math.hypot(n[1].x-n[0].x,n[1].y-n[0].y),s=Math.max(dp,Math.min(fp,this.pinchStartScale*(o/this.pinchStartDist))),c=this.getLOD(),l=this.zoom>=op,u=this.zoom>=sp;this.world.scale.set(s),this.world.x=i-this.pinchPivotWorldX*s,this.world.y=a-this.pinchPivotWorldY*s,this.getLOD()!==c&&this.applyLOD(),(s>=op!==l||s>=.5!==u)&&this.updateAllNameLabels(),this.updateAllRoomScales(s),this.callbacks.onZoomChanged?.(s),this.setSelectedRoom(this.selectedRoom),this.redrawSafeMode();return}if(this.isDragging){let e=n.clientX-this.dragStartX,t=n.clientY-this.dragStartY;(Math.abs(e)>3||Math.abs(t)>3)&&(this.hasDragged=!0);let r=this.worldBoundsSet;if(r){let n=this.world.scale.x,i=50-(r.maxX+1)*150*n,a=this.app.screen.width-50-r.minX*150*n,o=50-(r.maxY+1)*150*n,s=this.app.screen.height-50-r.minY*150*n;this.world.x=this.rubberBand(this.dragWorldX+e,i,a),this.world.y=this.rubberBand(this.dragWorldY+t,o,s)}else this.world.x=this.dragWorldX+e,this.world.y=this.dragWorldY+t}}),e.addEventListener(`pointerleave`,()=>{!this.isDragging&&!this.isPinching&&this.callbacks.onRoomHover(null)}),e.addEventListener(`pointerdown`,n=>{if(n.preventDefault(),this.isAnimating=!1,t.set(n.pointerId,{x:n.clientX,y:n.clientY}),e.setPointerCapture(n.pointerId),t.size>=2){this.isDragging=!1,this.isPinching=!0;let n=[...t.values()],r=e.getBoundingClientRect(),i=(n[0].x+n[1].x)/2-r.left,a=(n[0].y+n[1].y)/2-r.top;this.pinchStartDist=Math.hypot(n[1].x-n[0].x,n[1].y-n[0].y),this.pinchStartScale=this.world.scale.x,this.pinchPivotWorldX=(i-this.world.x)/this.pinchStartScale,this.pinchPivotWorldY=(a-this.world.y)/this.pinchStartScale}else this.isPinching=!1,this.isDragging=!0,this.hasDragged=!1,this.dragStartX=n.clientX,this.dragStartY=n.clientY,this.dragWorldX=this.world.x,this.dragWorldY=this.world.y}),e.addEventListener(`pointerup`,n=>{if(t.delete(n.pointerId),e.releasePointerCapture(n.pointerId),this.isPinching){t.size<2&&(this.isPinching=!1,this.isDragging=!1,this.springBack());return}if(this.isDragging){if(this.isDragging=!1,!this.hasDragged){let t=e.getBoundingClientRect(),r=this.screenToRoom(n.clientX-t.left,n.clientY-t.top);r&&this.callbacks.onRoomClick(r)}this.springBack()}}),e.addEventListener(`pointercancel`,n=>{t.delete(n.pointerId),e.releasePointerCapture(n.pointerId),(this.isPinching||this.isDragging)&&(this.isPinching=!1,this.isDragging=!1,this.springBack())}),e.addEventListener(`wheel`,e=>{if(e.preventDefault(),this.isDragging||this.isPinching)return;this.isAnimating=!1;let t=this.world.scale.x,n=e.deltaY<0?1.1:.9,r=Math.max(dp,Math.min(fp,t*n));this.applyZoomAt(r,e.offsetX,e.offsetY)},{passive:!1})}rubberBand(e,t,n){let r=n-t;if(r<=0||e>=t&&e<=n)return e;let i=.55;return e<t?t-(1-1/((t-e)*i/r+1))*r*i:n+(1-1/((e-n)*i/r+1))*r*i}springBack(){let e=this.worldBoundsSet;if(!e)return;let t=this.world.scale.x,n=this.app.screen.width,r=this.app.screen.height,i=this.world.x+e.minX*150*t,a=this.world.x+(e.maxX+1)*150*t,o=this.world.y+e.minY*150*t,s=this.world.y+(e.maxY+1)*150*t,c=this.world.x,l=this.world.y;a<50?c+=50-a:i>n-50&&(c-=i-(n-50)),s<50?l+=50-s:o>r-50&&(l-=o-(r-50)),(c!==this.world.x||l!==this.world.y)&&(this.animTargetX=c,this.animTargetY=l,this.isAnimating=!0)}screenToRoom(e,t){let n=this.world.scale.x,r=(e-this.world.x)/n,i=(t-this.world.y)/n;return Vc(Math.floor(r/150),Math.floor(i/150))}emitHover(e,t){this.callbacks.onRoomHover(this.screenToRoom(e,t))}lastCheckX=0;lastCheckY=0;lastCheckScale=0;checkVisibleRooms(){let e=this.world.scale.x,t=this.world.x,n=this.world.y;if(this.lastCheckX===t&&this.lastCheckY===n&&this.lastCheckScale===e)return;this.lastCheckX=t,this.lastCheckY=n,this.lastCheckScale=e;let r=-t/e,i=-n/e,a=(this.app.screen.width-t)/e,o=(this.app.screen.height-n)/e,s=Math.floor(r/150)-1,c=Math.ceil(a/150),l=Math.floor(i/150)-1,u=Math.ceil(o/150);this.lastVisibleBounds={rxMin:s,rxMax:c,ryMin:l,ryMax:u};let d=[],f=this.worldBoundsSet,p=f?Math.max(s,f.minX):s,m=f?Math.min(c,f.maxX):c,h=f?Math.max(l,f.minY):l,g=f?Math.min(u,f.maxY):u;for(let e=p;e<=m;e++)for(let t=h;t<=g;t++){let n=Vc(e,t);n&&d.push(n)}let _=`${s},${l},${c},${u}`;_!==this.lastVisibleKey&&(this.lastVisibleKey=_,this.visibleDebounceTimer!==null&&clearTimeout(this.visibleDebounceTimer),this.visibleDebounceTimer=setTimeout(()=>{this.visibleDebounceTimer=null,this.callbacks.onVisibleRoomsChanged(d)},up))}},Tp=P(`<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></div><div style="display:grid;grid-template-columns:repeat(3, 1fr);gap:4px;margin-top:8px">`),Ep=P(`<button type=button style="padding:5px 8px;border-radius:6px;cursor:pointer;font-size:11px;font-weight:600">`),Dp=[{mode:`owner`,label:`Owner`},{mode:`mineral`,label:`Mineral`},{mode:`none`,label:`None`}];function Op(e){let t=()=>(e.zoom??1)>=sp;return(()=>{var n=Tp(),r=n.firstChild,i=r.firstChild.nextSibling,a=i.firstChild.nextSibling,s=a.nextSibling.nextSibling,c=i.nextSibling,u=c.firstChild.nextSibling,d=c.nextSibling,f=d.firstChild.nextSibling,p=d.nextSibling.firstChild.nextSibling,h=r.nextSibling;return z(a,()=>e.zoom?.toFixed(2)??`—`),z(s,()=>e.subsActive?`Yes`:`No`),u.addEventListener(`change`,e=>ws(e.currentTarget.checked)),f.addEventListener(`change`,e=>Es(e.currentTarget.checked)),p.addEventListener(`change`,e=>Bs(e.currentTarget.checked)),z(h,m(l,{each:Dp,children:e=>{let t=()=>Rf()===e.mode;return(()=>{var n=Ep();return n.$$click=()=>zf(e.mode),z(n,()=>e.label),o(e=>{var r=`1px solid ${t()?`#58a6ff`:`#30363d`}`,i=t()?`#1f6feb33`:`#161b22`,a=t()?`#c9d1d9`:`#8b949e`;return r!==e.e&&R(n,`border`,e.e=r),i!==e.t&&R(n,`background`,e.t=i),a!==e.a&&R(n,`color`,e.a=a),e},{e:void 0,t:void 0,a:void 0}),n})()}})),o(e=>{var n=t()?`#c9d1d9`:`#484f58`,r=t()?`pointer`:`default`,i=!t();return n!==e.e&&R(c,`color`,e.e=n),r!==e.t&&R(c,`cursor`,e.t=r),i!==e.a&&(u.disabled=e.a=i),e},{e:void 0,t:void 0,a:void 0}),o(()=>u.checked=Cs()),o(()=>f.checked=Ts()),o(()=>p.checked=zs()),n})()}F([`click`]);var kp=P(`<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">`),Ap=P(`<div style="padding:6px 8px;font-size:11px;color:#484f58;font-style:italic">None`),jp=P(`<div style="padding:3px 8px;color:#8b949e">Mineral`),Mp=P(`<div style="padding:3px 8px;color:#79c0ff">`),Np=P(`<div style="padding:3px 8px;color:#8b949e">Density`),Pp=P(`<div style="padding:3px 8px;color:#c9d1d9">`),Fp=P(`<div style=font-size:11px><div style="padding:5px 8px;font-weight:600;color:#c9d1d9;font-size:12px;border-bottom:1px solid #21262d"></div><div style="display:grid;grid-template-columns:auto 1fr;row-gap:1px;column-gap:0"><div style="padding:3px 8px;color:#8b949e">Owner</div><div style="padding:3px 8px;color:#c9d1d9">`),Ip=[`Low`,`Medium`,`High`,`Ultra`];function Lp(e){return Ip[e-1]??String(e)}function Rp(e){return(()=>{var t=kp(),n=t.firstChild;return z(n,()=>e.label),z(t,m(u,{get when(){return e.info},get fallback(){return Ap()},children:e=>(()=>{var t=Fp(),n=t.firstChild,r=n.nextSibling,i=r.firstChild.nextSibling;return z(n,()=>e().room),z(i,()=>e().owner??`None`),z(r,m(u,{get when(){return e().mineral},get children(){return[jp(),(()=>{var t=Mp();return z(t,()=>e().mineral),t})(),Np(),(()=>{var t=Pp();return z(t,()=>Lp(e().density??0)),t})()]}}),null),t})()}),null),o(n=>{var r=`1px solid ${e.dim?`#21262d`:`#30363d`}`,i=e.dim?.6:1;return r!==n.e&&R(t,`border`,n.e=r),i!==n.t&&R(t,`opacity`,n.t=i),n},{e:void 0,t:void 0}),t})()}var zp=P(`<span style=color:#8b949e;font-size:11px>Checking…`),Bp=P(`<div style=margin-top:8px><div style="padding:6px 8px;font-size:11px;font-weight:600;color:#c9d1d9;margin-bottom:6px">Your flags`),Vp=P(`<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>`),Hp=P(`<span style=color:#f85149;font-size:11px>`),Up=P(`<div style=margin-top:8px;color:#484f58;font-style:italic;font-size:12px>No flags.`),Wp=P(`<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:Gp}=Jt(`flag`),Kp={};for(let[e,t]of Object.entries(Tl))Kp[t]=e;function qp(){let e=e=>{Al({...kl(),...e})},[t,n]=x(null),[r,i]=x(!1),a=null;f(()=>{if(Dl()!==`flag`||kl().name.trim()!==``)return;let t=W();t&&t.http.game.genUniqueFlagName().then(t=>{e({name:t.name}),n(null)}).catch(e=>{Gp(`gen unique name failed:`,e)})});let s=t=>{e({name:t}),n(null),a&&clearTimeout(a);let r=t.trim();if(!r){i(!1);return}i(!0),a=setTimeout(()=>{let e=W();if(!e){i(!1);return}e.http.game.checkUniqueFlagName(r).then(()=>{n(null)}).catch(e=>{n(e.message)}).finally(()=>{i(!1)})},300)},c=()=>Tl[kl().color]??1,d=()=>Tl[kl().secondaryColor]??1,p=t=>{e({color:Kp[t]??`COLOR_WHITE`})},h=t=>{e({secondaryColor:Kp[t]??`COLOR_WHITE`})},g=()=>{let e=Cn(),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},_=e=>e===void 0||e<0||e>=Ki.length?`#8b949e`:`#${Ki[e].toString(16).padStart(6,`0`)}`,v={display:`flex`,"flex-direction":`column`,gap:`5px`,"font-size":`11px`,color:`#8b949e`};return(()=>{var e=Vp(),n=e.firstChild.firstChild.nextSibling.firstChild,i=n.firstChild.nextSibling,a=n.nextSibling;a.firstChild;var f=a.nextSibling;f.firstChild;var y=f.nextSibling;return i.$$input=e=>s(e.currentTarget.value),z(n,m(u,{get when(){return t()},children:e=>(()=>{var t=Hp();return z(t,e),t})()}),null),z(n,m(u,{get when(){return r()},get children(){return zp()}}),null),z(a,m(ld,{get value(){return c()},onChange:p}),null),z(f,m(ld,{get value(){return d()},onChange:h}),null),z(y,(()=>{var e=N(()=>!!jl());return()=>e()?`Marked at x=${jl().tx}, y=${jl().ty}. Click again to create the flag, or click elsewhere to move the mark.`:`Click a position in the room to mark it.`})()),z(e,m(u,{get when(){return g().length>0},get fallback(){return Up()},get children(){var e=Bp();return e.firstChild,z(e,m(l,{get each(){return g()},children:([e,t])=>(()=>{var n=Wp(),r=n.firstChild.firstChild,i=r.nextSibling,a=i.nextSibling,s=a.nextSibling,c=s.firstChild.nextSibling,l=c.nextSibling.nextSibling;return l.nextSibling,z(i,e),z(a,()=>t.room),z(s,()=>t.x,c),z(s,()=>t.y,l),o(e=>R(r,`background`,_(t.color))),n})()}),null),e}}),null),o(e=>{var r=v,o=`1px solid ${t()?`#f85149`:`#30363d`}`,s=v,c=v;return e.e=L(n,r,e.e),o!==e.t&&R(i,`border`,e.t=o),e.a=L(a,s,e.a),e.o=L(f,c,e.o),e},{e:void 0,t:void 0,a:void 0,o:void 0}),o(()=>i.value=kl().name),e})()}F([`input`]);var Jp=P(`<span style=color:#8b949e>…`),Yp=P(`<span style=color:#3fb950>✓`),Xp=P(`<span style=color:#f85149>✗`),Zp=P(`<div style=font-size:10px;color:#f85149>`),Qp=P(`<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>`),$p=P(`<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>`),em=P(`<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 tm(t){let n=Object.keys(El),[r,i]=x(`idle`),[a,s]=x(``),c=null,d=(e,t)=>{let n=El[e];return n?Tn()===`empty`&&e===`spawn`?Math.max(n[t]??0,1):n[t]??0:0},p=(e,t)=>{let n=d(e,t);if(n===2500)return 1/0;let r=jc()[e]??0;return Math.max(0,n-r)},h=()=>Fl().structureType===`spawn`;f(e(()=>Fl().structureType,(e,n)=>{if(e!==`spawn`||e===n)return;let r=W();if(!r)return;i(`loading`),s(``);let a=!1;y(()=>{a=!0}),r.http.game.genUniqueObjectName(`spawn`,t.shard).then(e=>{a||(Il({structureType:`spawn`,structureName:e.name}),i(`valid`))}).catch(()=>{a||(Il({structureType:`spawn`,structureName:`Spawn1`}),i(`idle`))})}));let g=e=>{if(c&&clearTimeout(c),!e.trim()){i(`invalid`),s(`Name cannot be empty`);return}i(`loading`),s(``),c=setTimeout(()=>{let n=W();n&&n.http.game.checkUniqueObjectName(`spawn`,e.trim(),t.shard).then(e=>{e.error?(i(`invalid`),s(e.error)):(i(`valid`),s(``))}).catch(()=>{i(`invalid`),s(`Could not validate name`)})},400)},_=e=>{Il({structureType:`spawn`,structureName:e}),g(e)},v=e=>{Il({structureType:e,structureName:``}),i(`idle`),s(``)},b=()=>{switch(r()){case`loading`:return Jp();case`valid`:return Yp();case`invalid`:return Xp();default:return null}};return(()=>{var e=$p(),t=e.firstChild,i=t.firstChild;i.firstChild;var s=i.nextSibling,c=t.nextSibling;c.firstChild;var f=c.nextSibling,g=f.firstChild;return z(i,()=>Tc()??`?`,null),z(s,()=>{let e=Tn();return e===`empty`?`World is empty — place a spawn to claim this room.`:e===`lost`?`You lost all your spawns — respawn to continue.`:Tc()==null?`No controller — roads and containers only.`:`RCL ${Tc()} — Select a structure type and click a tile to build.`}),z(c,m(l,{each:n,children:e=>{let t=()=>Tc()??0,n=()=>d(e,t()),r=()=>jc()[e]??0,i=()=>Fl().structureType===e,a=()=>n()===2500,s=()=>!a()&&p(e,t())<=0;return m(u,{get when(){return n()>0},get children(){var t=em(),c=t.firstChild,l=c.nextSibling;return t.$$click=()=>!s()&&v(e),z(c,()=>e.replace(/([A-Z])/g,` $1`).trim(),null),z(c,()=>i()&&` ✓`,null),z(l,(()=>{var e=N(()=>!!a());return()=>e()?`${r()}/∞`:`${r()}/${n()}`})(),null),z(l,()=>s()&&` (Max)`,null),o(e=>{var n=i()?`#1f3158`:`transparent`,r=s()?`default`:`pointer`,a=s()?.5:1;return n!==e.e&&R(t,`background`,e.e=n),r!==e.t&&R(t,`cursor`,e.t=r),a!==e.a&&R(t,`opacity`,e.a=a),e},{e:void 0,t:void 0,a:void 0}),t}})}}),null),z(e,m(u,{get when(){return h()},get children(){var e=Qp(),t=e.firstChild.nextSibling,n=t.firstChild.firstChild,i=n.nextSibling;return n.$$input=e=>_(e.currentTarget.value),z(i,b),z(t,m(u,{get when(){return N(()=>r()===`invalid`)()&&a()},get children(){var e=Zp();return z(e,a),e}}),null),o(e=>R(n,`border`,`1px solid ${r()===`invalid`?`#f85149`:r()===`valid`?`#238636`:`#30363d`}`)),o(()=>n.value=Fl().structureName??``),e}}),f),z(g,()=>Fl().structureType?`Click a tile in the room to build.`:`Select a structure type, then click a tile.`),e})()}F([`input`,`click`]);var nm=P(`<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">`),rm=P(`<button type=button>`),im=P(`<option>/s`),am=[.5,1,2,5,10,20],om=[{delta:-100,label:`-100`},{delta:-10,label:`-10`}],sm=[{delta:10,label:`+10`},{delta:100,label:`+100`}];function cm(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 lm(){let e=()=>{let e=Qc(),t=Jc(),n=vn()??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=nm(),n=t.firstChild.firstChild,r=n.firstChild,i=r.nextSibling;i.firstChild;var a=n.nextSibling,s=a.firstChild,c=a.nextSibling.firstChild.nextSibling;return z(r,(()=>{var e=N(()=>!!il());return()=>e()?`Loading…`:`Tick ${Jc()}`})()),z(i,e,null),z(a,m(l,{each:om,children:e=>(()=>{var t=rm();return t.$$click=()=>fl(e.delta),z(t,()=>e.label),o(e=>{var n=il(),r=cm(il());return n!==e.e&&(t.disabled=e.e=n),e.t=L(t,r,e.t),e},{e:void 0,t:void 0}),t})()}),s),ye(s,`click`,pl,!0),z(s,()=>el()?`⏸`:`▶`),z(a,m(l,{each:sm,children:e=>(()=>{var t=rm();return t.$$click=()=>fl(e.delta),z(t,()=>e.label),o(e=>{var n=il(),r=cm(il());return n!==e.e&&(t.disabled=e.e=n),e.t=L(t,r,e.t),e},{e:void 0,t:void 0}),t})()}),null),c.addEventListener(`change`,e=>ml(parseFloat(e.currentTarget.value))),z(c,m(l,{each:am,children:e=>(()=>{var t=im(),n=t.firstChild;return t.value=e,z(t,e,n),t})()})),o(e=>{var t=il()?`#f0883e`:`#c9d1d9`,n=il(),i=el()?`#1a3a2a`:`#161b22`,a=el()?`#3fb950`:`#8b949e`,o=il()?`not-allowed`:`pointer`;return t!==e.e&&R(r,`color`,e.e=t),n!==e.t&&(s.disabled=e.t=n),i!==e.a&&R(s,`background`,e.a=i),a!==e.o&&R(s,`color`,e.o=a),o!==e.i&&R(s,`cursor`,e.i=o),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),o(()=>c.value=nl()),t})()}F([`click`]);var um=P(`<div style=padding-bottom:8px;overflow:auto;min-height:0>`),dm=P(`<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`),fm=P(`<button style=background:transparent;border:none;color:#8b949e;font-size:14px;cursor:pointer;padding:4px>`),pm=P(`<button style=background:transparent;border:none;color:#8b949e;font-size:11px;cursor:pointer>Collapse`);function mm(e){return m(u,{get when(){return Dl()===`flag`},get fallback(){return m(u,{get when(){return Dl()===`build`},get fallback(){return m(Tf,{})},get children(){return m(tm,{get shard(){return e.shard}})}})},get children(){return m(qp,{})}})}function hm(e){let t=()=>{e.onToggle?.()},n=t=>{t.stopPropagation(),e.onToggle?.()};return(()=>{var r=dm(),i=r.firstChild,a=i.nextSibling,o=a.firstChild;return o.firstChild,i.$$click=t,z(i,(()=>{var t=N(()=>!!e.onToggle);return()=>t()&&(()=>{var t=fm();return t.$$click=n,z(t,()=>e.isCollapsed?`▶`:`◀`),t})()})()),z(o,(()=>{var t=N(()=>!!e.onToggle);return()=>t()&&(()=>{var e=pm();return e.$$click=n,e})()})(),null),z(a,m(u,{get when(){return e.mapMode},get fallback(){return m(Lf,{get room(){return e.room??`—`},get shard(){return e.shard??null}})},get children(){return m(Op,{get zoom(){return e.mapZoom},get subsActive(){return e.mapSubsActive}})}}),null),z(a,m(u,{get when(){return N(()=>!e.mapMode)()&&Z()},get children(){return m(lm,{})}}),null),z(a,m(u,{get when(){return e.mapMode},get fallback(){return m(mm,{get shard(){return e.shard}})},get children(){var t=um();return z(t,m(Rp,{label:`Selected`,get info(){return e.selectedRoomInfo??null}}),null),z(t,m(Rp,{label:`Cursor`,get info(){return e.hoveredRoomInfo??null},dim:!0}),null),t}}),null),r})()}F([`click`]);var gm=P(`<div style=display:flex;gap:6px;align-items:center><span style=font-weight:600>CPU:</span><span style=color:#c9d1d9>`),_m=P(`<div style=display:flex;gap:6px;align-items:center><span style=font-weight:600>Memory:</span><span style=color:#c9d1d9>`),vm=P(`<div style=display:flex;gap:6px;align-items:center><span style=font-weight:600>Zoom:</span><span style=color:#c9d1d9>%`),ym=P(`<div style=display:flex;gap:6px;align-items:center><span style=font-weight:600>Subs:</span><span>`),bm=P(`<div style="display:flex;gap:16px;padding:6px 16px;font-size:12px;color:#8b949e;align-items:center">`);function xm(e){let[t,n]=x(null);a(()=>{let e=W();if(!e)return;let t=new _t;t.add(e.stores.user.subscribe(`cpu`)),t.add(e.stores.user.on(`user:cpu`,e=>{n(e)})),y(()=>{t.dispose()})});let r=()=>{let e=t();if(!e)return`—`;let n=pn()?.cpu??`?`;return`${e.cpu.toFixed(0)} / ${n}`},i=()=>{let e=t();return e?`${(e.memory/1024).toFixed(1)} KB`:`—`};return(()=>{var n=bm();return z(n,m(u,{get when(){return t()!==null},get children(){return[(()=>{var e=gm(),t=e.firstChild.nextSibling;return z(t,r),e})(),(()=>{var e=_m(),t=e.firstChild.nextSibling;return z(t,i),e})()]}}),null),z(n,m(u,{get when(){return N(()=>e.mapZoom!==null)()&&e.mapZoom!==void 0},get children(){return[(()=>{var t=vm(),n=t.firstChild.nextSibling,r=n.firstChild;return z(n,()=>(e.mapZoom*100).toFixed(0),r),t})(),(()=>{var t=ym(),n=t.firstChild.nextSibling;return z(n,()=>e.mapSubsActive===!1?`paused`:`active`),o(t=>R(n,`color`,e.mapSubsActive===!1?`#e3b341`:`#3fb950`)),t})()]}}),null),n})()}var Sm=P(`<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">`),Cm=P(`<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>`),wm=P(`<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">`),Tm=P(`<button style=width:100%;aspect-ratio:1;border-radius:2px;cursor:pointer;padding:0;outline:none>`),Em={};for(let e=1;e<=24;e++){let t=Lt({type:e,color1:`#4a5060`,color2:`#7a9ec0`,color3:`#c0daf0`,param:0,flip:!1});Em[e]=`data:image/svg+xml,${encodeURIComponent(t)}`}function Dm(e){return typeof e==`string`?e:Ft[e]?.rgb??`#000000`}function Om(e){return typeof e==`number`?Math.max(0,Math.min(79,e)):e}var km=[{slot:1,label:`Background`},{slot:2,label:`Primary`},{slot:3,label:`Secondary`}],Am=Array.from({length:24},(e,t)=>t+1),jm=/^#[0-9a-f]{6}$/i;function Mm(e){let[t,n]=x(r(()=>typeof e.badge.type==`number`?e.badge.type:1)),[i,a]=x(r(()=>Om(e.badge.color1))),[s,c]=x(r(()=>Om(e.badge.color2))),[u,p]=x(r(()=>Om(e.badge.color3))),[h,g]=x(r(()=>e.badge.param??0)),[_,v]=x(r(()=>e.badge.flip??!1)),[y,b]=x(1),[S,C]=x(!1),[w,T]=x(r(()=>Dm(Om(e.badge.color1)))),E=e=>e===1?i():e===2?s():u(),ee=e=>{let t=y();t===1?a(e):t===2?c(e):p(e)};f(()=>{T(Dm(E(y())))});let D=e=>{let t=E(y());return typeof t==`number`?t===e:t.toLowerCase()===(Ft[e]?.rgb??``).toLowerCase()},O=()=>({type:t(),color1:Dm(i()),color2:Dm(s()),color3:Dm(u()),param:h(),flip:_()}),te=d(()=>{let e=Lt(O());return`data:image/svg+xml,${encodeURIComponent(e)}`}),ne=e=>{if(T(e),!jm.test(e))return;let t=Ft.findIndex(t=>t.rgb.toLowerCase()===e.toLowerCase());ee(t>=0?t:e)},re=async()=>{let t=W();if(t){C(!0);try{await t.http.user.badge(O()),await t.stores.user.refreshMe(),e.onClose(),e.onSaved?.(),V(`Badge saved`,`success`,3e3)}catch(e){V(`Failed to save badge: ${e instanceof Error?e.message:String(e)}`,`error`,5e3)}finally{C(!1)}}},k=t=>{t.target===t.currentTarget&&e.onClose()};return(()=>{var r=Sm(),i=r.firstChild.firstChild,a=i.firstChild.nextSibling,s=i.nextSibling,c=s.firstChild,u=c.firstChild,d=u.firstChild.nextSibling,f=u.nextSibling.firstChild.nextSibling,p=c.nextSibling,x=p.firstChild.nextSibling,C=x.nextSibling,T=C.nextSibling.firstChild,O=T.nextSibling,ie=p.nextSibling,ae=ie.firstChild,A=ae.firstChild.nextSibling,j=ae.nextSibling,oe=ie.nextSibling.firstChild,M=s.nextSibling.firstChild,se=M.nextSibling;return r.$$click=k,a.$$click=()=>e.onClose(),z(a,m(Rr,{size:18})),z(f,m(l,{each:Am,children:e=>(()=>{var r=Cm(),i=r.firstChild;return r.$$click=()=>n(e),o(n=>{var a=t()===e?`#1f3a2a`:`#0d1117`,o=`1px solid ${t()===e?`#238636`:`#21262d`}`,s=t()===e?te():Em[e];return a!==n.e&&R(r,`background`,n.e=a),o!==n.t&&R(r,`border`,n.t=o),s!==n.a&&I(i,`src`,n.a=s),n},{e:void 0,t:void 0,a:void 0}),r})()})),z(x,m(l,{each:km,children:({slot:e,label:t})=>(()=>{var n=wm(),r=n.firstChild;return n.$$click=()=>b(e),z(n,t,null),o(t=>{var i=`1px solid ${y()===e?`#58a6ff`:`#30363d`}`,a=y()===e?`#1c2d47`:`transparent`,o=y()===e?`#58a6ff`:`#8b949e`,s=Dm(E(e));return i!==t.e&&R(n,`border`,t.e=i),a!==t.t&&R(n,`background`,t.t=a),o!==t.a&&R(n,`color`,t.a=o),s!==t.o&&R(r,`background`,t.o=s),t},{e:void 0,t:void 0,a:void 0,o:void 0}),n})()})),z(C,m(l,{each:Ft,children:e=>(()=>{var t=Tm();return t.$$click=()=>ee(e.index),o(n=>{var r=e.rgb,i=e.rgb,a=D(e.index)?`2px solid #fff`:`1px solid transparent`;return r!==n.e&&I(t,`title`,n.e=r),i!==n.t&&R(t,`background`,n.t=i),a!==n.a&&R(t,`border`,n.a=a),n},{e:void 0,t:void 0,a:void 0}),t})()})),O.$$input=e=>ne(e.currentTarget.value),z(A,h),j.$$input=e=>g(+e.currentTarget.value),oe.addEventListener(`change`,e=>v(e.currentTarget.checked)),M.$$click=()=>e.onClose(),se.$$click=re,z(se,()=>S()?`Saving…`:`Save Badge`),o(e=>{var t=te(),n=jm.test(w())?w():Dm(E(y())),r=`1px solid ${jm.test(w())?`#30363d`:`#f85149`}`,i=S(),a=S()?`not-allowed`:`pointer`,o=S(),s=S()?`not-allowed`:`pointer`,c=S()?.7:1;return t!==e.e&&I(d,`src`,e.e=t),n!==e.t&&R(T,`background`,e.t=n),r!==e.a&&R(O,`border`,e.a=r),i!==e.o&&(M.disabled=e.o=i),a!==e.i&&R(M,`cursor`,e.i=a),o!==e.n&&(se.disabled=e.n=o),s!==e.s&&R(se,`cursor`,e.s=s),c!==e.h&&R(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}),o(()=>O.value=w()),o(()=>j.value=h()),o(()=>oe.checked=_()),r})()}F([`click`,`input`]);var Nm=P(`<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">`),Pm=P(`<div style=font-size:11px;color:#8b949e;margin-top:3px>`),Fm=P(`<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>`),Im=P(`<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>`),Lm=P(`<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)`),Rm=P(`<img width=40 height=40 style=display:block>`),zm=P(`<div style="display:flex;align-items:center;justify-content:space-between;padding:10px 0;border-bottom:1px solid #21262d"><div style=display:flex;align-items:center;gap:12px><span style=font-size:13px;color:#c9d1d9></span></div><button style="padding:6px 14px;border-radius:6px;border:1px solid #30363d;background:transparent;color:#c9d1d9;font-size:12px;cursor:pointer;flex-shrink:0">`),Bm=P(`<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">`),Vm=P(`<div style="position:absolute;inset:0px;background:rgba(13, 17, 23, 0.96);z-index:100;display:flex;flex-direction:column;overflow:hidden"><div style="display:flex;align-items:center;justify-content:space-between;padding:14px 24px;border-bottom:1px solid #30363d;flex-shrink:0"><span style=font-size:15px;font-weight:600;color:#c9d1d9>Settings</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 24px"><div style=max-width:480px>`),Hm={type:1,color1:`#4a5060`,color2:`#7a9ec0`,color3:`#c0daf0`,param:0,flip:!1};function Um(e){return(()=>{var t=Nm(),n=t.firstChild,r=n.firstChild,i=n.nextSibling,a=i.firstChild;return z(r,()=>e.label),z(n,(()=>{var t=N(()=>!!e.description);return()=>t()&&(()=>{var t=Pm();return z(t,()=>e.description),t})()})(),null),i.$$click=()=>e.onChange(!e.value),o(t=>{var n=e.value?`#238636`:`#30363d`,r=e.value?`22px`:`2px`;return n!==t.e&&R(i,`background`,t.e=n),r!==t.t&&R(a,`left`,t.t=r),t},{e:void 0,t:void 0}),t})()}function Wm(e){return(()=>{var t=Fm(),n=t.firstChild;return z(n,()=>e.title),z(t,()=>e.children,null),t})()}function Gm(e){return(()=>{var t=Im(),n=t.firstChild,r=n.nextSibling;return z(n,()=>e.label),z(r,()=>e.value),t})()}function Km(e){let t=Kt(),n=!K()&&!pn()?.badge,[r,i]=x(n),[a,s]=x(!1),c=d(()=>{let e=pn()?.badge;if(!e)return null;let t=Lt(e);return`data:image/svg+xml,${encodeURIComponent(t)}`});async function l(){s(!0);try{await on(),V(`All caches cleared. Reloading…`,`success`,2e3),setTimeout(()=>window.location.reload(),1500)}catch{V(`Failed to clear caches.`,`error`),s(!1)}}return(()=>{var s=Vm(),d=s.firstChild,f=d.firstChild.nextSibling,p=d.nextSibling,h=p.firstChild;return f.$$click=()=>e.onClose(),z(f,m(Rr,{size:18})),z(s,m(u,{get when(){return r()},get children(){return m(Mm,{get badge(){return pn()?.badge??Hm},onClose:()=>i(!1),onSaved:n?()=>e.onClose():void 0})}}),p),z(h,m(Wm,{title:`Layout`,get children(){return m(Um,{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 ys()},onChange:bs})}}),null),z(h,m(Wm,{title:`Room View`,get children(){return[m(Um,{label:`Show creep labels`,description:`Display each creep's name above its sprite.`,get value(){return xs()},onChange:Ss}),m(Um,{label:`Terrain effects`,description:`Swamp glow and wall noise texture overlay.`,get value(){return Ds()},onChange:Os}),m(Um,{label:`Verbose creep details`,description:`Show a colour-coded body part breakdown (e.g. 8×MOVE, 4×WORK) in the creep property panel.`,get value(){return Ls()},onChange:Rs}),m(Um,{label:`Room decorations`,description:`Load player-activated theme decorations (floor, wall, road colors) from the server.`,get value(){return ks()},onChange:As}),m(Um,{label:`Dark overlay + lights`,description:`Darken the room and add per-object light glows.`,get value(){return js()},onChange:Ms}),(()=>{var e=Lm(),t=e.firstChild.nextSibling;return t.addEventListener(`change`,e=>Is(e.currentTarget.value)),o(()=>t.value=Fs()),e})()]}}),null),z(h,m(Wm,{title:`Map View`,get children(){return[m(Um,{label:`Show room names`,description:`Render a small room name in the top-left corner of each map tile.`,get value(){return Cs()},onChange:ws}),m(Um,{label:`Show unclaimable rooms`,description:`Highlight rooms where you cannot claim a controller: corridors, sector centres, rooms already owned, and restricted areas.`,get value(){return Ts()},onChange:Es})]}}),null),z(h,m(u,{get when(){return!K()},get children(){return m(Wm,{title:`Player Badge`,get children(){var e=zm(),t=e.firstChild,n=t.firstChild,r=t.nextSibling;return z(t,m(u,{get when(){return c()},get children(){var e=Rm();return o(()=>I(e,`src`,c())),e}}),n),z(n,()=>pn()?.username??``),r.$$click=()=>i(!0),z(r,()=>c()?`Edit Badge`:`Create Badge`),e}})}}),null),z(h,m(Wm,{title:`Data`,get children(){var e=Bm(),t=e.firstChild;t.firstChild.nextSibling;var n=t.nextSibling;return n.$$click=l,z(n,()=>a()?`Clearing…`:`Clear`),o(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&&R(n,`color`,e.t=r),i!==e.a&&R(n,`cursor`,e.a=i),o!==e.o&&R(n,`opacity`,e.o=o),e},{e:void 0,t:void 0,a:void 0,o:void 0}),e}}),null),z(h,m(Wm,{title:`About`,get children(){return[m(Gm,{label:`Client version`,get value(){return Gt()}}),N(()=>t&&m(Gm,{label:`Mod version`,get value(){return`${t.version} (${t.kind})`}}))]}}),null),s})()}F([`click`]);var qm=P(`<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">`),Jm=15e3;function Ym(e){let t,n=()=>{t!==void 0&&(clearTimeout(t),t=void 0)},r=()=>{n(),t=setTimeout(()=>e.onClose(),Jm)};return a(r),y(n),(()=>{var t=qm(),i=t.firstChild,a=i.nextSibling;return t.addEventListener(`mouseleave`,r),t.addEventListener(`mouseenter`,n),i.$$click=()=>e.onClose(),z(i,m(Rr,{size:16})),o(()=>a.innerHTML=e.text),t})()}F([`click`]);var Xm=P(`<button style="padding:7px;border-radius:4px;cursor:pointer;margin:0 4px;display:flex;align-items:center">`),Zm=P(`<button style="padding:7px;border-radius:4px;border:1px solid #30363d;background:#21262d;margin:0 2px;display:flex;align-items:center">`),Qm=P(`<div style=flex:1;position:relative;overflow:hidden>`),$m=P(`<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>`),eh=P(`<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>`),th=P(`<div style=display:flex;flex:1;overflow:hidden><div style=display:flex;flex-direction:column;flex:1;overflow:hidden>`),nh=P(`<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><button style="padding:7px;border-radius:4px;border:none;color:#fff;cursor:pointer;margin:0 16px 0 8px;display:flex;align-items:center">`),rh=P(`<div style=display:flex;flex-direction:column;flex:1;overflow:hidden><div style=display:flex;flex:1;overflow:hidden>`),ih=b(()=>te(()=>import(`./CodePanel-CwVNxrB0.js`).then(e=>({default:e.CodePanel})),__vite__mapDeps([2,3]))),ah=b(()=>te(()=>import(`./MapViewer-B3Ow_Bmv.js`).then(e=>({default:e.MapViewer})),__vite__mapDeps([4,3])));function oh(){let e=qt(),t=window.location.pathname.match(RegExp(`^${e}/room/([A-Za-z0-9]+)`));if(!t)return{room:null,shard:null,tick:null};let n=t[1].toUpperCase();if(!Bc(n))return{room:null,shard:null,tick:null};let r=new URLSearchParams(window.location.search).get(`shard`),i=window.location.hash.match(/tick=(\d+)/);return{room:n,shard:r,tick:i?parseInt(i[1],10):null}}function sh(e,t){return`${qt()}/room/${e}${t?`?shard=${encodeURIComponent(t)}`:``}`}function ch(e){return`${qt()}/map${e?`?shard=${encodeURIComponent(e)}`:``}`}function lh(){return window.location.pathname.startsWith(`${qt()}/map`)?{shard:new URLSearchParams(window.location.search).get(`shard`)}:null}function uh(e){return(()=>{var t=Xm();return t.$$click=()=>e.onClick(),z(t,()=>e.children),o(n=>{var r=e.title,i=`1px solid ${e.active?`#388bfd`:`#30363d`}`,a=e.active?`#1f3158`:`#21262d`,o=e.active?`#58a6ff`:`#c9d1d9`;return r!==n.e&&I(t,`title`,n.e=r),i!==n.t&&R(t,`border`,n.t=i),a!==n.a&&R(t,`background`,n.a=a),o!==n.o&&R(t,`color`,n.o=o),n},{e:void 0,t:void 0,a:void 0,o:void 0}),t})()}function dh(e){return(()=>{var t=Zm();return t.$$click=()=>e.onClick(),z(t,()=>e.children),o(n=>{var r=e.title,i=e.disabled,a=e.disabled?`#484f58`:`#c9d1d9`,o=e.disabled?`default`:`pointer`;return r!==n.e&&I(t,`title`,n.e=r),i!==n.t&&(t.disabled=n.t=i),a!==n.a&&R(t,`color`,n.a=a),o!==n.o&&R(t,`cursor`,n.o=o),n},{e:void 0,t:void 0,a:void 0,o:void 0}),t})()}function fh(){let e=oh(),[t,n]=x(e.room??Yt(H.room)??`W1N1`),[i,s]=x(e.shard??Yt(H.shard)),[c,l]=x(lh()!==null||!e.room),d=()=>hn()?.serverData?.welcomeText??null,[p,h]=x(!1),g=()=>K()&&c()&&!p()&&d()!==null,[_,v]=x(!K()&&!pn()?.badge),[b,S]=x(!1),[C,w]=x(!1);f(()=>{b(),w(!0),Promise.resolve().then(()=>w(!1))}),f(()=>{K()&&Ol(`view`)}),f(()=>{if(i()!==null||Nn()!==!1)return;let e=hn()?.serverData?.shards?.[0];e&&s(e)});let[T,E]=x(void 0),[ee,D]=x(null),[O,te]=x(null),ne=Yt(H.mapZoom),[re,k]=x(e.room&&ne?Number(ne):null),[ie,ae]=x(null),[A,j]=x(!1),[oe,M]=x(!1),se=e.tick;f(()=>{let e=G();if(e===null||se===null)return;let t=se;se=null,ll(e),dl(t)}),f(()=>{if(r(c))return;let e=sh(t(),i());Z()?history.replaceState(null,``,`${e}#tick=${Jc()}`):history.replaceState(null,``,e)});let[ce,le]=x(Qt(H.sidebarWidth,300)),[ue,de]=x(Qt(H.sidebarWidth,300)),[fe,pe]=x(Qt(H.consoleHeight,220)),[me,he]=x(Qt(H.consoleHeight,220)),[P,F]=x(!1),[ge,_e]=x(!1),ve=()=>ce()<=32,be=()=>fe()<=32,L=()=>{ce()>32?(de(ce()),le(32)):le(ue())},xe=()=>{fe()>32?(he(fe()),pe(32)):pe(me())},Se=e=>{e.preventDefault(),F(!0);let t=e.clientX,n=ce(),r=e=>{let r=e.clientX-t;le(Math.max(32,Math.min(500,n-r)))},i=()=>{F(!1),$t(H.sidebarWidth,ce()),window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)},Ce=e=>{e.preventDefault(),_e(!0);let t=e.clientY,n=fe(),r=e=>{let r=e.clientY-t;pe(Math.max(32,Math.min(500,n-r)))},i=()=>{_e(!1),$t(H.consoleHeight,fe()),window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)},we=(e,t)=>{W()?.stores.navigation.navigateTo(e,t)},Te=e=>{E(e),l(!0),history.pushState(null,``,ch(i()))},Ee=()=>{c()?(l(!1),D(null),te(null),history.pushState(null,``,sh(t(),i()))):Te(t())};a(()=>{!oh().room&&!lh()&&history.replaceState(null,``,ch(i()));let e=()=>{let e=lh();if(e){l(!0),e.shard!==null&&s(e.shard),r(Z)&&ul();return}let{room:t,shard:i,tick:a}=oh();t&&(n(t),s(i),l(!1),a===null?r(Z)&&ul():se=a)};window.addEventListener(`popstate`,e),y(()=>window.removeEventListener(`popstate`,e));let a=W()?.stores.navigation;if(a){let e=a.on(`navigation:change`,e=>{e.room!==null&&(n(e.room),s(e.shard),l(!1),D(null),te(null),j(a.canBack()),M(a.canForward()),Xt(H.room,e.room),e.shard?Xt(H.shard,e.shard):Zt(H.shard),history.pushState(null,``,sh(e.room,e.shard)))});y(()=>e.dispose())}let o=e=>{if(!Gc(e.target)){if(e.key===`o`||e.key===`O`){S(e=>!e),v(!1);return}(e.key===`l`||e.key===`L`)&&du(),(e.key===`c`||e.key===`C`)&&fu(),(e.key===`y`||e.key===`Y`)&&pu(),c()||(e.key===`1`&&Ol(`view`),K()||(e.key===`2`&&Ol(`flag`),e.key===`3`&&Ol(`build`)),e.key===`m`&&Te(t()))}};window.addEventListener(`keydown`,o),y(()=>window.removeEventListener(`keydown`,o))});let De=()=>(()=>{var e=Qm();return z(e,m(u,{get when(){return _()},get children(){return m(Km,{onClose:()=>v(!1)})}}),null),z(e,m(u,{get when(){return b()},get children(){return m(ih,{onClose:()=>S(!1)})}}),null),z(e,m(u,{get when(){return!c()},get fallback(){return m(ah,{get shard(){return i()},get originRoom(){return T()},get initialZoom(){return re()??void 0},onNavigateToRoom:e=>we(e,i()),onHoveredRoomChanged:D,onSelectedRoomChanged:te,onZoomChanged:e=>{k(e),$t(H.mapZoom,e)},onSubscriptionStateChanged:ae})},get children(){return m(Xl,{get room(){return t()},get shard(){return i()},onNavigate:we})}}),null),z(e,m(u,{get when(){return g()},get children(){return m(Ym,{get text(){return d()},onClose:()=>h(!0)})}}),null),e})(),Oe=()=>m(u,{get when(){return!K()},get children(){var e=$m(),t=e.firstChild;return t.$$pointerdown=Ce,z(e,m(ad,{get shard(){return i()},get isCollapsed(){return be()},onToggle:xe}),null),o(t=>{var n=`${fe()}px`,r=ge()?`none`:`height 0.15s ease`;return n!==t.e&&R(e,`height`,t.e=n),r!==t.t&&R(e,`transition`,t.t=r),t},{e:void 0,t:void 0}),e}}),ke=e=>(()=>{var n=eh(),r=n.firstChild;return r.$$pointerdown=Se,z(n,m(hm,{get isCollapsed(){return ve()},onToggle:L,get mapMode(){return c()},get hoveredRoomInfo(){return ee()},get selectedRoomInfo(){return O()},get room(){return t()},get shard(){return i()},get mapZoom(){return re()},get mapSubsActive(){return ie()}}),null),o(t=>{var r=b()?`0`:`${ce()}px`,i=e&&!(C()||P())?`width 0.15s ease`:`none`;return r!==t.e&&R(n,`width`,t.e=r),i!==t.t&&R(n,`transition`,t.t=i),t},{e:void 0,t:void 0}),n})();return(()=>{var e=nh(),t=e.firstChild,n=t.firstChild,r=n.nextSibling;return z(t,m(xi,{}),n),z(t,m(u,{get when(){return!K()||c()},get children(){return m(xm,{get mapZoom(){return N(()=>!!c())()?re():null},get mapSubsActive(){return N(()=>!!c())()?ie():null}})}}),n),z(t,m(dh,{title:`Back`,get disabled(){return!A()},onClick:()=>W()?.stores.navigation.back(),get children(){return m(er,{size:16})}}),r),z(t,m(dh,{title:`Forward`,get disabled(){return!oe()},onClick:()=>W()?.stores.navigation.forward(),get children(){return m(Qn,{size:16})}}),r),z(t,m(uh,{get title(){return c()?`Room View`:`Map`},get active(){return c()},onClick:Ee,get children(){return N(()=>!!c())()?m(fr,{size:16}):m(br,{size:16})}}),r),z(t,m(u,{get when(){return!K()},get children(){return m(uh,{title:`Code Editor`,get active(){return b()},onClick:()=>{S(e=>!e),v(!1)},get children(){return m(ir,{size:16})}})}}),r),z(t,m(uh,{title:`Settings`,get active(){return _()},onClick:()=>{v(e=>!e),S(!1)},get children(){return m(Mr,{size:16})}}),r),ye(r,`click`,In,!0),z(r,(()=>{var e=N(()=>!!K());return()=>e()?m(gr,{size:16}):m(vr,{size:16})})()),z(e,m(u,{get when(){return ys()},get fallback(){return(()=>{var e=rh(),t=e.firstChild;return z(t,De,null),z(t,()=>ke(!0),null),z(e,Oe,null),e})()},get children(){var e=th(),t=e.firstChild;return z(t,De,null),z(t,Oe,null),z(e,()=>ke(!1),null),e}}),null),z(e,m($l,{}),null),o(e=>{var t=K()?`Login`:`Logout`,n=K()?`#238636`:`#da3633`;return t!==e.e&&I(r,`title`,e.e=t),n!==e.t&&R(r,`background`,e.t=n),e},{e:void 0,t:void 0}),e})()}F([`click`,`pointerdown`]);var ph=P(`<div style=width:100%;height:100%>`),{log:mh}=Jt(`app`);function hh(){let e=new URLSearchParams(window.location.search).get(`guest`);return e===null?null:e.startsWith(`http`)?e:nn(U.url)??`https://screeps.com`}function gh(){if(Ut()||hh()!==null)return!0;let e=Ht()?Wt():nn(U.url),t=nn(U.token);return!!(e&&t)}function _h(){let e=()=>ln()===`connected`&&W()!==null,[t,n]=x(gh());return a(async()=>{try{if(ln()===`idle`&&(await Fn().catch(()=>{}),ln()!==`connected`)){if(Ut()){let e=Wt();mh(`xxscreeps mode — auto-connecting as guest to ${e}`),await Pn({url:e,auth:`guest`,storage:null}).catch(()=>{})}else if(!Ht()){let e=hh();e&&(mh(`?guest param — auto-connecting as guest to ${e}`),await Pn({url:e,auth:`guest`,storage:null}).catch(()=>{}))}}}finally{n(!1)}}),(()=>{var n=ph();return z(n,(()=>{var n=N(()=>!!e());return()=>n()?m(fh,{}):N(()=>!!t())()?m(vi,{}):m(gi,{})})()),n})()}var vh=document.getElementById(`root`);if(!vh)throw Error(`Root element not found`);he(()=>m(_h,{}),vh);export{Se as S,V as _,Uc as a,R as b,Bc as c,Ts as d,W as f,Jt as g,xn as h,Vc as i,Cs as l,pn as m,Rf as n,Wc as o,Sn as p,Kc as r,zc as s,wp as t,zs as u,F as v,P as x,z as y};
|