CLIENT v1.3
`,e.appendChild(i);let n=t.categories,o={Visual:'',Utility:'',Combat:'',Player:'',Movement:''};n.forEach(l=>{let c=document.createElement("div");c.className=`serenity-category ${l===this.activeCategory?"active":""}`;let d=o[l]||o.Utility;c.innerHTML=`
${d}
${l}
`,c.addEventListener("click",()=>{document.querySelectorAll(".serenity-category").forEach(p=>{p.classList.remove("active")}),c.classList.add("active"),this.activeCategory=l,this.activeSettingsModule=null,this.searchQuery="",this.closeHUDSettingsPopup(),this.updateContent(t)}),e.appendChild(c)});let s=document.createElement("div");s.className="serenity-sidebar-footer";let r=document.createElement("div");r.className="serenity-category serenity-hud-editor-btn",r.innerHTML=' HUD Editor',r.addEventListener("click",()=>{this.isEditingHUD=!0,this.renderHUDeditor(t)}),s.appendChild(r);let a=document.createElement("div");return a.className="serenity-category serenity-config-btn",a.innerHTML=' Settings',a.addEventListener("click",()=>{this.activeView="settings",this.updateContent(t)}),s.appendChild(a),e.appendChild(s),e},exitHUDeditor(t){if(!this.isEditingHUD)return;let e=document.querySelector(".serenity-hud-editor-overlay");e&&document.body.removeChild(e),this.isEditingHUD=!1,this.closeHUDSettingsPopup(),this.overlay&&(this.overlay.style.zIndex="1000000000"),t.list().forEach(i=>{i.enabled&&i.element&&(i.element.style.zIndex=i.name==="ArmorHUD"||i.name==="FPSCounter"||i.name==="Interface"?9997:"",i.element.style.pointerEvents="none",i.element.style.cursor="",i.element.onmousedown=null)})},renderHUDeditor(t){this.element.style.display="none",this.overlay&&(this.overlay.style.zIndex="-1");let e=document.createElement("div");e.className="serenity-hud-editor-overlay",document.body.appendChild(e);let i=document.createElement("div");i.className="serenity-hud-grid",e.appendChild(i),t.list().forEach(o=>{o.enabled&&o.element&&(o.element.style.zIndex=10001,o.element.style.pointerEvents="auto",this.makeElementDraggable(o.element,o,t))});let n=document.createElement("button");n.className="serenity-hud-done-btn",n.textContent="Done",n.addEventListener("click",()=>{this.exitHUDeditor(t),this.element.style.display="flex",this.element.style.pointerEvents="auto",this.element.style.zIndex="1000000001"}),e.appendChild(n)},makeElementDraggable(t,e,i){if(!t||e.name==="ClickGUI")return;let n=0,o=0,s=0,r=0,a=d=>{d.preventDefault(),s=d.clientX,r=d.clientY;let p=t.getBoundingClientRect();t.style.top=`${p.top}px`,t.style.left=`${p.left}px`,t.style.bottom="auto",t.style.right="auto",document.onmouseup=c,document.onmousemove=l},l=d=>{d.preventDefault(),n=s-d.clientX,o=r-d.clientY,s=d.clientX,r=d.clientY;let p=t.offsetTop-o,u=t.offsetLeft-n,h=window.innerWidth,m=window.innerHeight,g=t.offsetWidth,b=t.offsetHeight;if(u=Math.max(0,Math.min(u,h-g)),p=Math.max(0,Math.min(p,m-b)),t.style.top=`${p}px`,t.style.left=`${u}px`,this.activeHUDSettingsPopup&&this.activeHUDSettingsPopup.moduleName===e.name){let y=this.activeHUDSettingsPopup.element,f=y.offsetWidth,v=u+g+10;v+f>h&&(v=u-f-10),y.style.top=`${p}px`,y.style.left=`${v}px`}},c=()=>{document.onmouseup=null,document.onmousemove=null,i.updateModulePosition(e.name,t.offsetLeft,t.offsetTop)};t.onmousedown=a,t.oncontextmenu=d=>{d.preventDefault(),this.showHUDSettingsPopup(d,e,i,t)},t.style.cursor="move"},showHUDSettingsPopup(t,e,i,n){this.closeHUDSettingsPopup();let o=document.createElement("div");o.className="serenity-hud-settings-popup";let s=document.createElement("div");s.className="serenity-hud-popup-header";let r=document.createElement("span");r.textContent=e.name;let a=document.createElement("button");a.className="serenity-hud-popup-close-btn",a.innerHTML="×",a.onclick=()=>this.closeHUDSettingsPopup(),s.appendChild(r),s.appendChild(a),o.appendChild(s);let l=document.createElement("div");l.className="serenity-hud-popup-body",e.settings.forEach(g=>{let b=this.createSettingElement(e,g,i);b&&l.appendChild(b)}),o.appendChild(l);let c=document.createElement("div");c.className="serenity-hud-popup-footer";let d=document.createElement("button");d.className="serenity-hud-popup-reset-btn",d.textContent="Reset to Defaults",d.onclick=()=>{i.resetModuleSettings(e.name),this.showHUDSettingsPopup(t,i.get(e.name),i,n)},c.appendChild(d),o.appendChild(c),document.body.appendChild(o);let p=n.getBoundingClientRect(),u=window.innerWidth,h=o.offsetWidth,m=p.left+p.width+10;m+h>u&&(m=p.left-h-10),o.style.top=`${p.top}px`,o.style.left=`${m}px`,this.activeHUDSettingsPopup={element:o,moduleName:e.name}},closeHUDSettingsPopup(){this.activeHUDSettingsPopup&&(document.body.removeChild(this.activeHUDSettingsPopup.element),this.activeHUDSettingsPopup=null)},createContent(t){let e=document.createElement("div");return e.className="serenity-content",this.populateModulesContent(e,t),e},updateContent(t){let e=this.element.querySelector(".serenity-content");e.innerHTML="",this.activeView==="settings"?this.element.classList.add("settings-view-active"):this.element.classList.remove("settings-view-active"),this.activeSettingsModule?this.populateSettingsContent(e,t):this.activeView==="settings"?this.renderSettingsScreen(e,t):this.populateModulesContent(e,t)},renderSettingsScreen(t,e){let i=document.createElement("div");i.className="serenity-settings-header";let n=document.createElement("button");n.className="serenity-back-btn",n.innerHTML=' Back',n.addEventListener("click",()=>{this.activeView="modules",this.activeSettingsModule=null,this.updateContent(e)});let o=document.createElement("span");o.textContent="Settings",i.appendChild(n),i.appendChild(o),t.appendChild(i);let s=document.createElement("div");s.className="serenity-config-screen-content";let r=document.createElement("div");r.className="serenity-config-tabs-vertical",r.innerHTML=`
`,s.appendChild(r);let a=document.createElement("div");a.className="serenity-config-tab-content",s.appendChild(a),t.appendChild(s),r.querySelectorAll(".serenity-config-tab").forEach(l=>{l.addEventListener("click",()=>{r.querySelectorAll(".serenity-config-tab").forEach(c=>c.classList.remove("active")),l.classList.add("active"),this.activeConfigTab=l.dataset.tab,this.renderConfigContent(e)})}),this.renderConfigContent(e)},renderConfigContent(t){let e=this.element.querySelector(".serenity-config-tab-content");if(e)switch(e.innerHTML="",this.activeConfigTab){case"Themes":this.renderThemesContent(e,t);break;case"Config":this.renderConfigSubContent(e,t);break;case"Keybinds":this.renderKeybindsContent(e,t);break;case"Scripting":this.renderScriptingContent(e,t);break}},renderThemesContent(t,e){let i=document.createElement("div");i.className="serenity-theme-editor";let n=this.createSectionHeader("Accent Color","Sets the main color for UI elements.");i.appendChild(n);let o=document.createElement("div");o.className="serenity-theme-control";let s=document.createElement("input");s.type="color",s.className="serenity-theme-color-picker",s.value=getComputedStyle(document.documentElement).getPropertyValue("--primary").trim(),s.addEventListener("input",y=>{let f=y.target.value;document.documentElement.style.setProperty("--primary",f),document.documentElement.style.setProperty("--primary-dark",this.shadeColor(f,-20)),e.saveConfiguration()}),o.appendChild(s),i.appendChild(o);let r=this.createSectionHeader("Panel Style","Customize the look of UI backgrounds.");i.appendChild(r);let a=document.createElement("div");a.className="serenity-theme-panel-controls";let l=document.createElement("div");l.className="serenity-theme-control-group",l.innerHTML="";let c=document.createElement("input");c.type="color",c.className="serenity-theme-color-picker";let d=getComputedStyle(document.documentElement).getPropertyValue("--panel-base").trim();c.value=d,c.addEventListener("input",y=>{document.documentElement.style.setProperty("--panel-base",y.target.value),e.saveConfiguration()}),l.appendChild(c),a.appendChild(l);let p=document.createElement("div");p.className="serenity-theme-control-group",p.innerHTML="";let u=document.createElement("input");u.type="range",u.className="serenity-slider",u.min=0,u.max=1,u.step=.01;let h=getComputedStyle(document.documentElement).getPropertyValue("--panel-opacity").trim();u.value=h,u.addEventListener("input",y=>{document.documentElement.style.setProperty("--panel-opacity",y.target.value),e.saveConfiguration()}),p.appendChild(u),a.appendChild(p),i.appendChild(a);let m=this.createSectionHeader("Themes","Select from a pre-made color scheme.");i.appendChild(m);let g=document.createElement("div");g.className="serenity-themes-grid",[{name:"Serenity",color:"#5E72EB"},{name:"Sunset",color:"#E54B4B"},{name:"Emerald",color:"#3f9a56"},{name:"Goldenrod",color:"#cda34a"},{name:"Amethyst",color:"#9b59b6"}].forEach(y=>{let f=document.createElement("div");f.className="serenity-theme-card",f.innerHTML=`
${y.name}`,f.addEventListener("click",()=>{document.documentElement.style.setProperty("--primary",y.color),document.documentElement.style.setProperty("--primary-dark",this.shadeColor(y.color,-20)),s.value=y.color,e.saveConfiguration()}),g.appendChild(f)}),i.appendChild(g),t.appendChild(i)},renderKeybindsContent(t,e){t.innerHTML="";let i=e.keybindManager,n=document.createElement("div");n.className="serenity-keybind-editor";let o=this.createSectionHeader("Module Keybinds","Click a key to set a new bind. Press ESC to cancel, or Backspace/Delete to unbind.");n.appendChild(o);let s=document.createElement("div");s.className="serenity-keybind-list",e.list().filter(a=>a.name!=="ClickGUI").sort((a,l)=>a.name.localeCompare(l.name)).forEach(a=>{let l=document.createElement("div");l.className="serenity-keybind-item";let c=document.createElement("span");c.className="serenity-keybind-name",c.textContent=a.name;let d=document.createElement("button");d.className="serenity-keybind-button";let p=i.getBind(a.name);d.textContent=p?this.formatKeyCode(p):"None",d.onclick=()=>{document.querySelectorAll(".serenity-keybind-button").forEach(u=>u.disabled=!0),d.textContent="[...]",d.classList.add("binding"),d.disabled=!1,i.startBinding(a.name,()=>{this.renderKeybindsContent(t,e)})},l.appendChild(c),l.appendChild(d),s.appendChild(l)}),n.appendChild(s),t.appendChild(n)},formatKeyCode(t){return t.startsWith("Key")?t.substring(3):t.startsWith("Digit")?t.substring(5):t.startsWith("Numpad")?`Num ${t.substring(6)}`:t},createSectionHeader(t,e){let i=document.createElement("div");return i.className="serenity-section-subheader",i.innerHTML=`
${t}
${e}
`,i},renderConfigSubContent(t,e){let i=document.createElement("div");i.className="serenity-config-editor";let n=document.createElement("div");n.className="serenity-config-column";let o=this.createSectionHeader("General","Manage how your configuration is handled.");n.appendChild(o);let s=document.createElement("div");s.className="serenity-config-controls-grid";let r=this.createToggleSetting("Auto Save","Automatically save changes.",e.autoSave,f=>{e.autoSave=f,e.forceSaveConfiguration()});s.appendChild(r);let a=this.createToggleSetting("Auto Load","Load config on startup.",e.autoLoad,f=>{e.autoLoad=f,e.forceSaveConfiguration()});s.appendChild(a),n.appendChild(s);let l=this.createSectionHeader("Manual Control","Manually save or load the current config.");n.appendChild(l);let c=document.createElement("div");c.className="serenity-config-manual-buttons";let d=document.createElement("button");d.className="serenity-btn",d.textContent="Force Save",d.onclick=()=>{e.forceSaveConfiguration(),d.textContent="Saved!",setTimeout(()=>{d.textContent="Force Save"},2e3)},c.appendChild(d);let p=document.createElement("button");p.className="serenity-btn",p.textContent="Force Load",p.onclick=()=>e.loadConfiguration(),c.appendChild(p);let u=document.createElement("button");u.className="serenity-btn serenity-btn-danger",u.textContent="Reset All",u.onclick=()=>{confirm("Are you sure you want to reset all settings to their defaults? This action cannot be undone.")&&(e.loadConfiguration({}),setTimeout(()=>{window.location.reload()},500))},c.appendChild(u),n.appendChild(c),i.appendChild(n);let h=document.createElement("div");h.className="serenity-config-column";let m=this.createSectionHeader("Import / Export","Share your configuration with others.");h.appendChild(m);let g=document.createElement("div");g.className="serenity-import-export-buttons";let b=document.createElement("button");b.className="serenity-btn serenity-btn-primary",b.innerHTML=' Import from File',b.onclick=()=>{let f=document.createElement("input");f.type="file",f.accept=".json",f.onchange=v=>{let C=v.target.files[0];if(!C)return;let w=new FileReader;w.onload=x=>{try{e.importConfiguration(x.target.result),alert("Configuration imported successfully!")}catch{alert("Failed to import configuration. The file may be corrupt or improperly formatted.")}},w.readAsText(C)},f.click()};let y=document.createElement("button");y.className="serenity-btn",y.innerHTML=' Export to File',y.onclick=()=>{let f=e.exportConfiguration(),v=JSON.stringify(f,null,2);navigator.clipboard.writeText(v).then(()=>{this.notifications.show({title:"Config Exported",message:"Configuration copied to clipboard.",type:"success"})});let C=new Blob([v],{type:"application/json"}),w=URL.createObjectURL(C),x=document.createElement("a");x.href=w,x.download="serenity-config.json",document.body.appendChild(x),x.click(),document.body.removeChild(x),URL.revokeObjectURL(w)},g.appendChild(b),g.appendChild(y),h.appendChild(g),i.appendChild(h),t.appendChild(i)},renderScriptingContent(t,e){t.innerHTML='
Scripting coming soon...
'},shadeColor(t,e){let i=parseInt(t.substring(1,3),16),n=parseInt(t.substring(3,5),16),o=parseInt(t.substring(5,7),16);i=parseInt(i*(100+e)/100),n=parseInt(n*(100+e)/100),o=parseInt(o*(100+e)/100),i=i<255?i:255,n=n<255?n:255,o=o<255?o:255;let s=i.toString(16).length==1?"0"+i.toString(16):i.toString(16),r=n.toString(16).length==1?"0"+n.toString(16):n.toString(16),a=o.toString(16).length==1?"0"+o.toString(16):o.toString(16);return"#"+s+r+a},populateModulesContent(t,e){let i=document.createElement("div");i.className="serenity-section-header";let n=document.createElement("span");n.textContent=this.activeCategory;let o=document.createElement("input");o.type="text",o.className="serenity-search-bar",o.placeholder="Search...",o.value=this.searchQuery,o.addEventListener("input",r=>{this.searchQuery=r.target.value,this.filterAndRenderModules(e)}),i.appendChild(n),i.appendChild(o),t.appendChild(i);let s=document.createElement("div");s.className="serenity-modules",t.appendChild(s),this.filterAndRenderModules(e)},filterAndRenderModules(t){let e=this.element.querySelector(".serenity-modules");if(!e)return;e.innerHTML="",t.getModulesByCategory(this.activeCategory).filter(o=>o.name.toLowerCase().includes(this.searchQuery.toLowerCase())).forEach(o=>{let s=this.createModuleCard(o,t);e.appendChild(s)})},createModuleCard(t,e){let i=document.createElement("div");i.className="serenity-module";let n=document.createElement("div");n.className="serenity-module-header";let o=document.createElement("div");o.className="serenity-module-name",o.textContent=t.name,n.appendChild(o);let s=document.createElement("div");if(s.className="serenity-module-controls",t.settings.length>0){let a=document.createElement("button");a.className="serenity-module-settings-btn",a.innerHTML='',a.addEventListener("click",l=>{l.stopPropagation(),this.activeSettingsModule=t,this.updateContent(e)}),s.appendChild(a)}let r=document.createElement("div");if(r.className=`serenity-module-toggle ${t.enabled?"enabled":""}`,r.innerHTML='',r.addEventListener("click",()=>{e.toggle(t.name),r.classList.toggle("enabled")}),s.appendChild(r),n.appendChild(s),i.appendChild(n),t.description){let a=document.createElement("div");a.className="serenity-module-description",a.textContent=t.description,i.appendChild(a)}return i},populateSettingsContent(t,e){let i=this.activeSettingsModule;if(!i)return;let n=document.createElement("div");n.className="serenity-section";let o=document.createElement("div");o.className="serenity-settings-header";let s=document.createElement("button");s.className="serenity-back-btn",s.innerHTML=' Back',s.addEventListener("click",()=>{this.activeSettingsModule=null,this.updateContent(e)});let r=document.createElement("span");r.textContent=`${i.name} Settings`,o.appendChild(s),o.appendChild(r),n.appendChild(o);let a=document.createElement("div");a.className="serenity-module-settings",i.name==="Waypoint"?this.renderWaypointManager(a,e):i.name==="Nametags"?i.renderNametagManager(a,e):i.settings.forEach(l=>{let c=this.createSettingElement(i,l,e);if(c){if(l.condition){let d=l.condition(i.settings.reduce((p,u)=>({...p,[u.id]:u.value}),{}));c.style.display=d?"":"none"}a.appendChild(c)}}),n.appendChild(a),t.appendChild(n)},renderWaypointManager(t,e){t.innerHTML="";let i=e.get("Waypoint");if(!i)return;let n=document.createElement("div");n.className="serenity-waypoint-general-settings",i.settings.filter(l=>l.type!=="info").forEach(l=>{let c=this.createSettingElement(i,l,e);n.appendChild(c)}),t.appendChild(n);let o=document.createElement("div");o.className="serenity-waypoint-actions";let s=document.createElement("button");s.className="serenity-btn serenity-btn-primary",s.textContent="Add at Current Location",s.onclick=()=>{let l=i.getCurrentPlayerPosition();l?(i.addWaypoint({...l}),this.renderWaypointManager(t,e)):alert("Could not get player position.")};let r=document.createElement("button");r.className="serenity-btn",r.textContent="Create Manually",r.onclick=()=>{i.addWaypoint({}),this.renderWaypointManager(t,e)},o.appendChild(s),o.appendChild(r),t.appendChild(o);let a=document.createElement("div");a.className="serenity-waypoint-list",i.getWaypoints().forEach(l=>{let c=document.createElement("div");c.className="serenity-waypoint-item";let d=document.createElement("div");d.className="serenity-waypoint-color-preview",d.style.backgroundColor=l.color;let p=document.createElement("div");p.className="serenity-waypoint-info",p.innerHTML=`
${l.title}X: ${l.x}, Y: ${l.y}, Z: ${l.z}
`;let u=document.createElement("div");u.className="serenity-waypoint-controls";let h=document.createElement("input");h.type="checkbox",h.className="serenity-checkbox",h.checked=l.enabled,h.onchange=b=>{i.updateWaypoint(l.id,{enabled:b.target.checked})};let m=document.createElement("button");m.innerHTML='',m.onclick=()=>this.showWaypointEditPopup(l,e);let g=document.createElement("button");g.innerHTML='',g.onclick=()=>{confirm(`Are you sure you want to delete "${l.title}"?`)&&(i.removeWaypoint(l.id),this.renderWaypointManager(t,e))},u.appendChild(h),u.appendChild(m),u.appendChild(g),c.appendChild(d),c.appendChild(p),c.appendChild(u),a.appendChild(c)}),t.appendChild(a)},showWaypointEditPopup(t,e){let i=e.get("Waypoint"),n=document.createElement("div");n.className="serenity-config-popup",n.innerHTML=`
Edit Waypoint
`;let o=document.createElement("div");o.className="serenity-overlay visible",o.style.zIndex="10001",document.body.appendChild(o),document.body.appendChild(n);let s=()=>{document.body.removeChild(n),document.body.removeChild(o),this.updateContent(e)};n.querySelector("#wp-save").onclick=()=>{let r={title:n.querySelector("#wp-title").value,x:n.querySelector("#wp-x").value,y:n.querySelector("#wp-y").value,z:n.querySelector("#wp-z").value,color:n.querySelector("#wp-color").value};i.updateWaypoint(t.id,r),s()},n.querySelector("#wp-cancel").onclick=s},createSettingElement(t,e,i){let n=document.createElement("div");n.className="serenity-setting",n.dataset.settingId=e.id;let o=document.createElement("div");o.className="serenity-setting-info";let s=document.createElement("label");if(s.className="serenity-setting-label",s.textContent=e.name,o.appendChild(s),e.description){let a=document.createElement("p");a.className="serenity-setting-description",a.textContent=e.description,o.appendChild(a)}n.appendChild(o);let r=document.createElement("div");switch(r.className="serenity-setting-control",e.type){case"boolean":let a=document.createElement("input");a.type="checkbox",a.checked=e.value,a.className="serenity-checkbox",a.addEventListener("change",u=>{i.updateModuleSetting(t.name,e.id,u.target.checked),this.updateConditionalSettings(t,i)}),r.appendChild(a);break;case"slider":let l=document.createElement("input");l.type="range",l.min=e.min,l.max=e.max,l.step=e.step,l.value=e.value,l.className="serenity-slider",l.addEventListener("input",u=>{i.updateModuleSetting(t.name,e.id,parseFloat(u.target.value))}),r.appendChild(l);break;case"select":let c=document.createElement("select");c.className="serenity-select",e.options.forEach(u=>{let h=document.createElement("option");h.value=u,h.textContent=u,e.value===u&&(h.selected=!0),c.appendChild(h)}),c.addEventListener("change",u=>{i.updateModuleSetting(t.name,e.id,u.target.value),this.updateConditionalSettings(t,i)}),r.appendChild(c);break;case"text":let d=document.createElement("input");d.type="text",d.value=e.value,d.className="serenity-text-input",d.addEventListener("change",u=>{i.updateModuleSetting(t.name,e.id,u.target.value)}),r.appendChild(d);break;case"color":let p=this.createColorPicker(t,e,i);r.appendChild(p);break}return n.appendChild(r),n},updateConditionalSettings(t,e){let i=t.settings.reduce((o,s)=>({...o,[s.id]:s.value}),{}),n=this.element.querySelector(".serenity-module-settings");t.settings.forEach(o=>{if(o.condition){let s=n.querySelector(`[data-setting-id="${o.id}"]`);s&&(s.style.display=o.condition(i)?"":"none")}})},createColorPicker(t,e,i){let n=document.createElement("div");n.className="serenity-color-picker-wrapper";let o=document.createElement("div");o.className="serenity-color-swatch",o.style.color=e.value;let s=this.createColorPopup(t,e,i,o);return o.addEventListener("click",r=>{r.stopPropagation();let a=document.querySelector(".serenity-color-popup");a&&a!==s&&a.remove(),document.querySelector(".serenity-color-popup")===s?s.remove():n.appendChild(s)}),n.appendChild(o),document.addEventListener("click",r=>{n.contains(r.target)||s.remove()}),n},createColorPopup(t,e,i,n){let o=document.createElement("div");o.className="serenity-color-popup";let s=document.createElement("input");s.type="color",s.value=this.rgbaToHex(e.value).hex;let r=document.createElement("input");r.type="range",r.className="serenity-slider",r.min=0,r.max=1,r.step=.01,r.value=this.rgbaToHex(e.value).alpha;let a=()=>{let l=s.value,c=parseFloat(r.value),d=this.hexToRgba(l,c);n.style.color=d,i.updateModuleSetting(t.name,e.id,d)};return s.addEventListener("input",a),r.addEventListener("input",a),o.appendChild(s),o.appendChild(r),o},hexToRgba(t,e){let i=parseInt(t.slice(1,3),16),n=parseInt(t.slice(3,5),16),o=parseInt(t.slice(5,7),16);return`rgba(${i}, ${n}, ${o}, ${e})`},rgbaToHex(t){if(t.startsWith("#"))return{hex:t,alpha:1};let e=t.match(/[\d.]+/g);if(!e||e.length<3)return{hex:"#000000",alpha:1};let i=parseInt(e[0]).toString(16).padStart(2,"0"),n=parseInt(e[1]).toString(16).padStart(2,"0"),o=parseInt(e[2]).toString(16).padStart(2,"0"),s=e.length>=4?parseFloat(e[3]):1;return{hex:`#${i}${n}${o}`,alpha:s}},createToggleSetting(t,e,i,n){let o=document.createElement("div");o.className="serenity-config-toggle-setting";let s=document.createElement("div");s.className="serenity-setting-info";let r=document.createElement("label");r.className="serenity-setting-label",r.textContent=t;let a=document.createElement("p");a.className="serenity-setting-description",a.textContent=e,s.appendChild(r),s.appendChild(a);let l=document.createElement("div");l.className="serenity-setting-control";let c=document.createElement("input");return c.type="checkbox",c.checked=i,c.className="serenity-checkbox",c.addEventListener("change",d=>{n(d.target.checked)}),l.appendChild(c),o.appendChild(s),o.appendChild(l),o}},P=ye;var M=null;function q(){if(M)return M;let t=document.querySelectorAll(".ChatMessages .IndividualText"),e=Array.from(t).filter(i=>i.textContent?.includes(" joined"));if(e.length>0){let o=e[e.length-1].textContent.split(" joined")[0].trim();if(o)return M=o,o}return null}function W(t,e=20){let i=Date.now()/e;return`hsl(${(t*15+i)%360}, 90%, 65%)`}var ge={name:"Chat",category:"Visual",description:"Replaces the default in-game chat with a customizable one.",enabled:!0,defaultX:4,defaultY:59,element:null,gameChat:null,chatObserver:null,mainObserver:null,customInput:null,settings:[{id:"hide-game-chat",name:"Hide Game Chat",type:"boolean",value:!0,description:"Hides the original in-game chat UI."},{id:"font-size",name:"Font Size",type:"slider",value:14,min:10,max:24,step:1},{id:"max-messages",name:"Max Messages",type:"slider",value:7,min:5,max:25,step:1},{id:"show-timestamps",name:"Show Timestamps",type:"boolean",value:!1}],onEnable(){this.createDisplay(),this.handleGameChat(),this.mainObserver=new MutationObserver(()=>this.handleGameChat()),this.mainObserver.observe(document.body,{childList:!0,subtree:!0})},onDisable(){this.mainObserver&&this.mainObserver.disconnect(),this.chatObserver&&this.chatObserver.disconnect(),this.restoreGameChat(),this.destroyDisplay()},onTick(){this.handleGameChat()},onFrame(){if(this.element){let t=window.Serenity.instance.get("ClickGUI");if(!t||!t.isEditingHUD){let e=window.Serenity.instance.get(this.name);e.x!==null&&(this.element.style.left=`${e.x}px`),e.y!==null&&(this.element.style.top=`${e.y}px`)}}},onSettingUpdate(){this.applyStyles(),this.handleGameChat()},createDisplay(){this.element=document.createElement("div"),this.element.className="serenity-chat-container",this.element.style.zIndex=5,document.body.appendChild(this.element);let t=document.createElement("div");t.className="serenity-chat-messages",this.element.appendChild(t),this.createCustomInput()},createCustomInput(){let t=document.createElement("div");t.className="serenity-chat-input-wrapper",this.customInput=document.createElement("input"),this.customInput.type="text",this.customInput.className="serenity-chat-input",this.customInput.placeholder="Send a message...",this.customInput.addEventListener("keydown",e=>{if(e.key==="Enter"){let i=document.querySelector(".ChatInput");if(i&&this.customInput.value){i.value=this.customInput.value;let n=new KeyboardEvent("keydown",{key:"Enter",code:"Enter",which:13,keyCode:13,bubbles:!0});i.dispatchEvent(n),this.customInput.value=""}}}),t.appendChild(this.customInput),this.element.appendChild(t)},syncInputVisibility(t){let e=this.element.querySelector(".serenity-chat-input-wrapper");t.style.display==="none"?e.style.display="none":(e.style.display="flex",setTimeout(()=>this.customInput.focus(),0))},destroyDisplay(){this.element&&(document.body.removeChild(this.element),this.element=null)},handleGameChat(){let t=document.querySelector(".Chat");if(!t){this.chatObserver&&(this.chatObserver.disconnect(),this.chatObserver=null),this.gameChat=null;return}this.gameChat!==t&&(this.chatObserver&&(this.chatObserver.disconnect(),this.chatObserver=null),this.gameChat=t,this.element&&(this.element.querySelector(".serenity-chat-messages").innerHTML=""));let e=this.settings.find(o=>o.id==="hide-game-chat").value;this.gameChat.style.visibility=e?"hidden":"visible",this.gameChat.style.pointerEvents=e?"none":"auto";let i=t.querySelector(".ChatMessages");i&&!this.chatObserver&&(this.element.querySelector(".serenity-chat-messages").innerHTML="",i.querySelectorAll(".MessageWrapper").forEach(o=>this.addMessage(o)),this.chatObserver=new MutationObserver(o=>{o.forEach(s=>{s.addedNodes.length&&s.addedNodes.forEach(r=>{r.nodeType===1&&r.classList.contains("MessageWrapper")&&this.addMessage(r)})})}),this.chatObserver.observe(i,{childList:!0}));let n=t.querySelector(".ChatInputWrapper");n&&this.syncInputVisibility(n)},restoreGameChat(){this.gameChat&&(this.gameChat.style.visibility="visible",this.gameChat.style.pointerEvents="auto")},addMessage(t){if(!this.element)return;let e=this.element.querySelector(".serenity-chat-messages"),i=document.createElement("div");i.className="serenity-chat-message";let n=document.createElement("div");n.className="serenity-message-content";let o=q();if(t.querySelectorAll(".IndividualText").forEach(r=>{let a=r.cloneNode(!0);o&&a.textContent===o&&a.classList.add("serenity-message-own-name"),/^\[.*\]$/.test(a.textContent)&&a.classList.add("serenity-message-tag"),n.appendChild(a)}),i.appendChild(n),this.settings.find(r=>r.id==="show-timestamps").value){let r=document.createElement("span");r.className="serenity-message-timestamp",r.textContent=new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),i.insertBefore(r,n)}e.appendChild(i);let s=this.settings.find(r=>r.id==="max-messages").value;for(;e.children.length>s;)e.removeChild(e.firstChild)},applyStyles(){if(!this.element)return;let t=this.settings.reduce((e,i)=>({...e,[i.id]:i.value}),{});this.element.style.setProperty("--chat-font-size",`${t["font-size"]}px`)}},O=ge;var fe={name:"Keystrokes",category:"Combat",description:"Displays your keystrokes with a sexy, modern look.",enabled:!0,defaultX:8,defaultY:562,element:null,keys:{w:!1,a:!1,s:!1,d:!1," ":!1,lmb:!1,rmb:!1},boundKeyDown:null,boundKeyUp:null,boundMouseDown:null,boundMouseUp:null,settings:[{id:"show-mouse",name:"Show Mouse Buttons",type:"boolean",value:!0},{id:"scale",name:"Scale",type:"slider",value:1,min:.5,max:2,step:.1},{id:"opacity",name:"Opacity",type:"slider",value:.85,min:0,max:1,step:.05},{id:"enable-animations",name:"Enable Animations",type:"boolean",value:!0}],onEnable(){this.createDisplay(),this.applyStyles(),this.boundKeyDown=t=>this.updateKeyState(t.key.toLowerCase(),!0),this.boundKeyUp=t=>this.updateKeyState(t.key.toLowerCase(),!1),this.boundMouseDown=t=>{t.button===0&&this.updateKeyState("lmb",!0),t.button===2&&this.updateKeyState("rmb",!0)},this.boundMouseUp=t=>{t.button===0&&this.updateKeyState("lmb",!1),t.button===2&&this.updateKeyState("rmb",!1)},window.addEventListener("keydown",this.boundKeyDown),window.addEventListener("keyup",this.boundKeyUp),window.addEventListener("mousedown",this.boundMouseDown),window.addEventListener("mouseup",this.boundMouseUp)},onDisable(){this.destroyDisplay(),window.removeEventListener("keydown",this.boundKeyDown),window.removeEventListener("keyup",this.boundKeyUp),window.removeEventListener("mousedown",this.boundMouseDown),window.removeEventListener("mouseup",this.boundMouseUp)},onTick(){this.updateDisplayLocation()},onSettingUpdate(){this.applyStyles()},updateKeyState(t,e){this.keys.hasOwnProperty(t)&&(this.keys[t]=e,this.updateKeyVisuals())},createKey(t,e,...i){let n=document.createElement("div");return n.className=`keystrokes-key key-${e} ${i.join(" ")}`,n.textContent=t,n},createDisplay(){this.element=document.createElement("div"),this.element.className="keystrokes-display";let t=document.createElement("div");t.className="keystrokes-row",t.appendChild(this.createKey("W","w")),this.element.appendChild(t);let e=document.createElement("div");e.className="keystrokes-row",e.appendChild(this.createKey("A","a")),e.appendChild(this.createKey("S","s")),e.appendChild(this.createKey("D","d")),this.element.appendChild(e);let i=document.createElement("div");i.className="keystrokes-row mouse-row",i.appendChild(this.createKey("LMB","lmb","mouse-button")),i.appendChild(this.createKey("RMB","rmb","mouse-button")),this.element.appendChild(i);let n=document.createElement("div");n.className="keystrokes-row",n.appendChild(this.createKey("Space"," ","space-key")),this.element.appendChild(n),document.body.appendChild(this.element)},destroyDisplay(){this.element&&(document.body.removeChild(this.element),this.element=null)},updateDisplayLocation(){if(!this.element)return;let t=window.Serenity.instance.get("ClickGUI");if(!t||!t.isEditingHUD){let e=window.Serenity.instance.get(this.name);e.x!==null&&(this.element.style.left=`${e.x}px`),e.y!==null&&(this.element.style.top=`${e.y}px`)}},updateKeyVisuals(){if(this.element)for(let t in this.keys){let e=this.element.querySelector(`.key-${t}`);e&&e.classList.toggle("active",this.keys[t])}},applyStyles(){if(!this.element)return;let t=this.settings.reduce((e,i)=>({...e,[i.id]:i.value}),{});this.element.style.transform=`scale(${t.scale})`,this.element.style.opacity=t.opacity,this.element.classList.toggle("show-mouse",t["show-mouse"]),this.element.classList.toggle("no-animations",!t["enable-animations"])}},R=fe;var be={name:"ToggleSprint",category:"Movement",description:"Automatically sprints for you by simulating a Shift key press.",enabled:!0,sprinting:!1,sprintInterval:null,element:null,defaultX:"80%",defaultY:"80%",settings:[{id:"show-text",name:"Show Text",type:"boolean",value:!0},{id:"color-mode",name:"Color Mode",type:"select",options:["Theme","Custom"],value:"Theme",condition:t=>t["show-text"]},{id:"hud-text",name:"HUD Text",type:"text",value:"[Sprinting (Toggled)]",condition:t=>t["show-text"]},{id:"bg-color",name:"Background Color",type:"color",value:"rgba(30, 33, 41, 0.85)",condition:t=>t["show-text"]&&t["color-mode"]==="Custom"},{id:"text-color",name:"Text Color",type:"color",value:"rgba(234, 234, 234, 0.8)",condition:t=>t["show-text"]&&t["color-mode"]==="Custom"},{id:"font-size",name:"Font Size",type:"slider",value:16,min:8,max:24,step:1,condition:t=>t["show-text"]},{id:"padding",name:"Padding",type:"slider",value:8,min:0,max:20,step:1,condition:t=>t["show-text"]},{id:"border-radius",name:"Border Radius",type:"slider",value:10,min:0,max:20,step:1,condition:t=>t["show-text"]},{id:"border-width",name:"Border Width",type:"slider",value:1,min:0,max:5,step:1,condition:t=>t["show-text"]},{id:"border-color",name:"Border Color",type:"color",value:"rgba(255, 255, 255, 0.07)",condition:t=>t["show-text"]&&t["color-mode"]==="Custom"}],onEnable(){this.createDisplay()},onDisable(){this.sprinting&&this.stopSprinting(),this.destroyDisplay()},onTick(){let t=window.Serenity.instance.get("ClickGUI"),i=!(document.activeElement&&(["INPUT","TEXTAREA"].includes(document.activeElement.tagName)||document.activeElement.isContentEditable))&&(!t||!t.isGuiOpen);i&&!this.sprinting?this.startSprinting():!i&&this.sprinting&&this.stopSprinting(),i&&this.sprinting&&this.fireKeyDown(),this.updateDisplay()},onSettingUpdate(){this.applyStyles(),this.updateDisplay(!0)},startSprinting(){this.sprinting||(this.sprinting=!0,this.fireKeyDown(),this.sprintInterval=setInterval(()=>this.fireKeyDown(),200))},stopSprinting(){this.sprinting&&(this.sprinting=!1,this.sprintInterval&&(clearInterval(this.sprintInterval),this.sprintInterval=null),window.dispatchEvent(new KeyboardEvent("keyup",{key:"Shift",keyCode:16,code:"ShiftLeft",bubbles:!0})))},fireKeyDown(){window.dispatchEvent(new KeyboardEvent("keydown",{key:"Shift",keyCode:16,code:"ShiftLeft",bubbles:!0,repeat:!0}))},createDisplay(){this.element=document.createElement("div"),this.element.className="togglesprint-hud-display",document.body.appendChild(this.element),this.applyStyles()},destroyDisplay(){this.element&&(document.body.removeChild(this.element),this.element=null)},updateDisplay(){let t=this.settings.reduce((e,i)=>({...e,[i.id]:i.value}),{});if(!t["show-text"]){this.element&&(this.element.style.display="none");return}if(this.element||this.createDisplay(),this.element.style.display=this.enabled?"block":"none",this.enabled){this.element.textContent=t["hud-text"];let e=window.Serenity.instance.get("ClickGUI");if(!e||!e.isEditingHUD){let i=window.Serenity.instance.get(this.name);i.x!==null&&(this.element.style.left=typeof i.x=="string"?i.x:`${i.x}px`),i.y!==null&&(this.element.style.top=typeof i.y=="string"?i.y:`${i.y}px`)}}},applyStyles(){if(!this.element)return;let t=this.settings.reduce((e,i)=>({...e,[i.id]:i.value}),{});t["color-mode"]==="Theme"?(this.element.style.backgroundColor="var(--panel)",this.element.style.color="var(--text)",this.element.style.border=`${t["border-width"]}px solid var(--border)`):(this.element.style.backgroundColor=t["bg-color"],this.element.style.color=t["text-color"],this.element.style.border=`${t["border-width"]}px solid ${t["border-color"]}`),this.element.style.fontSize=`${t["font-size"]}px`,this.element.style.padding=`${t.padding}px`,this.element.style.borderRadius=`${t["border-radius"]}px`,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.style.pointerEvents="none",this.element.style.zIndex=5}},G=be;var ve={name:"ArmorHUD",category:"Player",description:"Displays your currently equipped armor and selected item.",enabled:!1,observer:null,defaultX:"90%",defaultY:"50%",settings:[{id:"color-mode",name:"Color Mode",type:"select",options:["Theme","Custom"],value:"Theme"},{id:"show-selected",name:"Show Selected Item",type:"boolean",value:!0},{id:"display-style",name:"Display Style",type:"select",options:["Horizontal","Vertical"],value:"Vertical"},{id:"bg-color",name:"Background Color",type:"color",value:"rgba(30, 33, 41, 0.85)",condition:t=>t["color-mode"]==="Custom"},{id:"padding",name:"Padding",type:"slider",value:4,min:0,max:20,step:1},{id:"border-radius",name:"Border Radius",type:"slider",value:20,min:0,max:20,step:1},{id:"border-width",name:"Border Width",type:"slider",value:2,min:0,max:5,step:1},{id:"border-color",name:"Border Color",type:"color",value:"rgba(255, 255, 255, 0.07)",condition:t=>t["color-mode"]==="Custom"},{id:"item-size",name:"Item Size",type:"slider",value:64,min:16,max:64,step:1},{id:"item-spacing",name:"Item Spacing",type:"slider",value:0,min:0,max:20,step:1}],element:null,onEnable(){this.createDisplay(),this.applyStyles(),this.setupObserver()},onDisable(){this.observer&&(this.observer.disconnect(),this.observer=null),this.destroyDisplay()},onTick(){this.updateDisplay()},onSettingUpdate(){this.applyStyles(),this.updateDisplay(!0)},setupObserver(){let t=()=>{let e=document.querySelector(".HotBarGameItemsContainer");e&&!this.observer?(this.observer=new MutationObserver(i=>{i.some(o=>o.type==="attributes"&&o.attributeName==="class"&&o.target.classList.contains("InvenItem"))&&this.updateDisplay(!0)}),this.observer.observe(e,{attributes:!0,subtree:!0,attributeFilter:["class"]}),this.updateDisplay(!0)):e||setTimeout(t,500)};t()},createDisplay(){this.element=document.createElement("div"),this.element.className="armor-hud-display",document.body.appendChild(this.element)},destroyDisplay(){this.element&&(document.body.removeChild(this.element),this.element=null)},extractImage(t){if(!t)return null;let e=t.querySelector(".TwoDImageIcon");if(e){if(e.style.backgroundImage&&e.style.backgroundImage!=="none")return{type:"image",src:e.style.backgroundImage.slice(5,-2),filter:null};let o=t.querySelector(".TwoDItemGrayscaleVisiblePng"),s=t.querySelector(".TwoDItemGrayscale");if(o)return{type:"image",src:o.src,filter:s?s.style.filter:""}}let i=t.querySelector(".BlockItem");if(i&&i.style.backgroundImage&&i.style.backgroundImage!=="none")return{type:"image",src:i.style.backgroundImage.slice(5,-2),filter:null};let n=t.querySelector(".InvenItemUnfilled");return n?{type:"unfilled",src:n.style.backgroundImage.slice(5,-2)}:null},updateDisplay(t=!1){if(!this.element)return;let e=window.Serenity.instance.get("ClickGUI");if(!e||!e.isEditingHUD){let c=window.Serenity.instance.get(this.name);c.x!==null&&(this.element.style.left=typeof c.x=="string"?c.x:`${c.x}px`),c.y!==null&&(this.element.style.top=typeof c.y=="string"?c.y:`${c.y}px`)}let i=document.querySelector(".ArmourItemSlots"),o=(i?Array.from(i.querySelectorAll(".InvenItem")):[]).map(c=>this.extractImage(c)).filter(Boolean),r=window.Serenity.instance.get(this.name).settings.find(c=>c.id==="show-selected").value,a=[...o];if(r){let c=document.querySelector(".HotBarGameItemsContainer .InvenItem.Selected"),d=this.extractImage(c);d&&a.push(d)}let l=JSON.stringify(a);(l!==this.lastContentHash||t)&&(this.element.innerHTML="",a.forEach(c=>{if(!c)return;let d=document.createElement("div");if(d.style.position="relative",c.type==="image"&&c.filter){let p=this.settings.find(g=>g.id==="item-size").value,u=document.createElement("div");u.style.position="absolute",u.style.width="100%",u.style.height="100%",u.style.overflow="hidden";let h=document.createElement("img");h.src=c.src,h.style.width="100%",h.style.height="100%",h.style.imageRendering="pixelated",h.style.filter=c.filter.replace("1em",`${p}px`),h.style.marginLeft=`-${p}px`,u.appendChild(h),d.appendChild(u);let m=document.createElement("img");m.src=c.src,m.style.position="absolute",m.style.width="100%",m.style.height="100%",m.style.imageRendering="pixelated",m.style.mixBlendMode="multiply",d.appendChild(m)}else{let p=document.createElement("img");p.src=c.src,p.style.width="100%",p.style.height="100%",p.style.imageRendering="pixelated",d.appendChild(p)}this.element.appendChild(d)}),this.lastContentHash=l,this.applyStyles())},applyStyles(){if(!this.element)return;let t=this.settings.reduce((n,o)=>({...n,[o.id]:o.value}),{});t["color-mode"]==="Theme"?(this.element.style.backgroundColor="var(--panel)",this.element.style.border=`${t["border-width"]}px solid var(--border)`):(this.element.style.backgroundColor=t["bg-color"],this.element.style.border=`${t["border-width"]}px solid ${t["border-color"]}`),this.element.style.padding=`${t.padding}px`,this.element.style.borderRadius=`${t["border-radius"]}px`,this.element.style.display="flex",this.element.style.flexDirection=t["display-style"]==="Horizontal"?"row":"column",this.element.style.gap=`${t["item-spacing"]}px`,this.element.style.position="absolute",this.element.style.userSelect="none";let e=window.Serenity.instance.get("ClickGUI");(!e||!e.isEditingHUD)&&(this.element.style.zIndex=5),this.element.style.pointerEvents="none",this.element.querySelectorAll(".armor-hud-display > div").forEach(n=>{n.style.width=`${t["item-size"]}px`,n.style.height=`${t["item-size"]}px`})}},j=ve;var xe={name:"CPSCounter",category:"Player",description:"Displays your clicks per second.",enabled:!0,settings:[{id:"text-color",name:"Text Color",type:"color",value:"#EAEAEA"},{id:"show-label",name:"Show Label",type:"boolean",value:!0},{id:"show-lmb",name:"Show LMB",type:"boolean",value:!0},{id:"show-rmb",name:"Show RMB",type:"boolean",value:!0},{id:"format",name:"Text Format",type:"text",value:"{label} {lmb} | {rmb}"}],leftClicks:[],rightClicks:[],element:null,positionInterval:null,onEnable(){this.createDisplay(),this.applyStyles(),this.startPositioning(),document.addEventListener("mousedown",this.handleMouseDown.bind(this))},onDisable(){this.destroyDisplay(),document.removeEventListener("mousedown",this.handleMouseDown.bind(this)),this.positionInterval&&clearInterval(this.positionInterval)},onTick(){let t=performance.now();this.leftClicks=this.leftClicks.filter(e=>t-e<1e3),this.rightClicks=this.rightClicks.filter(e=>t-e<1e3),this.updateDisplay()},onSettingUpdate(){this.applyStyles(),this.updateDisplay()},handleMouseDown(t){t.button===0?this.leftClicks.push(performance.now()):t.button===2&&this.rightClicks.push(performance.now())},createDisplay(){this.element=document.createElement("div"),this.element.className="cps-counter-display",document.body.appendChild(this.element)},destroyDisplay(){this.element&&(document.body.removeChild(this.element),this.element=null)},updateDisplay(){if(!this.element)return;let t=this.settings.reduce((i,n)=>({...i,[n.id]:n.value}),{}),e=t.format;e=e.replace("{label}",t["show-label"]?"CPS:":""),e=e.replace("{lmb}",t["show-lmb"]?this.leftClicks.length:"0"),e=e.replace("{rmb}",t["show-rmb"]?this.rightClicks.length:"0"),this.element.textContent=e.trim()},startPositioning(){this.positionInterval=setInterval(()=>{if(!this.element)return;let t=document.querySelector(".FpsWrapperDiv"),e=document.querySelectorAll(".CoordinateUI"),i=document.querySelector(".InGameHeader");if(!i)return;let n=t&&window.getComputedStyle(t).display!=="none",o=Array.from(e).filter(r=>window.getComputedStyle(r).display!=="none"),s=null;o.length>0?s=o.reduce((r,a)=>{let l=a.getBoundingClientRect();return!r||l.right>r.right?l:r},null):n?s=t.getBoundingClientRect():s=i.getBoundingClientRect(),s&&(this.element.style.top=`${s.top+window.scrollY}px`,this.element.style.left=`${s.right+window.scrollX+5}px`,this.element.style.display="block")},200)},applyStyles(){if(!this.element)return;let t=this.settings.reduce((e,i)=>({...e,[i.id]:i.value}),{});this.element.style.color=t["text-color"],this.element.style.fontSize="14px",this.element.style.position="absolute",this.element.style.userSelect="none",this.element.style.zIndex=5,this.element.style.pointerEvents="none",this.element.style.backgroundColor="rgba(30, 33, 41, var(--panel-opacity))",this.element.style.padding="16.5px 10px 16.5px 10px",this.element.style.borderRadius="10px"}},F=xe;var we={name:"PingCounter",category:"Player",description:"Displays your network ping.",enabled:!0,settings:[{id:"text-color",name:"Text Color",type:"color",value:"#EAEAEA"},{id:"show-label",name:"Show Label",type:"boolean",value:!0},{id:"format",name:"Text Format",type:"text",value:"{label} {ping}ms"},{id:"mod-credit",name:"Mod Made by GEORGECR and Casmyx",type:"info"}],ping:"--",element:null,pingIntervalId:null,positionInterval:null,onEnable(){this.createDisplay(),this.applyStyles(),this.updatePing(),this.pingIntervalId=setInterval(this.updatePing.bind(this),2e3),this.startPositioning()},onDisable(){this.destroyDisplay(),clearInterval(this.pingIntervalId),this.positionInterval&&clearInterval(this.positionInterval)},onTick(){this.updateDisplay()},onSettingUpdate(){this.applyStyles(),this.updateDisplay()},createDisplay(){this.element=document.createElement("div"),this.element.className="ping-counter-display",document.body.appendChild(this.element)},destroyDisplay(){this.element&&(document.body.removeChild(this.element),this.element=null)},updatePing(){let t=Date.now();fetch(window.location.origin,{method:"HEAD",mode:"no-cors"}).then(()=>{this.ping=Date.now()-t}).catch(()=>{this.ping="--"})},updateDisplay(){if(!this.element)return;let t=this.settings.reduce((i,n)=>({...i,[n.id]:n.value}),{}),e=t.format;e=e.replace("{label}",t["show-label"]?"Ping:":""),e=e.replace("{ping}",this.ping),this.element.textContent=e.trim()},startPositioning(){this.positionInterval=setInterval(()=>{if(!this.element)return;let t=document.querySelector(".FpsWrapperDiv"),e=document.querySelectorAll(".CoordinateUI"),i=document.querySelector(".cps-counter-display"),n=document.querySelector(".InGameHeader");if(!n)return;let o=t&&window.getComputedStyle(t).display!=="none",s=Array.from(e).filter(l=>window.getComputedStyle(l).display!=="none"),r=i&&window.getComputedStyle(i).display!=="none",a=null;r?a=i.getBoundingClientRect():s.length>0?a=s.reduce((l,c)=>{let d=c.getBoundingClientRect();return!l||d.right>l.right?d:l},null):o?a=t.getBoundingClientRect():a=n.getBoundingClientRect(),a&&(this.element.style.top=`${a.top+window.scrollY}px`,this.element.style.left=`${a.right+window.scrollX+5}px`,this.element.style.display="block")},200)},applyStyles(){if(!this.element)return;let t=this.settings.reduce((e,i)=>({...e,[i.id]:i.value}),{});this.element.style.color=t["text-color"],this.element.style.fontSize="14px",this.element.style.position="absolute",this.element.style.userSelect="none",this.element.style.zIndex=5,this.element.style.pointerEvents="none",this.element.style.backgroundColor="rgba(30, 33, 41, var(--panel-opacity))",this.element.style.padding="16.5px 10px 16.5px 10px",this.element.style.borderRadius="10px"}},K=we;var Ce={name:"FPSBooster",category:"Utility",description:"Optimizes game performance by adjusting resolution and other settings.",enabled:!1,canvas:null,settings:[{id:"resolutionScale",name:"Resolution Scale",description:"Lower values can improve performance at the cost of quality.",type:"slider",value:1,min:.1,max:1,step:.05}],onEnable(t){if(this.canvas=document.getElementById("noa-canvas"),!this.canvas){t.disable(this.name);return}this.canvas.dataset.originalWidth||(this.canvas.dataset.originalWidth=this.canvas.width,this.canvas.dataset.originalHeight=this.canvas.height)},onDisable(t){this.canvas&&this.canvas.dataset.originalWidth&&(this.canvas.width=parseInt(this.canvas.dataset.originalWidth,10),this.canvas.height=parseInt(this.canvas.dataset.originalHeight,10),delete this.canvas.dataset.originalWidth,delete this.canvas.dataset.originalHeight),this.canvas&&(this.canvas.style.width="",this.canvas.style.height=""),this.canvas=null},onSettingUpdate(t,e,i){},onTick(t,e){this.canvas&&this.enabled&&this.applySettings(e)},applySettings(t){if(!this.canvas||!this.canvas.dataset.originalWidth)return;let i=t.get(this.name).settings.find(a=>a.id==="resolutionScale").value,n=parseInt(this.canvas.dataset.originalWidth,10),o=parseInt(this.canvas.dataset.originalHeight,10),s=Math.round(n*i),r=Math.round(o*i);this.canvas.width!==s&&(this.canvas.width=s),this.canvas.height!==r&&(this.canvas.height=r),this.canvas.style.width!=="100%"&&(this.canvas.style.width="100%"),this.canvas.style.height!=="100%"&&(this.canvas.style.height="100%")}},V=Ce;var ke={name:"AdBlocker",category:"Utility",description:"Blocks in-game ads and trackers by hiding elements and intercepting network requests.",enabled:!0,settings:[{id:"hide-page-ads",name:"Hide In-Page Ads",type:"boolean",value:!0,description:"Hides visible ad containers and popups."},{id:"block-network-ads",name:"Block Ad Network Requests",type:"boolean",value:!0,description:"Prevents the browser from requesting ads from known ad servers."}],originalFetch:window.fetch,originalXhrOpen:window.XMLHttpRequest.prototype.open,originalXhrSend:window.XMLHttpRequest.prototype.send,observer:null,adSelectors:[".SuperRankAdContainer",".AdBannerContainer",".PlaywireVideoWrapper",".UiRequests",".AdBanner",".GenericVideoWrapper","#bloxd-io_300x600_2",".InventoryAdOuter"],blockList:["googlesyndication.com","googletagservices.com","google-analytics.com","doubleclick.net","adinplay.com","playwire.com","amazon-adsystem.com","adnxs.com"],onEnable(){this.applySettings()},onDisable(){this.unpatchNetworkRequests(),this.observer&&(this.observer.disconnect(),this.observer=null)},onSettingUpdate(){this.applySettings()},applySettings(){let t=this.settings.reduce((e,i)=>({...e,[i.id]:i.value}),{});t["block-network-ads"]?this.patchNetworkRequests():this.unpatchNetworkRequests(),t["hide-page-ads"]?(this.hidePageAds(),this.setupObserver()):this.observer&&(this.observer.disconnect(),this.observer=null)},isBlocked(t){return this.blockList.some(e=>t.includes(e))},patchNetworkRequests(){let t=this;window.fetch=function(e,i){let n=typeof e=="string"?e:e.url;return t.isBlocked(n)?Promise.resolve(new Response(null,{status:204,statusText:"No Content"})):t.originalFetch.apply(this,arguments)},window.XMLHttpRequest.prototype.open=function(e,i){t.isBlocked(i)?this._isBlocked=!0:delete this._isBlocked,t.originalXhrOpen.apply(this,arguments)},window.XMLHttpRequest.prototype.send=function(){this._isBlocked||t.originalXhrSend.apply(this,arguments)}},unpatchNetworkRequests(){window.fetch=this.originalFetch,window.XMLHttpRequest.prototype.open=this.originalXhrOpen,window.XMLHttpRequest.prototype.send=this.originalXhrSend},hideElement(t){t.style.opacity!=="0"&&(t.style.opacity="0",t.style.pointerEvents="none")},hidePageAds(){this.adSelectors.forEach(t=>{document.querySelectorAll(t).forEach(e=>this.hideElement(e))})},setupObserver(){this.observer||(this.observer=new MutationObserver(t=>{for(let e of t)for(let i of e.addedNodes)i.nodeType===Node.ELEMENT_NODE&&this.adSelectors.forEach(n=>{i.matches(n)&&this.hideElement(i),i.querySelectorAll(n).forEach(o=>this.hideElement(o))})}),this.observer.observe(document.documentElement,{childList:!0,subtree:!0}))}},X=ke;var k="loglevel",L=class{static save(e){try{let i=JSON.stringify(e),n=btoa(i);localStorage.setItem(k,n)}catch{}}static load(){try{let e=localStorage.getItem(k);if(!e)return null;let i=atob(e);return JSON.parse(i)}catch{return localStorage.removeItem(k),null}}static reset(){try{localStorage.removeItem(k)}catch{}}},S=L;var Se={name:"Crosshair",category:"Visual",description:"Replaces the default game crosshair with a custom one.",enabled:!1,element:null,gameCrosshair:null,gameCrosshairInitialDisplay:null,observer:null,settings:[{id:"hide-original",name:"Hide Original Crosshair",type:"boolean",value:!0},{id:"mode",name:"Mode",type:"select",value:"Cross",options:["Cross","Plus","Dot","Circle","T-Shape","Arrow","Custom Image"]},{id:"color-mode",name:"Color Mode",type:"select",options:["Theme","Custom"],value:"Theme",condition:t=>t.mode!=="Custom Image"},{id:"image-url",name:"Image URL",type:"text",value:"https://i.imgur.com/M8M4G3k.png",condition:t=>t.mode==="Custom Image"},{id:"size",name:"Size",type:"slider",value:12,min:1,max:100,step:1},{id:"color",name:"Color",type:"color",value:"#FFFFFF",condition:t=>t.mode!=="Custom Image"&&t["color-mode"]==="Custom"},{id:"thickness",name:"Thickness",type:"slider",value:2,min:1,max:20,step:1,condition:t=>["Cross","Plus","Circle","T-Shape"].includes(t.mode)},{id:"outline",name:"Outline",type:"boolean",value:!0,condition:t=>t.mode!=="Custom Image"},{id:"outline-color",name:"Outline Color",type:"color",value:"#000000",condition:t=>t.outline&&t.mode!=="Custom Image"&&t["color-mode"]==="Custom"}],onEnable(){this.createDisplay(),this.updateCrosshair(),this.handleGameCrosshair(),this.observer=new MutationObserver(()=>this.handleGameCrosshair()),this.observer.observe(document.body,{childList:!0,subtree:!0})},onDisable(){this.observer&&(this.observer.disconnect(),this.observer=null),this.destroyDisplay(),this.restoreGameCrosshair(),this.gameCrosshair=null,this.gameCrosshairInitialDisplay=null},onSettingUpdate(t){this.updateCrosshair(),t==="hide-original"&&this.handleGameCrosshair()},createDisplay(){this.element||(this.element=document.createElement("div"),this.element.className="serenity-crosshair",this.element.style.position="fixed",this.element.style.top="50%",this.element.style.left="50%",this.element.style.transform="translate(-50%, -50%)",this.element.style.pointerEvents="none",this.element.style.zIndex="9999",document.body.appendChild(this.element))},destroyDisplay(){this.element&&(document.body.removeChild(this.element),this.element=null)},handleGameCrosshair(){let t=this.settings.find(i=>i.id==="hide-original").value,e=document.querySelector(".CrossHair");t?e&&(this.gameCrosshair!==e&&(this.gameCrosshair=e,this.gameCrosshairInitialDisplay=e.style.display),this.gameCrosshair.style.display="none"):this.restoreGameCrosshair()},restoreGameCrosshair(){this.gameCrosshair&&(this.gameCrosshair.style.display=this.gameCrosshairInitialDisplay||"")},updateCrosshair(){if(!this.element)return;this.element.innerHTML="";let t=this.settings.reduce((d,p)=>({...d,[p.id]:p.value}),{}),{mode:e,size:i,color:n,thickness:o,outline:s,"outline-color":r,"image-url":a,"color-mode":l}=t;l==="Theme"&&e!=="Custom Image"&&(n=getComputedStyle(document.documentElement).getPropertyValue("--primary").trim(),r="#000000");let c=s?`0px 0px 2px ${r}, 0px 0px 2px ${r}, 0px 0px 2px ${r}, 0px 0px 2px ${r}`:"none";switch(e){case"Custom Image":let d=document.createElement("img");d.src=a,d.style.width=`${i}px`,d.style.height=`${i}px`,this.element.appendChild(d);break;case"Dot":let p=document.createElement("div");p.style.width=`${i}px`,p.style.height=`${i}px`,p.style.backgroundColor=n,p.style.borderRadius="50%",p.style.textShadow=c,this.element.appendChild(p);break;case"Circle":let u=document.createElement("div");u.style.width=`${i}px`,u.style.height=`${i}px`,u.style.border=`${o}px solid ${n}`,u.style.borderRadius="50%",u.style.textShadow=c,this.element.appendChild(u);break;case"Cross":case"Plus":case"T-Shape":let h=e==="Cross"?Math.max(1,i/4):0,m=i,g={top:{top:`-${h+m}px`,left:`-${o/2}px`,width:`${o}px`,height:`${m}px`},bottom:{top:`${h}px`,left:`-${o/2}px`,width:`${o}px`,height:`${m}px`},left:{left:`-${h+m}px`,top:`-${o/2}px`,width:`${m}px`,height:`${o}px`},right:{left:`${h}px`,top:`-${o/2}px`,width:`${m}px`,height:`${o}px`}},b=["top","bottom","left","right"];e==="T-Shape"&&(b=["bottom","left","right"]),b.forEach(f=>{let v=document.createElement("div");v.style.position="absolute",v.style.backgroundColor=n,v.style.textShadow=c,Object.assign(v.style,g[f]),this.element.appendChild(v)});break;case"Arrow":let y=document.createElement("div");y.style.width="0",y.style.height="0",y.style.borderLeft=`${i/2}px solid transparent`,y.style.borderRight=`${i/2}px solid transparent`,y.style.borderBottom=`${i}px solid ${n}`,s&&(y.style.filter=`drop-shadow(0 1px 1px ${r}) drop-shadow(0 -1px 1px ${r}) drop-shadow(1px 0 1px ${r}) drop-shadow(-1px 0 1px ${r})`),this.element.appendChild(y);break}}},Y=Se;var z=class{constructor(){this.container=null,this.init()}init(){if(!document.getElementById("font-awesome-link")){let e=document.createElement("link");e.id="font-awesome-link",e.rel="stylesheet",e.href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css",document.head.appendChild(e)}document.querySelector(".serenity-notification-container")?this.container=document.querySelector(".serenity-notification-container"):(this.container=document.createElement("div"),this.container.className="serenity-notification-container",document.body.appendChild(this.container))}show({title:e="Serenity",message:i,type:n="info",duration:o=3e3}){let s=document.createElement("div");s.className=`serenity-notification serenity-notification-${n}`;let r={info:'',success:'',warning:'',error:''};s.innerHTML=`
${r[n]||r.info}
${e}
${i}
`,this.container.prepend(s),s.style.animation="serenity-notification-in 0.5s forwards cubic-bezier(0.2, 1, 0.2, 1)";let a=s.querySelector(".serenity-notification-timer");a.style.transition=`width ${o}ms linear`,setTimeout(()=>{a&&(a.style.width="0%")},10);let l=()=>{s.classList.contains("exiting")||(s.classList.add("exiting"),clearTimeout(d),s.style.animation="serenity-notification-out 0.5s forwards cubic-bezier(0.8, 0, 0.8, 0)",s.addEventListener("animationend",p=>{p.animationName==="serenity-notification-out"&&s.remove()}))};s.querySelector(".serenity-notification-close").addEventListener("click",l,{once:!0});let d=setTimeout(l,o);s.addEventListener("mouseenter",()=>{clearTimeout(d),a.style.width=getComputedStyle(a).width}),s.addEventListener("mouseleave",()=>{d=setTimeout(l,o),a.style.transition=`width ${o}ms linear`,a.style.width="0%"})}},_=z;var Ee={name:"Notifications",category:"Utility",description:"Shows alerts when modules are toggled.",enabled:!1,settings:[]},J=Ee;var Ie={_ctx:null,getContext:function(){return this._ctx||(this._ctx=document.createElement("canvas").getContext("2d")),this._ctx}},Me={name:"ArrayList",category:"Visual",description:"Displays a list of enabled modules.",enabled:!1,element:null,settings:[{id:"color-mode",name:"Color Mode",description:"The color style of the module list.",type:"select",options:["Rainbow","Static"],value:"Static"},{id:"use-theme-color",name:"Use Theme Color",description:"Use the main theme color for static mode.",type:"boolean",value:!0,condition:t=>t["color-mode"]==="Static"},{id:"static-color",name:"Custom Static Color",description:"The color of the text if not using the theme color.",type:"color",value:"rgba(94, 114, 235, 1)",condition:t=>t["color-mode"]==="Static"&&!t["use-theme-color"]},{id:"border",name:"Show Border",description:"Display a colored border on the side of the list.",type:"boolean",value:!0},{id:"text-shadow",name:"Text Shadow",description:"Adds a shadow to the text for better visibility.",type:"boolean",value:!0},{id:"font-size",name:"Font Size",description:"The font size of the module names.",type:"slider",min:10,max:20,step:1,value:14}],onEnable(t){this.element||(this.element=document.createElement("div"),this.element.className="serenity-arraylist-container",document.body.appendChild(this.element)),this.updateStyle(t)},onDisable(){this.element&&(document.body.removeChild(this.element),this.element=null)},onTick(t,e){if(!this.element)return;let i=["ClickGUI","ArrayList","Notifications"],r=`600 ${this.getSettingValue(e,"font-size")}px Inter`,a=Ie.getContext();a.font=r;let l=e.list().filter(h=>h.enabled&&!i.includes(h.name)).map(h=>({name:h.name,width:a.measureText(h.name).width})).sort((h,m)=>m.width-h.width||h.name.localeCompare(m.name));this.element.innerHTML="";let c=this.getSettingValue(e,"color-mode"),d=this.getSettingValue(e,"use-theme-color"),p=this.getSettingValue(e,"static-color"),u=this.getSettingValue(e,"border");c==="Static"&&d&&(p=getComputedStyle(document.documentElement).getPropertyValue("--primary").trim()),l.forEach((h,m)=>{let g=document.createElement("div");g.className="serenity-arraylist-item";let b=c==="Rainbow"?W(m):p;if(g.style.color=b,g.textContent=h.name,u){let y=document.createElement("span");y.className="serenity-arraylist-border",y.style.backgroundColor=b,g.appendChild(y)}this.element.appendChild(g)})},onSettingUpdate(t,e,i){this.updateStyle(i)},updateStyle(t){if(!this.element)return;let e=this.getSettingValue(t,"text-shadow"),i=this.getSettingValue(t,"font-size");this.element.style.fontSize=`${i}px`,this.element.classList.toggle("with-shadow",e)},getSettingValue(t,e){let i=t.get("ArrayList");if(!i)return null;let n=i.settings.find(o=>o.id===e);return n?n.value:null}},Q=Me;var Le={name:"Waypoint",category:"Utility",description:"Manages and displays multiple waypoints in the world.",enabled:!1,waypoints:[],waypointElements:new Map,camera:null,entities:null,deathMarkerObserver:null,settings:[{id:"info",name:"Waypoint Manager",type:"info",description:"Click the settings cog to manage your waypoints."}],onEnable(t){this.manager=t,this.loadWaypoints(),this.waypoints.forEach(e=>this.createWaypointElement(e))},onDisable(){this.destroyDisplay(),this.camera=null,this.entities=null},onTick(){(!this.camera||!this.entities)&&this.findGameData()},onFrame(){let t=document.querySelector(".HotBarGameItemsContainer"),e=document.querySelector(".ForceRotateBackground");if(!t||e){this.waypointElements.forEach(i=>{i&&(i.style.display="none")});return}this.waypoints.forEach(i=>this.updateWaypointPosition(i))},getWaypoints(){return this.waypoints},addWaypoint(t){let e={id:Date.now(),title:"New Waypoint",x:0,y:0,z:0,color:"#5E72EB",enabled:!0,...t};this.waypoints.push(e),this.createWaypointElement(e),this.saveWaypoints()},removeWaypoint(t){this.waypoints=this.waypoints.filter(e=>e.id!==t),this.waypointElements.has(t)&&(this.waypointElements.get(t).remove(),this.waypointElements.delete(t)),this.saveWaypoints()},updateWaypoint(t,e){let i=this.waypoints.findIndex(n=>n.id===t);i!==-1&&(this.waypoints[i]={...this.waypoints[i],...e},this.updateWaypointElement(this.waypoints[i]),this.saveWaypoints())},saveWaypoints(){this.manager.saveConfiguration()},loadWaypoints(t){this.waypoints=t||this.manager.exportConfiguration().waypoints||[],this.waypointElements.forEach(e=>e.remove()),this.waypointElements.clear(),this.waypoints.forEach(e=>this.createWaypointElement(e))},getCurrentPlayerPosition(){if(!this.entities)return null;let t=this.entities.playerEntity||1,e=this.entities.getState(t,"position")||this.entities.getState(t,"physics");if(!e||!e.position)return null;let[i,n,o]=e.position;return{x:i.toFixed(2),y:n.toFixed(2),z:o.toFixed(2)}},createWaypointElement(t){if(this.waypointElements.has(t.id))return;let e=document.createElement("div");e.className="serenity-waypoint-static",e.innerHTML=`
`,document.body.appendChild(e),this.waypointElements.set(t.id,e),this.updateWaypointElement(t)},updateWaypointElement(t){let e=this.waypointElements.get(t.id);e&&(e.querySelector(".waypoint-static-title").textContent=t.title,e.style.setProperty("--waypoint-color",t.color))},findGameData(){try{let t=document.querySelector(".HotBarContainer");if(!t)return;let e=Object.values(t)[0]?.return?.updateQueue?.lastEffect?.deps;if(!e)return;let i=e[2];if(!i)return;this.entities=Object.values(i).find(n=>n?.entities?.getState)?.entities;for(let n of Object.values(i))if(typeof n=="object"&&n&&"camera"in n){this.camera=n.camera;break}}catch{this.camera=null,this.entities=null}},updateWaypointPosition(t){let e=this.waypointElements.get(t.id);if(!e||!this.camera||!this.entities||!t.enabled){e&&(e.style.display="none");return}let i=(pe,ue,he)=>Math.max(ue,Math.min(he,pe)),n=this.entities.playerEntity||1,o=this.entities.getState(n,"position")||this.entities.getState(n,"physics");if(!o||!o.position){e.style.display="none";return}let[s,r,a]=o.position,l=t.x-s,c=r-t.y,d=t.z-a,p=Math.sqrt(l*l+c*c+d*d),{pitch:u,heading:h}=this.camera,m=Math.cos(u)*Math.sin(h),g=Math.sin(u),b=Math.cos(u)*Math.cos(h),y=Math.sin(h-Math.PI/2),f=Math.cos(h-Math.PI/2),v=g*f,C=b*y-m*f,w=-g*y,x=Math.sqrt(v*v+C*C+w*w),T=v/x,oe=C/x,se=w/x,$=m*l+g*c+b*d,re=y*l+f*d,ae=T*l+oe*c+se*d;if($<0||p<1.5){e.style.display="none";return}let E=window.innerWidth,I=window.innerHeight,U=500/$,le=i(-re*U,-E/2,E/2),ce=i(ae*U,-I/2,I/2);e.style.display="flex",e.style.left=`${E/2+le}px`,e.style.top=`${I/2-ce}px`;let de=i(1-p/200,.4,1.2);e.style.transform=`translate(-50%, -100%) scale(${de})`,e.querySelector(".waypoint-static-distance").textContent=`${p.toFixed(0)}m`}},Z=Le;var N=class{constructor(e){this.moduleManager=e,this.keybinds=new Map,this.isBinding=!1,this.currentBindModule=null,this.onBindSetCallback=null,this.onKeyDown=this.onKeyDown.bind(this)}start(){window.addEventListener("keydown",this.onKeyDown)}stop(){window.removeEventListener("keydown",this.onKeyDown)}onKeyDown(e){if(document.querySelector(".serenity-config-popup"))return;if(this.isBinding&&this.currentBindModule){e.preventDefault(),e.stopPropagation();let n=e.code;if(n==="Escape"){this.stopBinding(!0);return}if(n==="Delete"||n==="Backspace"){this.removeBind(this.currentBindModule),this.stopBinding(!1,null);return}this.setBind(this.currentBindModule,n),this.stopBinding(!1,n);return}let i=this.keybinds.get(e.code);if(i){if(document.activeElement&&["INPUT","TEXTAREA"].includes(document.activeElement.tagName)||this.moduleManager.get("ClickGUI")?.isGuiOpen)return;this.moduleManager.toggle(i)}}startBinding(e,i){this.isBinding=!0,this.currentBindModule=e,this.onBindSetCallback=i}stopBinding(e,i=null){this.onBindSetCallback&&this.onBindSetCallback(this.currentBindModule,e,i),this.isBinding=!1,this.currentBindModule=null,this.onBindSetCallback=null}setBind(e,i){this.removeBind(e);let n=this.getModuleForKey(i);n&&this.removeBind(n),this.keybinds.set(i,e),this.moduleManager.saveConfiguration()}removeBind(e){for(let[i,n]of this.keybinds.entries())if(n===e){this.keybinds.delete(i);break}this.moduleManager.saveConfiguration()}getBind(e){for(let[i,n]of this.keybinds.entries())if(n===e)return i;return null}getModuleForKey(e){return this.keybinds.get(e)}loadBinds(e){e&&(this.keybinds=new Map(Object.entries(e)))}getBinds(){return Object.fromEntries(this.keybinds)}},ee=N;var B={name:"Nametags",category:"Player",description:"Get custom nametags that everyone can see.",enabled:!1,settings:[{id:"NametagUsername",name:"Nametag Username",type:"text",value:"unknown"},{id:"NametagImg",name:"Nametag Image",type:"select",value:"None",options:["None","https://i.postimg.cc/NMG91FWH/space-BG-loco.jpg","https://i.postimg.cc/1XzTTzhW/galaxy.png","https://i.postimg.cc/NfRTSvBt/custom-moving-skies-1-androidioswin10fps-friendly-5.webp","https://i.postimg.cc/J4Q0jrRs/14896441-xl.webp","https://i.postimg.cc/tC9CqKFp/banner.jpg","https://i.postimg.cc/906dTW28/15220236-xl.webp","https://i.postimg.cc/1RfHnC6F/2023-12-19-11-14-34.png","https://i.postimg.cc/ZKNxjWwK/6843ea27816c80d1186125192cbf582ece88036e-2-690x326.jpg","https://i.postimg.cc/GhjHcr2x/swirling-clouds-create-captivating-natural-vortex-sky-138943-2179.avif"]},{id:"mod-credit",name:"Mod Made By: GEORGECR",type:"info"}],patterns:{},firebaseLoaded:!1,unsub:null,defaultImage:"https://i.postimg.cc/PJ46tnhC/deafultanmetagiamge.png",onEnable(t){this.manager=t,this.loadFirebase(()=>{this.listenForUpdates(),this.hookCanvas(),this.setupUsernameSync(),this.uploadIfValid()})},onDisable(){this.unsub&&this.unsub(),Object.keys(this.patterns).forEach(t=>{let e=new Image;e.crossOrigin="anonymous",e.src=this.defaultImage,this.patterns[t]={img:e,pattern:null}})},onSettingUpdate(t,e,i){t==="NametagImg"&&!Array.from(document.querySelectorAll(".serenity-notification-title")).find(o=>o.textContent==="Nametag Updated")&&i?.notifications&&i.notifications.show({title:"Nametag Updated",message:"Rejoin the game for your new nametag to apply.",type:"info"}),this.uploadIfValid()},getSetting(t){return this.settings.find(e=>e.id===t)?.value},updateSetting(t,e){let i=this.settings.find(n=>n.id===t);i&&i.value!==e&&(i.value=e,this.uploadIfValid())},uploadIfValid(){let t=this.getSetting("NametagUsername"),e=this.getSetting("NametagImg");if(e==="None"&&(e=this.defaultImage),t&&e){firebase.firestore().collection("nametags").doc(t).set({name:t,imgUrl:e});let i=this.patterns[t];if(i)i.img.src!==e&&(i.img.src=e,i.pattern=null);else{let n=new Image;n.crossOrigin="anonymous",n.src=e,this.patterns[t]={img:n,pattern:null}}}},setupUsernameSync(){setInterval(()=>{let t=document.querySelector(".TextFromServerEntityName");if(t){let e=t.textContent.trim(),i=this.settings.find(n=>n.id==="NametagUsername");if(e&&i&&e!==i.value){i.value=e,this.uploadIfValid();let n=document.querySelector(".serenity-nametag-username-value");n&&(n.textContent=e)}}},500)},loadFirebase(t){if(this.firebaseLoaded)return t();let e=["https://www.gstatic.com/firebasejs/9.6.1/firebase-app-compat.js","https://www.gstatic.com/firebasejs/9.6.1/firebase-firestore-compat.js"],i=0;e.forEach(n=>{let o=document.createElement("script");o.src=n,o.onload=()=>{i++,i===e.length&&(firebase.initializeApp({apiKey:"AIzaSyCUnDj5OcI63iOyL3UzcxrXixbsjTIuzPA",authDomain:"vortex-client-db.firebaseapp.com",projectId:"vortex-client-db",storageBucket:"vortex-client-db.firebasestorage.app",messagingSenderId:"502851495964",appId:"1:502851495964:web:a1c7fc30c48c9901ce17d9"}),this.firebaseLoaded=!0,t())},document.head.appendChild(o)})},listenForUpdates(){let t=firebase.firestore();this.unsub=t.collection("nametags").onSnapshot(e=>{e.forEach(i=>{let{name:n,imgUrl:o}=i.data(),s=new Image;s.crossOrigin="anonymous",s.src=o||this.defaultImage,this.patterns[n]={img:s,pattern:null}})})},renderNametagManager(t,e){t.innerHTML=`
`;let i=this.settings.find(c=>c.id==="NametagUsername"),n=document.createElement("div");n.className="serenity-setting",n.innerHTML=`