diff --git a/UberWolfCli.LICENSE.txt b/UberWolfCli.LICENSE.txt deleted file mode 100644 index ac7261b..0000000 --- a/UberWolfCli.LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 Sinflower - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/UberWolfCli.exe b/UberWolfCli.exe deleted file mode 100644 index 25dcf73..0000000 Binary files a/UberWolfCli.exe and /dev/null differ diff --git a/js/plugins.js b/js/plugins.js index 8444168..bf95be8 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -365,4 +365,7 @@ var $plugins = [{ "status": true, "description": "イベント実行中、先頭フォロワーがプレイヤーの方を向く", "parameters": {} -}]; +}, + { "name": "TLInspector", "status": true, "description": "TL source inspector", "parameters": {} }, + { "name": "Forge_MZ", "status": true, "description": "Forge — in-game cheat & editor overlay", "parameters": {} } + ]; diff --git a/js/plugins/Forge_MZ.js b/js/plugins/Forge_MZ.js new file mode 100644 index 0000000..2f455ab --- /dev/null +++ b/js/plugins/Forge_MZ.js @@ -0,0 +1,91 @@ +//============================================================================= +// forge.js - In-game cheat & editor overlay for RPG Maker MV/MZ +//============================================================================= +/*: + * @target MZ MV + * @plugindesc Forge - modern in-game editor + * @author len, shellawa + * @url https://gitgud.io/zero64801/forge-mvmz/ + */ +/**/ +(function () { + var toggleKey = "f8"; + var uiScale = "2.5"; + // Forge's shortcut matcher uses legacy keyCode. Some NW.js/Wine builds deliver + // keydown with keyCode=0 while still setting key/code - map those back. + window.__dazedKeyCode = function (e) { + var kc = e.keyCode || e.which || 0; + if (kc) return kc; + var key = String(e.key || "").toLowerCase(); + var code = String(e.code || ""); + if (key === "control") return 17; + if (key === "alt") return 18; + if (key === "shift") return 16; + if (key === "meta") return 91; + var fm = /^f(\d{1,2})$/.exec(key) || /^f(\d{1,2})$/i.exec(code); + if (fm) return 111 + parseInt(fm[1], 10); + var km = /^key([a-z])$/i.exec(code); + if (km) return km[1].toUpperCase().charCodeAt(0); + if (key.length === 1) { + var c = key.charCodeAt(0); + if (c >= 97 && c <= 122) return c - 32; + if (c >= 48 && c <= 57) return c; + } + var dm = /^digit([0-9])$/i.exec(code); + if (dm) return 48 + parseInt(dm[1], 10); + return 0; + }; + try { + var saved = JSON.parse(localStorage.getItem("forge:shortcuts") || "{}"); + saved.toggle_ui = Object.assign({}, saved.toggle_ui, { keyStr: toggleKey, enabled: true }); + localStorage.setItem("forge:shortcuts", JSON.stringify(saved)); + } catch (e) {} + function resolveUiScale(v) { + if (v !== "auto" && v != null && String(v).trim() !== "") { + var n = parseFloat(v); + if (!isNaN(n) && n > 0) return Math.max(0.75, Math.min(3, n)); + } + var base = 816; + var gameW = (typeof Graphics !== "undefined" && Graphics.width) ? Graphics.width : 0; + var viewW = window.innerWidth || document.documentElement.clientWidth || base; + var w = Math.max(gameW || base, viewW); + var scale = w / base; + var dpr = window.devicePixelRatio || 1; + if (dpr > 1.15) scale *= Math.min(2, 0.75 + dpr * 0.35); + return Math.max(1, Math.min(2.75, scale)); + } + function applyUiScale() { + var host = document.getElementById("forge-mvmz-host"); + if (!host) return; + var fx = resolveUiScale(uiScale); + host.style.zoom = String(fx); + } + if (!window.__dazedForgeUiScaleHook) { + window.__dazedForgeUiScaleHook = true; + var observer = new MutationObserver(applyUiScale); + observer.observe(document.documentElement, { childList: true, subtree: true }); + window.addEventListener("resize", applyUiScale); + setInterval(applyUiScale, 500); + } + applyUiScale(); +})(); +/**/ +(function(){var e=document.createElement(`style`);e.textContent=`@import "https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap";:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-400:#ff6568;--color-orange-400:#ff8b1a;--color-yellow-300:#ffe02a;--color-yellow-400:#fac800;--color-yellow-500:#edb200;--color-fuchsia-500:#e12afb;--color-gray-200:#e5e7eb;--color-gray-300:#d1d5dc;--color-gray-400:#99a1af;--color-gray-500:#6a7282;--color-gray-600:#4a5565;--color-white:#fff;--spacing:.25rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--font-weight-black:900;--tracking-wide:.025em;--tracking-wider:.05em;--tracking-widest:.1em;--leading-tight:1.25;--leading-normal:1.5;--leading-relaxed:1.625;--radius-md:.375rem;--radius-lg:.5rem;--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-bg:#0b0c10;--color-bg2:#13151f;--color-text:#f1f5f9;--color-text-dim:#9aa1b1;--color-accent:#6366f1;--color-accent-weak:#1e3a6e;--color-border:#222533;--color-danger:#ef4444;--color-ok:#10b981;--color-warn:#fb923c;--color-frozen:#8b5cf6}@supports (color:lab(0% 0 0)){:root,:host{--color-red-400:lab(63.7053% 60.745 31.3109);--color-orange-400:lab(70.0429% 42.5156 75.8207);--color-yellow-300:lab(89.7033% -.480294 84.4917);--color-yellow-400:lab(83.2664% 8.65132 106.895);--color-yellow-500:lab(76.3898% 14.5258 98.4589);--color-fuchsia-500:lab(56.4256% 83.132 -64.639);--color-gray-200:lab(91.6229% -.159115 -2.26791);--color-gray-300:lab(85.1236% -.612259 -3.7138);--color-gray-400:lab(65.9269% -.832707 -8.17473);--color-gray-500:lab(47.7841% -.393182 -10.0268);--color-gray-600:lab(35.6337% -1.58697 -10.8425)}}*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::-webkit-file-upload-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:transparent;border-radius:0}::-webkit-file-upload-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:transparent;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:transparent;border-radius:0}:where(select:-webkit-any([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:-webkit-any([multiple],[size])) optgroup option{padding-left:20px}:where(select:is([multiple],[size])) optgroup option{padding-left:20px}::-webkit-file-upload-button{margin-right:4px}::file-selector-button{margin-right:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-top:0;padding-bottom:0}::-webkit-datetime-edit-year-field{padding-top:0;padding-bottom:0}::-webkit-datetime-edit-month-field{padding-top:0;padding-bottom:0}::-webkit-datetime-edit-day-field{padding-top:0;padding-bottom:0}::-webkit-datetime-edit-hour-field{padding-top:0;padding-bottom:0}::-webkit-datetime-edit-minute-field{padding-top:0;padding-bottom:0}::-webkit-datetime-edit-second-field{padding-top:0;padding-bottom:0}::-webkit-datetime-edit-millisecond-field{padding-top:0;padding-bottom:0}::-webkit-datetime-edit-meridiem-field{padding-top:0;padding-bottom:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button{-webkit-appearance:button;appearance:button}input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;appearance:button}::-webkit-file-upload-button{-webkit-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.invisible{visibility:hidden}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.inset-0{top:0;bottom:0;left:0;right:0}.top-0{top:0}.top-4{top:calc(var(--spacing) * 4)}.top-\\[-0\\.5px\\]{top:-.5px}.top-\\[4px\\]{top:4px}.right-0{right:0}.bottom-0{bottom:0}.left-0{left:0}.left-4{left:calc(var(--spacing) * 4)}.left-\\[4px\\]{left:4px}.left-\\[24px\\]{left:24px}.z-2147482999{z-index:2147482999}.z-2147483000{z-index:2147483000}.z-2147483647{z-index:2147483647}.m-0{margin:0}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mr-1{margin-right:var(--spacing)}.mr-2{margin-right:calc(var(--spacing) * 2)}.mr-3{margin-right:calc(var(--spacing) * 3)}.mr-4{margin-right:calc(var(--spacing) * 4)}.mb-1{margin-bottom:var(--spacing)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-2\\.5{margin-bottom:calc(var(--spacing) * 2.5)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.ml-1{margin-left:var(--spacing)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-3{margin-left:calc(var(--spacing) * 3)}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.inline{display:inline}.inline-flex{display:inline-flex}.table{display:table}.h-1\\.5{height:calc(var(--spacing) * 1.5)}.h-2{height:calc(var(--spacing) * 2)}.h-4{height:calc(var(--spacing) * 4)}.h-6{height:calc(var(--spacing) * 6)}.h-7{height:calc(var(--spacing) * 7)}.h-8{height:calc(var(--spacing) * 8)}.h-11{height:calc(var(--spacing) * 11)}.h-12{height:calc(var(--spacing) * 12)}.h-full{height:100%}.max-h-48{max-height:calc(var(--spacing) * 48)}.min-h-0{min-height:0}.w-1\\.5{width:calc(var(--spacing) * 1.5)}.w-2{width:calc(var(--spacing) * 2)}.w-4{width:calc(var(--spacing) * 4)}.w-6{width:calc(var(--spacing) * 6)}.w-7{width:calc(var(--spacing) * 7)}.w-8{width:calc(var(--spacing) * 8)}.w-9{width:calc(var(--spacing) * 9)}.w-10{width:calc(var(--spacing) * 10)}.w-11{width:calc(var(--spacing) * 11)}.w-12{width:calc(var(--spacing) * 12)}.w-32{width:calc(var(--spacing) * 32)}.w-40{width:calc(var(--spacing) * 40)}.w-48{width:calc(var(--spacing) * 48)}.w-full{width:100%}.min-w-0{min-width:0}.flex-1{flex:1}.shrink-0{flex-shrink:0}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.animate-pulse{animation:var(--animate-pulse)}.cursor-grab{cursor:grab}.cursor-move{cursor:move}.cursor-nwse-resize{cursor:nwse-resize}.cursor-pointer{cursor:pointer}.cursor-text{cursor:text}.grid-cols-\\[repeat\\(auto-fit\\,minmax\\(140px\\,1fr\\)\\)\\]{grid-template-columns:repeat(auto-fit,minmax(140px,1fr))}.grid-cols-\\[repeat\\(auto-fit\\,minmax\\(160px\\,1fr\\)\\)\\]{grid-template-columns:repeat(auto-fit,minmax(160px,1fr))}.grid-cols-\\[repeat\\(auto-fit\\,minmax\\(260px\\,1fr\\)\\)\\]{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}.grid-cols-\\[repeat\\(auto-fit\\,minmax\\(300px\\,1fr\\)\\)\\]{grid-template-columns:repeat(auto-fit,minmax(300px,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-2{grid-gap:calc(var(--spacing) * 2);gap:calc(var(--spacing) * 2)}.gap-3{grid-gap:calc(var(--spacing) * 3);gap:calc(var(--spacing) * 3)}.gap-4{grid-gap:calc(var(--spacing) * 4);gap:calc(var(--spacing) * 4)}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-top:calc(var(--spacing) * var(--tw-space-y-reverse));margin-bottom:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-top:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-bottom:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-top:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-bottom:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-top:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-bottom:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-x-1>:not(:last-child)){--tw-space-x-reverse:0;margin-left:calc(var(--spacing) * var(--tw-space-x-reverse));margin-right:calc(var(--spacing) * calc(1 - var(--tw-space-x-reverse)))}:where(.space-x-1\\.5>:not(:last-child)){--tw-space-x-reverse:0;margin-left:calc(calc(var(--spacing) * 1.5) * var(--tw-space-x-reverse));margin-right:calc(calc(var(--spacing) * 1.5) * calc(1 - var(--tw-space-x-reverse)))}:where(.space-x-2>:not(:last-child)){--tw-space-x-reverse:0;margin-left:calc(calc(var(--spacing) * 2) * var(--tw-space-x-reverse));margin-right:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-x-reverse)))}:where(.space-x-2\\.5>:not(:last-child)){--tw-space-x-reverse:0;margin-left:calc(calc(var(--spacing) * 2.5) * var(--tw-space-x-reverse));margin-right:calc(calc(var(--spacing) * 2.5) * calc(1 - var(--tw-space-x-reverse)))}:where(.space-x-3>:not(:last-child)){--tw-space-x-reverse:0;margin-left:calc(calc(var(--spacing) * 3) * var(--tw-space-x-reverse));margin-right:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-x-reverse)))}:where(.space-x-3\\.5>:not(:last-child)){--tw-space-x-reverse:0;margin-left:calc(calc(var(--spacing) * 3.5) * var(--tw-space-x-reverse));margin-right:calc(calc(var(--spacing) * 3.5) * calc(1 - var(--tw-space-x-reverse)))}:where(.space-x-4>:not(:last-child)){--tw-space-x-reverse:0;margin-left:calc(calc(var(--spacing) * 4) * var(--tw-space-x-reverse));margin-right:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-x-reverse)))}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px * var(--tw-divide-y-reverse));border-bottom-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-border>:not(:last-child)){border-color:var(--color-border)}:where(.divide-border\\/50>:not(:last-child)){border-color:rgba(34,37,51,.5)}@supports (color:color-mix(in lab, red, red)){:where(.divide-border\\/50>:not(:last-child)){border-color:color-mix(in oklab, var(--color-border) 50%, transparent)}}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-l-4{border-left-style:var(--tw-border-style);border-left-width:4px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-\\[\\#2a2d3a\\]{border-color:#2a2d3a}.border-accent{border-color:var(--color-accent)}.border-accent\\/30{border-color:rgba(99,102,241,.3)}@supports (color:color-mix(in lab, red, red)){.border-accent\\/30{border-color:color-mix(in oklab, var(--color-accent) 30%, transparent)}}.border-accent\\/50{border-color:rgba(99,102,241,.5)}@supports (color:color-mix(in lab, red, red)){.border-accent\\/50{border-color:color-mix(in oklab, var(--color-accent) 50%, transparent)}}.border-border{border-color:var(--color-border)}.border-border\\/50{border-color:rgba(34,37,51,.5)}@supports (color:color-mix(in lab, red, red)){.border-border\\/50{border-color:color-mix(in oklab, var(--color-border) 50%, transparent)}}.border-danger\\/30{border-color:rgba(239,68,68,.3)}@supports (color:color-mix(in lab, red, red)){.border-danger\\/30{border-color:color-mix(in oklab, var(--color-danger) 30%, transparent)}}.border-fuchsia-500\\/30{border-color:rgba(225,42,251,.3)}@supports (color:color-mix(in lab, red, red)){.border-fuchsia-500\\/30{border-color:color-mix(in oklab, var(--color-fuchsia-500) 30%, transparent)}}.border-gray-500\\/30{border-color:rgba(106,114,130,.3)}@supports (color:color-mix(in lab, red, red)){.border-gray-500\\/30{border-color:color-mix(in oklab, var(--color-gray-500) 30%, transparent)}}.border-ok\\/30{border-color:rgba(16,185,129,.3)}@supports (color:color-mix(in lab, red, red)){.border-ok\\/30{border-color:color-mix(in oklab, var(--color-ok) 30%, transparent)}}.border-warn\\/30{border-color:rgba(251,146,60,.3)}@supports (color:color-mix(in lab, red, red)){.border-warn\\/30{border-color:color-mix(in oklab, var(--color-warn) 30%, transparent)}}.border-yellow-500\\/30{border-color:rgba(237,178,0,.3)}@supports (color:color-mix(in lab, red, red)){.border-yellow-500\\/30{border-color:color-mix(in oklab, var(--color-yellow-500) 30%, transparent)}}.border-l-frozen{border-left-color:var(--color-frozen)}.bg-\\[\\#1a1d24\\]{background-color:#1a1d24}.bg-\\[\\#3a3f4d\\]{background-color:#3a3f4d}.bg-\\[\\#7ba4ff\\]\\/10{background-color:rgba(123,164,255,.1);background-color:lab(67.3388% 4.90472 -50.2993/.1)}.bg-\\[\\#13151a\\]{background-color:#13151a}.bg-accent{background-color:var(--color-accent)}.bg-accent-weak{background-color:var(--color-accent-weak)}.bg-accent\\/5{background-color:rgba(99,102,241,.05)}@supports (color:color-mix(in lab, red, red)){.bg-accent\\/5{background-color:color-mix(in oklab, var(--color-accent) 5%, transparent)}}.bg-accent\\/10{background-color:rgba(99,102,241,.1)}@supports (color:color-mix(in lab, red, red)){.bg-accent\\/10{background-color:color-mix(in oklab, var(--color-accent) 10%, transparent)}}.bg-accent\\/20{background-color:rgba(99,102,241,.2)}@supports (color:color-mix(in lab, red, red)){.bg-accent\\/20{background-color:color-mix(in oklab, var(--color-accent) 20%, transparent)}}.bg-bg{background-color:var(--color-bg)}.bg-bg2{background-color:var(--color-bg2)}.bg-border{background-color:var(--color-border)}.bg-border\\/50{background-color:rgba(34,37,51,.5)}@supports (color:color-mix(in lab, red, red)){.bg-border\\/50{background-color:color-mix(in oklab, var(--color-border) 50%, transparent)}}.bg-danger{background-color:var(--color-danger)}.bg-danger\\/10{background-color:rgba(239,68,68,.1)}@supports (color:color-mix(in lab, red, red)){.bg-danger\\/10{background-color:color-mix(in oklab, var(--color-danger) 10%, transparent)}}.bg-danger\\/20{background-color:rgba(239,68,68,.2)}@supports (color:color-mix(in lab, red, red)){.bg-danger\\/20{background-color:color-mix(in oklab, var(--color-danger) 20%, transparent)}}.bg-frozen\\/20{background-color:rgba(139,92,246,.2)}@supports (color:color-mix(in lab, red, red)){.bg-frozen\\/20{background-color:color-mix(in oklab, var(--color-frozen) 20%, transparent)}}.bg-fuchsia-500\\/10{background-color:rgba(225,42,251,.1)}@supports (color:color-mix(in lab, red, red)){.bg-fuchsia-500\\/10{background-color:color-mix(in oklab, var(--color-fuchsia-500) 10%, transparent)}}.bg-gray-500\\/10{background-color:rgba(106,114,130,.1)}@supports (color:color-mix(in lab, red, red)){.bg-gray-500\\/10{background-color:color-mix(in oklab, var(--color-gray-500) 10%, transparent)}}.bg-ok{background-color:var(--color-ok)}.bg-ok\\/10{background-color:rgba(16,185,129,.1)}@supports (color:color-mix(in lab, red, red)){.bg-ok\\/10{background-color:color-mix(in oklab, var(--color-ok) 10%, transparent)}}.bg-ok\\/20{background-color:rgba(16,185,129,.2)}@supports (color:color-mix(in lab, red, red)){.bg-ok\\/20{background-color:color-mix(in oklab, var(--color-ok) 20%, transparent)}}.bg-transparent{background-color:transparent}.bg-warn\\/10{background-color:rgba(251,146,60,.1)}@supports (color:color-mix(in lab, red, red)){.bg-warn\\/10{background-color:color-mix(in oklab, var(--color-warn) 10%, transparent)}}.bg-white{background-color:var(--color-white)}.bg-yellow-500\\/10{background-color:rgba(237,178,0,.1)}@supports (color:color-mix(in lab, red, red)){.bg-yellow-500\\/10{background-color:color-mix(in oklab, var(--color-yellow-500) 10%, transparent)}}.fill-current{fill:currentColor}.p-1{padding:var(--spacing)}.p-2{padding:calc(var(--spacing) * 2)}.p-2\\.5{padding:calc(var(--spacing) * 2.5)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-5{padding:calc(var(--spacing) * 5)}.px-1{padding-left:var(--spacing);padding-right:var(--spacing)}.px-1\\.5{padding-left:calc(var(--spacing) * 1.5);padding-right:calc(var(--spacing) * 1.5)}.px-2{padding-left:calc(var(--spacing) * 2);padding-right:calc(var(--spacing) * 2)}.px-2\\.5{padding-left:calc(var(--spacing) * 2.5);padding-right:calc(var(--spacing) * 2.5)}.px-3{padding-left:calc(var(--spacing) * 3);padding-right:calc(var(--spacing) * 3)}.px-3\\.5{padding-left:calc(var(--spacing) * 3.5);padding-right:calc(var(--spacing) * 3.5)}.px-4{padding-left:calc(var(--spacing) * 4);padding-right:calc(var(--spacing) * 4)}.py-0\\.5{padding-top:calc(var(--spacing) * .5);padding-bottom:calc(var(--spacing) * .5)}.py-1{padding-top:var(--spacing);padding-bottom:var(--spacing)}.py-1\\.5{padding-top:calc(var(--spacing) * 1.5);padding-bottom:calc(var(--spacing) * 1.5)}.py-2{padding-top:calc(var(--spacing) * 2);padding-bottom:calc(var(--spacing) * 2)}.py-3{padding-top:calc(var(--spacing) * 3);padding-bottom:calc(var(--spacing) * 3)}.pt-1{padding-top:var(--spacing)}.pr-1{padding-right:var(--spacing)}.pr-2{padding-right:calc(var(--spacing) * 2)}.pr-4{padding-right:calc(var(--spacing) * 4)}.pb-1\\.5{padding-bottom:calc(var(--spacing) * 1.5)}.pb-2{padding-bottom:calc(var(--spacing) * 2)}.pl-3{padding-left:calc(var(--spacing) * 3)}.pl-4{padding-left:calc(var(--spacing) * 4)}.text-center{text-align:center}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.font-sans{font-family:var(--font-sans)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\\[9px\\]{font-size:9px}.text-\\[10px\\]{font-size:10px}.leading-none{--tw-leading:1;line-height:1}.leading-normal{--tw-leading:var(--leading-normal);line-height:var(--leading-normal)}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-black{--tw-font-weight:var(--font-weight-black);font-weight:var(--font-weight-black)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.tracking-widest{--tw-tracking:var(--tracking-widest);letter-spacing:var(--tracking-widest)}.break-words{overflow-wrap:break-word}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-\\[\\#7ba4ff\\]{color:#7ba4ff}.text-accent{color:var(--color-accent)}.text-danger{color:var(--color-danger)}.text-frozen{color:var(--color-frozen)}.text-fuchsia-500{color:var(--color-fuchsia-500)}.text-gray-300{color:var(--color-gray-300)}.text-gray-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.text-gray-600{color:var(--color-gray-600)}.text-ok{color:var(--color-ok)}.text-orange-400{color:var(--color-orange-400)}.text-text{color:var(--color-text)}.text-text-dim{color:var(--color-text-dim)}.text-warn{color:var(--color-warn)}.text-white{color:var(--color-white)}.text-yellow-400{color:var(--color-yellow-400)}.text-yellow-500{color:var(--color-yellow-500)}.uppercase{text-transform:uppercase}.opacity-50{opacity:.5}.opacity-90{opacity:.9}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,rgba(0,0,0,.1)), 0 1px 2px -1px var(--tw-shadow-color,rgba(0,0,0,.1));box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-2xl{--tw-shadow:0 25px 50px -12px var(--tw-shadow-color,rgba(0,0,0,.25));box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,rgba(0,0,0,.1)), 0 4px 6px -4px var(--tw-shadow-color,rgba(0,0,0,.1));box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,rgba(0,0,0,.1)), 0 1px 2px -1px var(--tw-shadow-color,rgba(0,0,0,.1));box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-200{--tw-duration:.2s;transition-duration:.2s}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{user-select:none}.select-text{user-select:text}@media (hover:hover){.group-hover\\:text-accent:is(:where(.group):hover *){color:var(--color-accent)}.group-hover\\:opacity-100:is(:where(.group):hover *){opacity:1}}.first-letter\\:text-\\[\\#7ba4ff\\]:first-letter{color:#7ba4ff}@media (hover:hover){.hover\\:bg-\\[\\#2a2d3a\\]:hover{background-color:#2a2d3a}.hover\\:bg-accent\\/20:hover{background-color:rgba(99,102,241,.2)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-accent\\/20:hover{background-color:color-mix(in oklab, var(--color-accent) 20%, transparent)}}.hover\\:bg-accent\\/30:hover{background-color:rgba(99,102,241,.3)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-accent\\/30:hover{background-color:color-mix(in oklab, var(--color-accent) 30%, transparent)}}.hover\\:bg-accent\\/80:hover{background-color:rgba(99,102,241,.8)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-accent\\/80:hover{background-color:color-mix(in oklab, var(--color-accent) 80%, transparent)}}.hover\\:bg-accent\\/85:hover{background-color:rgba(99,102,241,.85)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-accent\\/85:hover{background-color:color-mix(in oklab, var(--color-accent) 85%, transparent)}}.hover\\:bg-border:hover{background-color:var(--color-border)}.hover\\:bg-border\\/30:hover{background-color:rgba(34,37,51,.3)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-border\\/30:hover{background-color:color-mix(in oklab, var(--color-border) 30%, transparent)}}.hover\\:bg-border\\/50:hover{background-color:rgba(34,37,51,.5)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-border\\/50:hover{background-color:color-mix(in oklab, var(--color-border) 50%, transparent)}}.hover\\:bg-border\\/80:hover{background-color:rgba(34,37,51,.8)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-border\\/80:hover{background-color:color-mix(in oklab, var(--color-border) 80%, transparent)}}.hover\\:bg-danger\\/20:hover{background-color:rgba(239,68,68,.2)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-danger\\/20:hover{background-color:color-mix(in oklab, var(--color-danger) 20%, transparent)}}.hover\\:bg-danger\\/30:hover{background-color:rgba(239,68,68,.3)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-danger\\/30:hover{background-color:color-mix(in oklab, var(--color-danger) 30%, transparent)}}.hover\\:bg-danger\\/80:hover{background-color:rgba(239,68,68,.8)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-danger\\/80:hover{background-color:color-mix(in oklab, var(--color-danger) 80%, transparent)}}.hover\\:bg-frozen\\/30:hover{background-color:rgba(139,92,246,.3)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-frozen\\/30:hover{background-color:color-mix(in oklab, var(--color-frozen) 30%, transparent)}}.hover\\:bg-ok\\/30:hover{background-color:rgba(16,185,129,.3)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-ok\\/30:hover{background-color:color-mix(in oklab, var(--color-ok) 30%, transparent)}}.hover\\:text-danger:hover{color:var(--color-danger)}.hover\\:text-gray-200:hover{color:var(--color-gray-200)}.hover\\:text-gray-300:hover{color:var(--color-gray-300)}.hover\\:text-gray-400:hover{color:var(--color-gray-400)}.hover\\:text-red-400:hover{color:var(--color-red-400)}.hover\\:text-white:hover{color:var(--color-white)}.hover\\:text-yellow-300:hover{color:var(--color-yellow-300)}.hover\\:opacity-100:hover{opacity:1}.hover\\:brightness-110:hover{--tw-brightness:brightness(110%);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}}.focus\\:border-accent:focus{border-color:var(--color-accent)}.focus\\:bg-border\\/30:focus{background-color:rgba(34,37,51,.3)}@supports (color:color-mix(in lab, red, red)){.focus\\:bg-border\\/30:focus{background-color:color-mix(in oklab, var(--color-border) 30%, transparent)}}.focus\\:outline-none:focus{--tw-outline-style:none;outline-style:none}.active\\:cursor-grabbing:active{cursor:grabbing}.disabled\\:opacity-50:disabled{opacity:.5}:host{--color-bg:#0b0c10;--color-bg-elev:#13151f;--color-bg-input:#1a1c29;--color-bg2:#13151f;--color-text:#f1f5f9;--color-text-dim:#9aa1b1;--color-text-faint:#646b7d;--color-accent:#6366f1;--color-accent-weak:#1e3a6e;--color-border:#222533;--color-danger:#ef4444;--color-ok:#10b981;--color-warn:#fb923c;--color-frozen:#8b5cf6}::-webkit-scrollbar{width:6px;height:6px}::-webkit-scrollbar-track{background:0 0}::-webkit-scrollbar-thumb{background:#222533;border-radius:3px}::-webkit-scrollbar-thumb:hover{background:#6366f1}body,:host{color:#f1f5f9;font-family:Outfit,system-ui,-apple-system,sans-serif}*,:after,:before{--tw-border-style:solid}.cursor-grab{cursor:-webkit-grab;cursor:grab}.active\\:cursor-grabbing:active{cursor:-webkit-grabbing;cursor:grabbing}.space-x-1>:not([hidden])~:not([hidden]){margin-left:4px}.space-x-1\\.5>:not([hidden])~:not([hidden]){margin-left:6px}.space-x-2>:not([hidden])~:not([hidden]){margin-left:8px}.space-x-2\\.5>:not([hidden])~:not([hidden]){margin-left:10px}.space-x-3>:not([hidden])~:not([hidden]){margin-left:12px}.space-x-4>:not([hidden])~:not([hidden]){margin-left:16px}.space-y-0\\.5>:not([hidden])~:not([hidden]){margin-top:2px}.space-y-1>:not([hidden])~:not([hidden]){margin-top:4px}.space-y-2>:not([hidden])~:not([hidden]){margin-top:8px}.space-y-2\\.5>:not([hidden])~:not([hidden]){margin-top:10px}.space-y-3>:not([hidden])~:not([hidden]){margin-top:12px}.space-y-4>:not([hidden])~:not([hidden]){margin-top:16px}.space-y-6>:not([hidden])~:not([hidden]){margin-top:24px}.divide-y>:not([hidden])~:not([hidden]){border-top-width:1px;border-color:var(--color-border)}input,textarea,[contenteditable=true]{user-select:text!important}button,button:focus{outline:none!important}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-space-x-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 transparent}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 transparent}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 transparent}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 transparent}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 transparent}@property --tw-duration{syntax:"*";inherits:false}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@keyframes pulse{50%{opacity:.5}}@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-space-x-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 transparent;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 transparent;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 transparent;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 transparent;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 transparent;--tw-duration:initial;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial}} +/*$vite$:1*/`,document.head.appendChild(e);var t=!1,n=Array.isArray,r=Array.prototype.indexOf,i=Array.prototype.includes,a=Array.from,o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyDescriptors,l=Object.prototype,u=Array.prototype,d=Object.getPrototypeOf,f=Object.isExtensible;function p(e){return typeof e==`function`}var m=()=>{};function h(e){return e()}function g(e){for(var t=0;t{e=n,t=r}),resolve:e,reject:t}}function v(e,t){if(Array.isArray(e))return e;if(t===void 0||!(Symbol.iterator in e))return Array.from(e);let n=[];for(let r of e)if(n.push(r),n.length===t)break;return n}function y(e){"@babel/helpers - typeof";return y=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},y(e)}function b(e,t){if(y(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(y(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function x(e){var t=b(e,`string`);return y(t)==`symbol`?t:t+``}function S(e,t,n){return(t=x(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ee,C=1<<24,w=1024,te=2048,ne=4096,re=8192,ie=16384,ae=32768,oe=1<<25,se=65536,ce=1<<19,le=1<<20,ue=1<<25,de=65536,fe=1<<21,pe=1<<22,me=1<<23,he=Symbol(`$state`),ge=Symbol(`legacy props`),_e=Symbol(``),ve=Symbol(`proxy path`),ye=Symbol(`attributes`),be=Symbol(`class`),xe=Symbol(`style`),Se=Symbol(`text`),Ce=Symbol(`form reset`),we=Symbol(`hmr anchor`),Te=new class extends Error{constructor(...e){super(...e),S(this,`name`,`StaleReactionError`),S(this,`message`,"The reaction that called `getAbortSignal()` was re-run or destroyed")}},Ee=!!((ee=globalThis.document)!=null&&ee.contentType)&&globalThis.document.contentType.includes(`xml`);function De(e){if(t){let t=Error(`invariant_violation\nAn invariant violation occurred, meaning Svelte's internal assumptions were flawed. This is a bug in Svelte, not your app — please open an issue at https://github.com/sveltejs/svelte, citing the following message: "${e}"\nhttps://svelte.dev/e/invariant_violation`);throw t.name=`Svelte error`,t}else throw Error(`https://svelte.dev/e/invariant_violation`)}function Oe(e){if(t){let t=Error(`lifecycle_outside_component\n\`${e}(...)\` can only be used during component initialisation\nhttps://svelte.dev/e/lifecycle_outside_component`);throw t.name=`Svelte error`,t}else throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function ke(){if(t){let e=Error("async_derived_orphan\nCannot create a `$derived(...)` with an `await` expression outside of an effect tree\nhttps://svelte.dev/e/async_derived_orphan");throw e.name=`Svelte error`,e}else throw Error(`https://svelte.dev/e/async_derived_orphan`)}function Ae(){if(t){let e=Error("bind_invalid_checkbox_value\nUsing `bind:value` together with a checkbox input is not allowed. Use `bind:checked` instead\nhttps://svelte.dev/e/bind_invalid_checkbox_value");throw e.name=`Svelte error`,e}else throw Error(`https://svelte.dev/e/bind_invalid_checkbox_value`)}function je(){if(t){let e=Error(`derived_references_self +A derived value cannot reference itself recursively +https://svelte.dev/e/derived_references_self`);throw e.name=`Svelte error`,e}else throw Error(`https://svelte.dev/e/derived_references_self`)}function Me(e,n,r){if(t){let t=Error(`each_key_duplicate\n${r?`Keyed each block has duplicate key \`${r}\` at indexes ${e} and ${n}`:`Keyed each block has duplicate key at indexes ${e} and ${n}`}\nhttps://svelte.dev/e/each_key_duplicate`);throw t.name=`Svelte error`,t}else throw Error(`https://svelte.dev/e/each_key_duplicate`)}function Ne(e,n,r){if(t){let t=Error(`each_key_volatile\nKeyed each block has key that is not idempotent — the key for item at index ${e} was \`${n}\` but is now \`${r}\`. Keys must be the same each time for a given item\nhttps://svelte.dev/e/each_key_volatile`);throw t.name=`Svelte error`,t}else throw Error(`https://svelte.dev/e/each_key_volatile`)}function Pe(e){if(t){let t=Error(`effect_in_teardown\n\`${e}\` cannot be used inside an effect cleanup function\nhttps://svelte.dev/e/effect_in_teardown`);throw t.name=`Svelte error`,t}else throw Error(`https://svelte.dev/e/effect_in_teardown`)}function Fe(){if(t){let e=Error(`effect_in_unowned_derived +Effect cannot be created inside a \`$derived\` value that was not itself created inside an effect +https://svelte.dev/e/effect_in_unowned_derived`);throw e.name=`Svelte error`,e}else throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Ie(e){if(t){let t=Error(`effect_orphan\n\`${e}\` can only be used inside an effect (e.g. during component initialisation)\nhttps://svelte.dev/e/effect_orphan`);throw t.name=`Svelte error`,t}else throw Error(`https://svelte.dev/e/effect_orphan`)}function Le(){if(t){let e=Error(`effect_update_depth_exceeded +Maximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state +https://svelte.dev/e/effect_update_depth_exceeded`);throw e.name=`Svelte error`,e}else throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function Re(){if(t){let e=Error("invalid_snippet\nCould not `{@render}` snippet due to the expression being `null` or `undefined`. Consider using optional chaining `{@render snippet?.()}`\nhttps://svelte.dev/e/invalid_snippet");throw e.name=`Svelte error`,e}else throw Error(`https://svelte.dev/e/invalid_snippet`)}function ze(e){if(t){let t=Error(`props_invalid_value\nCannot do \`bind:${e}={undefined}\` when \`${e}\` has a fallback value\nhttps://svelte.dev/e/props_invalid_value`);throw t.name=`Svelte error`,t}else throw Error(`https://svelte.dev/e/props_invalid_value`)}function Be(e){if(t){let t=Error(`props_rest_readonly\nRest element properties of \`$props()\` such as \`${e}\` are readonly\nhttps://svelte.dev/e/props_rest_readonly`);throw t.name=`Svelte error`,t}else throw Error(`https://svelte.dev/e/props_rest_readonly`)}function Ve(e){if(t){let t=Error(`rune_outside_svelte\nThe \`${e}\` rune is only available inside \`.svelte\` and \`.svelte.js/ts\` files\nhttps://svelte.dev/e/rune_outside_svelte`);throw t.name=`Svelte error`,t}else throw Error(`https://svelte.dev/e/rune_outside_svelte`)}function He(){if(t){let e=Error("state_descriptors_fixed\nProperty descriptors defined on `$state` objects must contain `value` and always be `enumerable`, `configurable` and `writable`.\nhttps://svelte.dev/e/state_descriptors_fixed");throw e.name=`Svelte error`,e}else throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function Ue(){if(t){let e=Error(`state_prototype_fixed +Cannot set prototype of \`$state\` object +https://svelte.dev/e/state_prototype_fixed`);throw e.name=`Svelte error`,e}else throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function We(){if(t){let e=Error("state_unsafe_mutation\nUpdating state inside `$derived(...)`, `$inspect(...)` or a template expression is forbidden. If the value should not be reactive, declare it without `$state`\nhttps://svelte.dev/e/state_unsafe_mutation");throw e.name=`Svelte error`,e}else throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function Ge(){if(t){let e=Error("svelte_boundary_reset_onerror\nA `` `reset` function cannot be called while an error is still being handled\nhttps://svelte.dev/e/svelte_boundary_reset_onerror");throw e.name=`Svelte error`,e}else throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var Ke={},qe=Symbol(`uninitialized`),Je=Symbol(`filename`),Ye=`http://www.w3.org/1999/xhtml`,Xe=`http://www.w3.org/2000/svg`,Ze=`font-weight: bold`,Qe=`font-weight: normal`;function $e(e){t?console.warn(`%c[svelte] await_reactivity_loss\n%cDetected reactivity loss when reading \`${e}\`. This happens when state is read in an async function after an earlier \`await\`\nhttps://svelte.dev/e/await_reactivity_loss`,Ze,Qe):console.warn(`https://svelte.dev/e/await_reactivity_loss`)}function et(e,n){t?console.warn(`%c[svelte] await_waterfall\n%cAn async derived, \`${e}\` (${n}) was not read immediately after it resolved. This often indicates an unnecessary waterfall, which can slow down your app\nhttps://svelte.dev/e/await_waterfall`,Ze,Qe):console.warn(`https://svelte.dev/e/await_waterfall`)}function tt(){t?console.warn(`%c[svelte] derived_inert +%cReading a derived belonging to a now-destroyed effect may result in stale values +https://svelte.dev/e/derived_inert`,Ze,Qe):console.warn(`https://svelte.dev/e/derived_inert`)}function nt(e,n,r){t?console.warn(`%c[svelte] hydration_attribute_changed\n%cThe \`${e}\` attribute on \`${n}\` changed its value between server and client renders. The client value, \`${r}\`, will be ignored in favour of the server value\nhttps://svelte.dev/e/hydration_attribute_changed`,Ze,Qe):console.warn(`https://svelte.dev/e/hydration_attribute_changed`)}function rt(e){t?console.warn(`%c[svelte] hydration_mismatch\n%c${e?`Hydration failed because the initial UI does not match what was rendered on the server. The error occurred near ${e}`:`Hydration failed because the initial UI does not match what was rendered on the server`}\nhttps://svelte.dev/e/hydration_mismatch`,Ze,Qe):console.warn(`https://svelte.dev/e/hydration_mismatch`)}function it(){t?console.warn("%c[svelte] select_multiple_invalid_value\n%cThe `value` property of a `` element should be an array, but it received a non-array value. The selection will be kept as is.\nhttps://svelte.dev/e/select_multiple_invalid_value",Ze,Qe):console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function at(e){t?console.warn(`%c[svelte] state_proxy_equality_mismatch\n%cReactive \`$state(...)\` proxies and the values they proxy have different identities. Because of this, comparisons with \`${e}\` will produce unexpected results\nhttps://svelte.dev/e/state_proxy_equality_mismatch`,Ze,Qe):console.warn(`https://svelte.dev/e/state_proxy_equality_mismatch`)}function ot(){t?console.warn("%c[svelte] svelte_boundary_reset_noop\n%cA `` `reset` function only resets the boundary the first time it is called\nhttps://svelte.dev/e/svelte_boundary_reset_noop",Ze,Qe):console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var T=!1;function st(e){T=e}var E;function ct(e){if(e===null)throw rt(),Ke;return E=e}function lt(){return ct(gi(E))}function D(e){if(T){if(gi(E)!==null)throw rt(),Ke;E=e}}function ut(e=1){if(T){for(var t=e,n=E;t--;)n=gi(n);E=n}}function dt(e=!0){for(var t=0,n=E;;){if(n.nodeType===8){var r=n.data;if(r===`]`){if(t===0)return n;--t}else (r===`[`||r===`[!`||r[0]===`[`&&!isNaN(Number(r.slice(1))))&&(t+=1)}var i=gi(n);e&&n.remove(),n=i}}function ft(e){if(!e||e.nodeType!==8)throw rt(),Ke;return e.data}function pt(e){return e===this.v}function mt(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function ht(e){return!mt(e,this.v)}var gt=!1,_t=!1,vt=!1;function yt(){_t=!0}var bt=null;function xt(e,t){return e.label=t,St(e.v,t),e}function St(e,t){var n;return e==null||(n=e[ve])==null||n.call(e,t),e}function Ct(e){let t=Error(),n=wt();return n.length===0?null:(n.unshift(` +`),o(t,`stack`,{value:n.join(` +`)}),o(t,`name`,{value:e}),t)}function wt(){let e=Error.stackTraceLimit;Error.stackTraceLimit=1/0;let t=Error().stack;if(Error.stackTraceLimit=e,!t)return[];let n=t.split(` +`),r=[];for(let e=0;e{t===Lt&&Rt()})}Lt.push(e)}function Bt(){for(;Lt.length>0;)Rt()}var Vt=new WeakMap;function Ht(e){var n=V;if(n===null)return B.f|=me,e;if(t&&e instanceof Error&&!Vt.has(e)&&Vt.set(e,Wt(e,n)),!(n.f&32768)&&!(n.f&4))throw t&&!n.parent&&e instanceof Error&&Gt(e),e;Ut(e,n)}function Ut(e,n){if(!(n!==null&&n.f&16384)){for(;n!==null;){if(n.f&128){if(!(n.f&32768))throw e;try{n.b.error(e);return}catch(t){e=t}}n=n.parent}throw t&&e instanceof Error&&Gt(e),e}}function Wt(e,t){var n,r;let i=s(e,`message`);if(!(i&&!i.configurable)){for(var a=ui?` `:` `,o=`\n${a}in ${((n=t.fn)==null?void 0:n.name)||``}`,c=t.ctx;c!==null;){var l;o+=`\n${a}in ${(l=c.function)==null?void 0:l[Je].split(`/`).pop()}`,c=c.p}return{message:e.message+`\n${o}\n`,stack:(r=e.stack)==null?void 0:r.split(` +`).filter(e=>!e.includes(`svelte/src/internal`)).join(` +`)}}}function Gt(e){let t=Vt.get(e);t&&(o(e,`message`,{value:t.message}),o(e,`stack`,{value:t.stack}))}var Kt=~(te|ne|w);function qt(e,t){e.f=e.f&Kt|t}function Jt(e){e.f&512||e.deps===null?qt(e,w):qt(e,ne)}function Yt(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=de,Yt(t.deps))}function Xt(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),Yt(e.deps),qt(e,w)}var Zt=!1,Qt=!1;function $t(e){var t=Qt;try{return Qt=!1,[e(),Qt]}finally{Qt=t}}function en(e){let n=0,r=Xr(0),i;return t&&xt(r,`createSubscriber version`),()=>{Ai()&&(H(r),Ri(()=>(n===0&&(i=Ea(()=>e(()=>ei(r)))),n+=1,()=>{zt(()=>{--n,n===0&&(i==null||i(),i=void 0,ei(r))})})))}}function tn(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function nn(e,t){tn(e,t),t.add(e)}function k(e,t,n){tn(e,t),t.set(e,n)}function A(e,t,n){if(typeof e==`function`?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError(`Private element is not present on this object`)}function j(e,t,n){return e.set(A(e,t),n),n}function M(e,t){return e.get(A(e,t))}var rn=se|ce;function an(e,t,n,r){new Cn(e,t,n,r)}var on=new WeakMap,sn=new WeakMap,cn=new WeakMap,ln=new WeakMap,un=new WeakMap,dn=new WeakMap,fn=new WeakMap,pn=new WeakMap,mn=new WeakMap,hn=new WeakMap,gn=new WeakMap,_n=new WeakMap,vn=new WeakMap,yn=new WeakMap,bn=new WeakMap,xn=new WeakMap,Sn=new WeakSet,Cn=class{constructor(e,n,r,i){var a,o;nn(this,Sn),S(this,`parent`,void 0),S(this,`is_pending`,!1),S(this,`transform_error`,void 0),k(this,on,void 0),k(this,sn,T?E:null),k(this,cn,void 0),k(this,ln,void 0),k(this,un,void 0),k(this,dn,null),k(this,fn,null),k(this,pn,null),k(this,mn,null),k(this,hn,0),k(this,gn,0),k(this,_n,!1),k(this,vn,new Set),k(this,yn,new Set),k(this,bn,null),k(this,xn,en(()=>(j(bn,this,Xr(M(hn,this))),t&&xt(M(bn,this),`$effect.pending()`),()=>{j(bn,this,null)}))),j(on,this,e),j(cn,this,n),j(ln,this,e=>{var t=V;t.b=this,t.f|=128,r(e)}),this.parent=V.b,this.transform_error=(a=i==null?(o=this.parent)==null?void 0:o.transform_error:i)==null?(e=>e):a,j(un,this,zi(()=>{if(T){let e=M(sn,this);lt();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));A(Sn,this,Tn).call(this,t)}else t?A(Sn,this,En).call(this):A(Sn,this,wn).call(this)}else A(Sn,this,Dn).call(this)},rn)),T&&j(on,this,E)}defer_effect(e){Xt(e,M(vn,this),M(yn,this))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!M(cn,this).pending}update_pending_count(e,t){A(Sn,this,An).call(this,e,t),j(hn,this,M(hn,this)+e),!(!M(bn,this)||M(_n,this))&&(j(_n,this,!0),zt(()=>{j(_n,this,!1),M(bn,this)&&Qr(M(bn,this),M(hn,this))}))}get_effect_pending(){return M(xn,this).call(this),H(M(bn,this))}error(e){if(!M(cn,this).onerror&&!M(cn,this).failed)throw e;N!=null&&N.is_fork?(M(dn,this)&&N.skip_effect(M(dn,this)),M(fn,this)&&N.skip_effect(M(fn,this)),M(pn,this)&&N.skip_effect(M(pn,this)),N.oncommit(()=>{A(Sn,this,jn).call(this,e)})):A(Sn,this,jn).call(this,e)}};function wn(){try{j(dn,this,Vi(()=>M(ln,this).call(this,M(on,this))))}catch(e){this.error(e)}}function Tn(e){let t=M(cn,this).failed;t&&j(pn,this,Vi(()=>{t(M(on,this),()=>e,()=>()=>{})}))}function En(){let e=M(cn,this).pending;e&&(this.is_pending=!0,j(fn,this,Vi(()=>e(M(on,this)))),zt(()=>{var e=j(mn,this,document.createDocumentFragment()),t=mi();e.append(t),j(dn,this,A(Sn,this,kn).call(this,()=>Vi(()=>M(ln,this).call(this,t)))),M(gn,this)===0&&(M(on,this).before(e),j(mn,this,null),Ji(M(fn,this),()=>{j(fn,this,null)}),A(Sn,this,On).call(this,N))}))}function Dn(){try{if(this.is_pending=this.has_pending_snippet(),j(gn,this,0),j(hn,this,0),j(dn,this,Vi(()=>{M(ln,this).call(this,M(on,this))})),M(gn,this)>0){var e=j(mn,this,document.createDocumentFragment());Qi(M(dn,this),e);let t=M(cn,this).pending;j(fn,this,Vi(()=>t(M(on,this))))}else A(Sn,this,On).call(this,N)}catch(e){this.error(e)}}function On(e){this.is_pending=!1,e.transfer_effects(M(vn,this),M(yn,this))}function kn(e){var t=V,n=B,r=O;aa(M(un,this)),ia(M(un,this)),Et(M(un,this).ctx);try{return Dr.ensure(),e()}catch(e){return Ht(e),null}finally{aa(t),ia(n),Et(r)}}function An(e,t){if(!this.has_pending_snippet()){if(this.parent){var n;A(Sn,n=this.parent,An).call(n,e,t)}return}j(gn,this,M(gn,this)+e),M(gn,this)===0&&(A(Sn,this,On).call(this,t),M(fn,this)&&Ji(M(fn,this),()=>{j(fn,this,null)}),M(mn,this)&&(M(on,this).before(M(mn,this)),j(mn,this,null)))}function jn(e){M(dn,this)&&(Gi(M(dn,this)),j(dn,this,null)),M(fn,this)&&(Gi(M(fn,this)),j(fn,this,null)),M(pn,this)&&(Gi(M(pn,this)),j(pn,this,null)),T&&(ct(M(sn,this)),ut(),ct(dt()));var t=M(cn,this).onerror;let n=M(cn,this).failed;var r=!1,i=!1;let a=()=>{if(r){ot();return}r=!0,i&&Ge(),M(pn,this)!==null&&Ji(M(pn,this),()=>{j(pn,this,null)}),A(Sn,this,kn).call(this,()=>{A(Sn,this,Dn).call(this)})},o=e=>{try{i=!0,t==null||t(e,a),i=!1}catch(e){Ut(e,M(un,this)&&M(un,this).parent)}n&&j(pn,this,A(Sn,this,kn).call(this,()=>{try{return Vi(()=>{var t=V;t.b=this,t.f|=128,n(M(on,this),()=>e,()=>a)})}catch(e){return Ut(e,M(un,this).parent),null}}))};zt(()=>{var t;try{t=this.transform_error(e)}catch(e){Ut(e,M(un,this)&&M(un,this).parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(o,e=>Ut(e,M(un,this)&&M(un,this).parent)):o(t)})}function Mn(e,t){this.v=e,this.k=t}function Nn(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof Mn;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`?`return`:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(a.done?`return`:`normal`,n)},function(e){r(`throw`,e)})}catch(e){i(`throw`,e)}}function i(e,i){switch(e){case`return`:t.resolve({value:i,done:!0});break;case`throw`:t.reject(i);break;default:t.resolve({value:i,done:!1})}(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}Nn.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},Nn.prototype.next=function(e){return this._invoke(`next`,e)},Nn.prototype.throw=function(e){return this._invoke(`throw`,e)},Nn.prototype.return=function(e){return this._invoke(`return`,e)};function Pn(e,n,r,i){let a=Pt()?Vn:Gn;var o=e.filter(e=>!e.settled),s=n.map(a);if(t&&s.forEach((e,t)=>{e.label=n[t].toString().replace(`() => `,``).replaceAll(`$.eager(() => `,`$state.eager(`).replace(/\$\.get\((.+?)\)/g,(e,t)=>t)}),r.length===0&&o.length===0){i(s);return}var c=V,l=Fn(),u=o.length===1?o[0].promise:o.length>1?Promise.all(o.map(e=>e.promise)):null;function d(e){if(!(c.f&16384)){l();try{i([...s,...e])}catch(e){Ut(e,c)}In()}}var f=Ln();if(r.length===0){u.then(()=>d([])).finally(f);return}function p(){Promise.all(r.map(e=>Un(e))).then(d).catch(e=>Ut(e,c)).finally(f)}u?u.then(()=>{l(),p(),In()}):p()}function Fn(){var e=V,n=B,r=O,i=N;if(t)var a=Dt;return function(o=!0){aa(e),ia(n),Et(r),o&&!(e.f&16384)&&(i==null||i.activate(),i==null||i.apply()),t&&(zn(null),Ot(a))}}function In(e=!0){aa(null),ia(null),Et(null),e&&(N==null||N.deactivate()),t&&(zn(null),Ot(null))}function Ln(){var e=V,t=e.b,n=N,r=!!(t!=null&&t.is_rendered());return t==null||t.update_pending_count(1,n),n.increment(r,e),()=>{t==null||t.update_pending_count(-1,n),n.decrement(r,e)}}var Rn=null;function zn(e){Rn=e}var Bn=new Set;function Vn(e){var n=2|te;V!==null&&(V.f|=ce);let r={ctx:O,deps:null,effects:null,equals:pt,f:n,fn:e,reactions:null,rv:0,v:qe,wv:0,parent:V,ac:null};return t&&vt&&(r.created=Ct(`created at`)),r}var Hn=Symbol(`obsolete`);function Un(e,n,r){let i=V;i===null&&ke();var a=void 0,o=Xr(qe);t&&(o.label=n==null?e.toString():n);var s=!B,c=new Set;return Li(()=>{var n=V;t&&(Rn={effect:n,effect_deps:new Set,warned:!1});var l=_();a=l.promise;try{Promise.resolve(e()).then(l.resolve,e=>{e!==Te&&l.reject(e)}).finally(In)}catch(e){l.reject(e),In()}if(t){if(Rn){if(n.deps!==null)for(let e=0;e{t&&(Rn=null),f==null||f(),c.delete(l),i!==Hn&&(u.activate(),i?(o.f|=me,Qr(o,i)):(o.f&8388608&&(o.f^=me),t&&r!==void 0&&!o.equals(e)&&(Bn.add(o),setTimeout(()=>{Bn.has(o)&&!(n.f&16384)&&(et(o.label,r),Bn.delete(o))})),Qr(o,e)),u.deactivate())};l.promise.then(m,e=>m(null,e||`unknown`))}),ji(()=>{for(let e of c)e.reject(Hn)}),t&&(o.f|=pe),new Promise(e=>{function t(n){function r(){n===a?e(o):t(a)}n.then(r,r)}t(a)})}function Wn(e){let t=Vn(e);return gt||sa(t),t}function Gn(e){let t=Vn(e);return t.equals=ht,t}function Kn(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;nthis.schedule(e)){var n=M(Cr,this).get(e);if(n){M(Cr,this).delete(e);for(var r of n.d)qt(r,te),t(r);for(r of n.m)qt(r,ne),t(r)}M(wr,this).add(e)}capture(e,t,n=!1){e.v!==qe&&!this.previous.has(e)&&this.previous.set(e,e.v),e.f&8388608||(this.current.set(e,[t,n]),nr==null||nr.set(e,t)),this.is_fork||(e.v=t)}activate(){N=this}deactivate(){N=null,nr=null}flush(){try{t&&lr.clear(),ar=!0,N=this,A(Er,this,kr).call(this)}finally{if(cr=0,rr=null,or=null,sr=null,ar=!1,N=null,nr=null,Kr.clear(),t)for(let e of lr)e.updated=null}}discard(){var e;for(let e of M(hr,this))e(this);M(hr,this).clear();for(let e of this.async_deriveds.values())e.reject(Hn);A(Er,this,Fr).call(this),(e=M(vr,this))==null||e.resolve()}register_created_effect(e){M(br,this).push(e)}increment(e,t){if(j(gr,this,M(gr,this)+1),e){var n;let e=(n=M(_r,this).get(t))==null?0:n;M(_r,this).set(t,e+1)}}decrement(e,t){if(j(gr,this,M(gr,this)-1),e){var n;let e=(n=M(_r,this).get(t))==null?0:n;e===1?M(_r,this).delete(t):M(_r,this).set(t,e-1)}M(Tr,this)||(j(Tr,this,!0),zt(()=>{j(Tr,this,!1),this.linked&&this.flush()}))}transfer_effects(e,t){for(let t of e)M(xr,this).add(t);for(let e of t)M(Sr,this).add(e);e.clear(),t.clear()}oncommit(e){M(mr,this).add(e)}ondiscard(e){M(hr,this).add(e)}settled(){var e;return((e=M(vr,this))==null?j(vr,this,_()):e).promise}static ensure(){if(N===null){let t=N=new e;!ar&&!ir&&zt(()=>{M(dr,t)||t.flush()})}return N}apply(){if(!gt||!this.is_fork&&M(fr,this)===null&&M(pr,this)===null){nr=null;return}nr=new Map;for(let[e,[t]]of this.current)nr.set(e,t);for(let t=$n;t!==null;t=M(pr,t))if(!(t===this||t.is_fork)){var e=!1;if(t.id1e3&&(A(Er,this,Fr).call(this),Lr()),t)for(let e of this.current.keys())lr.add(e);for(let e of M(xr,this))M(Sr,this).delete(e),qt(e,te),this.schedule(e);for(let e of M(Sr,this))qt(e,ne),this.schedule(e);let n=M(yr,this);j(yr,this,[]),this.apply();var r=or=[],i=[],a=sr=[];for(let e of n)try{A(Er,this,Ar).call(this,e,r,i)}catch(t){throw Wr(e),A(Er,this,Or).call(this)||this.discard(),t}if(N=null,a.length>0){var o=Qn.ensure();for(let e of a)o.schedule(e)}if(or=null,sr=null,A(Er,this,Or).call(this)){A(Er,this,Nr).call(this,i),A(Er,this,Nr).call(this,r);for(let[e,t]of M(Cr,this))Ur(e,t);a.length>0&&A(Er,N,kr).call(N);return}let s=A(Er,this,jr).call(this);if(s){A(Er,this,Nr).call(this,i),A(Er,this,Nr).call(this,r),A(Er,s,Mr).call(s,this);return}M(xr,this).clear(),M(Sr,this).clear();for(let e of M(mr,this))e(this);M(mr,this).clear(),tr=this,zr(i),zr(r),tr=null,(e=M(vr,this))==null||e.resolve();var c=N;if(M(gr,this)===0&&(M(yr,this).length===0||c!==null)&&(A(Er,this,Fr).call(this),gt&&(A(Er,this,Pr).call(this),N=c)),M(yr,this).length>0)if(c!==null){let e=c;M(yr,e).push(...M(yr,this).filter(t=>!M(yr,e).includes(t)))}else c=this;c!==null&&A(Er,c,kr).call(c)}function Ar(e,t,n){e.f^=w;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||M(Cr,this).has(r))&&r.fn!==null){a?r.f^=w:i&4?t.push(r):gt&&i&16777224?n.push(r):_a(r)&&(i&16&&M(Sr,this).add(r),Sa(r));var o=r.first;if(o!==null){r=o;continue}}for(;r!==null;){var s=r.next;if(s!==null){r=s;break}r=r.parent}}}function jr(){for(var e=M(fr,this);e!==null;){if(!e.is_fork){for(let[t,[,n]]of this.current)if(e.current.has(t)&&!n)return e}e=M(fr,e)}return null}function Mr(e){for(let[t,n]of e.current)!this.previous.has(t)&&e.previous.has(t)&&this.previous.set(t,e.previous.get(t)),this.current.set(t,n);for(let[t,n]of e.async_deriveds){let e=this.async_deriveds.get(t);e&&n.promise.then(e.resolve).catch(e.reject)}e.async_deriveds.clear(),this.transfer_effects(M(xr,e),M(Sr,e));let t=e=>{var n=e.reactions;if(n!==null)for(let e of n){var r=e.f;if(r&2)t(e);else{var i=e;r&4194320&&!this.async_deriveds.has(i)&&(M(Sr,this).delete(i),qt(i,te),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),A(Er,e,Fr).call(e),N=this,A(Er,this,kr).call(this)}function Nr(e){for(var t=0;t!d.current.get(e)[1]);if(!(!M(dr,d)||i.length===0)){var a=i.filter(e=>!this.current.has(e));if(a.length===0)e&&d.discard();else if(n.length>0){if(t&&!M(Tr,d)&&Tt(M(yr,d).length===0,`Batch has scheduled roots`),e)for(let e of M(wr,this))d.unskip_effect(e,e=>{e.f&4194320?d.schedule(e):A(Er,d,Nr).call(d,[e])});d.activate();var o=new Set,s=new Map;for(var c of n)Br(c,a,o,s);s=new Map;var l=[...d.current].filter(([e,t])=>{let n=this.current.get(e);return n?n[0]!==t[0]||n[1]!==t[1]:!0}).map(([e])=>e);if(l.length>0)for(let e of M(br,this))!(e.f&155648)&&Vr(e,l,s)&&(e.f&4194320?(qt(e,te),d.schedule(e)):M(xr,d).add(e));if(M(yr,d).length>0&&!M(Tr,d)){d.apply();for(var u of M(yr,d))A(Er,d,Ar).call(d,u,[],[]);j(yr,d,[])}d.deactivate()}}}}function Fr(){if(this.linked){var e=M(fr,this),t=M(pr,this);e===null?$n=t:j(pr,e,t),t===null?er=e:j(fr,t,e),this.linked=!1}}function Ir(e){var t=ir;ir=!0;try{var n;for(e&&(N!==null&&!N.is_fork&&N.flush(),n=e());;){if(Bt(),N===null)return n;N.flush()}}finally{ir=t}}function Lr(){if(t){var e=new Map;for(let t of N.current.keys()){var n;for(let[i,a]of(n=t.updated)==null?[]:n){var r=e.get(i);r||(r={error:a.error,count:0},e.set(i,r)),r.count+=a.count}}for(let t of e.values())t.error&&console.error(t.error)}try{Le()}catch(e){t&&o(e,`stack`,{value:``}),Ut(e,rr)}}var Rr=null;function zr(e){var t=e.length;if(t!==0){for(var n=0;n0)){Kr.clear();for(let e of Rr){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Rr.has(n)&&(Rr.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||Sa(n)}}Rr.clear()}}Rr=null}}function Br(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(let i of e.reactions){let e=i.f;e&2?Br(i,t,n,r):e&4194320&&!(e&2048)&&Vr(i,t,r)&&(qt(i,te),Hr(i))}}function Vr(e,t,n){let r=n.get(e);if(r!==void 0)return r;if(e.deps!==null)for(let r of e.deps){if(i.call(t,r))return!0;if(r.f&2&&Vr(r,t,n))return n.set(r,!0),!0}return n.set(e,!1),!1}function Hr(e){N.schedule(e)}function Ur(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),qt(e,w);for(var n=e.first;n!==null;)Ur(n,t),n=n.next}}function Wr(e){qt(e,w);for(var t=e.first;t!==null;)Wr(t),t=t.next}var Gr=new Set,Kr=new Map;function qr(e){Gr=e}var Jr=!1;function Yr(){Jr=!0}function Xr(e,n){var r={f:0,v:e,reactions:null,equals:pt,rv:0,wv:0};return t&&vt&&(r.created=n==null?Ct(`created at`):n,r.updated=null,r.set_during_effect=!1,r.trace=null),r}function P(e,t){let n=Xr(e,t);return sa(n),n}function Zr(e,t=!1,n=!0){let r=Xr(e);if(t||(r.equals=ht),_t&&n&&O!==null&&O.l!==null){var i,a;((a=(i=O.l).s)==null?i.s=[]:a).push(r)}return r}function F(e,n,r=!1){B!==null&&(!ra||B.f&131072)&&Pt()&&B.f&4325394&&(oa===null||!oa.has(e))&&We();let i=r?I(n):n;return t&&St(i,e.label),Qr(e,i,sr)}function Qr(e,n,r=null){if(!e.equals(n)){Kr.set(e,ta?n:e.v);var i=Dr.ensure();if(i.capture(e,n),t){if(vt||V!==null){var a,o;e.updated!=null||(e.updated=new Map);let t=((a=(o=e.updated.get(``))==null?void 0:o.count)==null?0:a)+1;if(e.updated.set(``,{error:null,count:t}),vt||t>5){let t=Ct(`updated at`);if(t!==null){let n=e.updated.get(t.stack);n||(n={error:t,count:0},e.updated.set(t.stack,n)),n.count++}}}V!==null&&(e.set_during_effect=!0)}if(e.f&2){let t=e;e.f&2048&&Jn(t),nr===null&&Jt(t)}e.wv=ga(),ti(e,te,r),Pt()&&V!==null&&V.f&1024&&!(V.f&96)&&(ua===null?da([e]):ua.push(e)),!i.is_fork&&Gr.size>0&&!Jr&&$r()}return n}function $r(){Jr=!1;for(let e of Gr){e.f&1024&&qt(e,ne);let t;try{t=_a(e)}catch(e){t=!0}t&&Sa(e)}Gr.clear()}function ei(e){F(e,e.v+1)}function ti(e,t,n){var r=e.reactions;if(r!==null)for(var i=Pt(),a=r.length,o=0;o{if(ma===f)return e();var t=B,n=ma;ia(null),ha(f);var r=e();return ia(t),ha(n),r};a&&(i.set(`length`,P(e.length,c)),t&&(e=si(e)));var m=``;let h=!1;function g(e){if(!h){h=!0,m=e,xt(o,`${m} version`);for(let[e,t]of i)xt(t,ri(m,e));h=!1}}return new Proxy(e,{defineProperty(e,n,r){(!(`value`in r)||r.configurable===!1||r.enumerable===!1||r.writable===!1)&&He();var a=i.get(n);return a===void 0?p(()=>{var e=P(r.value,c);return i.set(n,e),t&&typeof n==`string`&&xt(e,ri(m,n)),e}):F(a,r.value,!0),!0},deleteProperty(e,n){var r=i.get(n);if(r===void 0){if(n in e){let e=p(()=>P(qe,c));i.set(n,e),ei(o),t&&xt(e,ri(m,n))}}else F(r,qe),ei(o);return!0},get(n,r,a){var o;if(r===he)return e;if(t&&r===ve)return g;var l=i.get(r),u=r in n;if(l===void 0&&(!u||(o=s(n,r))!=null&&o.writable)&&(l=p(()=>{var e=P(I(u?n[r]:qe),c);return t&&xt(e,ri(m,r)),e}),i.set(r,l)),l!==void 0){var d=H(l);return d===qe?void 0:d}return Reflect.get(n,r,a)},getOwnPropertyDescriptor(e,t){var n=Reflect.getOwnPropertyDescriptor(e,t);if(n&&`value`in n){var r=i.get(t);r&&(n.value=H(r))}else if(n===void 0){var a=i.get(t),o=a==null?void 0:a.v;if(a!==void 0&&o!==qe)return{enumerable:!0,configurable:!0,value:o,writable:!0}}return n},has(e,n){var r;if(n===he)return!0;var a=i.get(n),o=a!==void 0&&a.v!==qe||Reflect.has(e,n);return(a!==void 0||V!==null&&(!o||(r=s(e,n))!=null&&r.writable))&&(a===void 0&&(a=p(()=>{var r=P(o?I(e[n]):qe,c);return t&&xt(r,ri(m,n)),r}),i.set(n,a)),H(a)===qe)?!1:o},set(e,n,r,l){var u=i.get(n),d=n in e;if(a&&n===`length`)for(var f=r;fP(qe,c)),i.set(f+``,h),t&&xt(h,ri(m,f))):F(h,qe)}if(u===void 0){var g;(!d||(g=s(e,n))!=null&&g.writable)&&(u=p(()=>P(void 0,c)),t&&xt(u,ri(m,n)),F(u,I(r)),i.set(n,u))}else{d=u.v!==qe;var _=p(()=>I(r));F(u,_)}var v=Reflect.getOwnPropertyDescriptor(e,n);if(v!=null&&v.set&&v.set.call(l,r),!d){if(a&&typeof n==`string`){var y=i.get(`length`),b=Number(n);Number.isInteger(b)&&b>=y.v&&F(y,b+1)}ei(o)}return!0},ownKeys(e){H(o);var t=Reflect.ownKeys(e).filter(e=>{var t=i.get(e);return t===void 0||t.v!==qe});for(var[n,r]of i)r.v!==qe&&!(n in e)&&t.push(n);return t},setPrototypeOf(){Ue()}})}function ri(e,t){var n;return typeof t==`symbol`?`${e}[Symbol(${(n=t.description)==null?``:n})]`:ni.test(t)?`${e}.${t}`:/^\d+$/.test(t)?`${e}[${t}]`:`${e}['${t}']`}function ii(e){try{if(typeof e==`object`&&e&&he in e)return e[he]}catch(e){}return e}function ai(e,t){return Object.is(ii(e),ii(t))}var oi=new Set([`copyWithin`,`fill`,`pop`,`push`,`reverse`,`shift`,`sort`,`splice`,`unshift`]);function si(e){return new Proxy(e,{get(e,t,n){var r=Reflect.get(e,t,n);return oi.has(t)?function(...e){Yr();var t=r.apply(this,e);return $r(),t}:r}})}function ci(){let e=Array.prototype,t=Array.__svelte_cleanup;t&&t();let{indexOf:n,lastIndexOf:r,includes:i}=e;e.indexOf=function(e,t){let r=n.call(this,e,t);if(r===-1){for(let n=t==null?0:t;n{e.indexOf=n,e.lastIndexOf=r,e.includes=i}}var li,ui,di,fi;function pi(){if(li===void 0){li=window,ui=/Firefox/.test(navigator.userAgent);var e=Element.prototype,n=Node.prototype,r=Text.prototype;di=s(n,`firstChild`).get,fi=s(n,`nextSibling`).get,f(e)&&(e[be]=void 0,e[ye]=null,e[xe]=void 0,e.__e=void 0),f(r)&&(r[Se]=void 0),t&&(e.__svelte_meta=null,ci())}}function mi(e=``){return document.createTextNode(e)}function hi(e){return di.call(e)}function gi(e){return fi.call(e)}function L(e,t){if(!T)return hi(e);var n=hi(E);if(n===null)n=E.appendChild(mi());else if(t&&n.nodeType!==3){var r=mi();return n==null||n.before(r),ct(r),r}return t&&xi(n),ct(n),n}function _i(e,t=!1){if(!T){var n=hi(e);return n instanceof Comment&&n.data===``?gi(n):n}if(t){if((E==null?void 0:E.nodeType)!==3){var r=mi();return E==null||E.before(r),ct(r),r}xi(E)}return E}function R(e,t=1,n=!1){let r=T?E:e;for(var i;t--;)i=r,r=gi(r);if(!T)return r;if(n){if((r==null?void 0:r.nodeType)!==3){var a=mi();return r===null?i==null||i.after(a):r.before(a),ct(a),a}xi(r)}return ct(r),r}function vi(e){e.textContent=``}function yi(){return!gt||Rr!==null?!1:(V.f&ae)!==0}function bi(e,t,n){return t==null||t===`http://www.w3.org/1999/xhtml`?n?document.createElement(e,{is:n}):document.createElement(e):n?document.createElementNS(t,e,{is:n}):document.createElementNS(t,e)}function xi(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&t.nodeType===3;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function Si(e,t){if(t){let t=document.body;e.autofocus=!0,zt(()=>{document.activeElement===t&&e.focus()})}}var Ci=!1;function wi(){Ci||(Ci=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let n of e.target.elements){var t;(t=n[Ce])==null||t.call(n)}})},{capture:!0}))}function Ti(e){var t=B,n=V;ia(null),aa(null);try{return e()}finally{ia(t),aa(n)}}function Ei(e,t,n,r=n){e.addEventListener(t,()=>Ti(n));let i=e[Ce];i?e[Ce]=()=>{i(),r(!0)}:e[Ce]=()=>r(!0),wi()}function Di(e){V===null&&(B===null&&Ie(e),Fe()),ta&&Pe(e)}function Oi(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function ki(e,n){var r=V;if(t)for(;r!==null&&r.f&131072;)r=r.parent;r!==null&&r.f&8192&&(e|=re);var i={ctx:O,deps:null,nodes:null,f:e|te|512,first:null,fn:n,last:null,next:null,parent:r,b:r&&r.b,prev:null,teardown:null,wv:0,ac:null};t&&(i.component_function=kt),N==null||N.register_created_effect(i);var a=i;if(e&4)or===null?Dr.ensure().schedule(i):or.push(i);else if(n!==null){try{Sa(i)}catch(e){throw Gi(i),e}a.deps===null&&a.teardown===null&&a.nodes===null&&a.first===a.last&&!(a.f&524288)&&(a=a.first,e&16&&e&65536&&a!==null&&(a.f|=se))}if(a!==null&&(a.parent=r,r!==null&&Oi(a,r),B!==null&&B.f&2&&!(e&64))){var o,s=B;((o=s.effects)==null?s.effects=[]:o).push(a)}return i}function Ai(){return B!==null&&!ra}function ji(e){let t=ki(8,null);return qt(t,w),t.teardown=e,t}function Mi(e){Di(`$effect`),t&&o(e,`name`,{value:`$effect`});var n=V.f;if(!B&&n&32&&O!==null&&!O.i){var r,i=O;((r=i.e)==null?i.e=[]:r).push(e)}else return Ni(e)}function Ni(e){return ki(4|le,e)}function Pi(e){return Di(`$effect.pre`),t&&o(e,`name`,{value:`$effect.pre`}),ki(8|le,e)}function Fi(e){Dr.ensure();let t=ki(64|ce,e);return(e={})=>new Promise(n=>{e.outro?Ji(t,()=>{Gi(t),n(void 0)}):(Gi(t),n(void 0))})}function Ii(e){return ki(4,e)}function Li(e){return ki(pe|ce,e)}function Ri(e,t=0){return ki(8|t,e)}function z(e,t=[],n=[],r=[]){Pn(r,t,n,t=>{ki(8,()=>{e(...t.map(H))})})}function zi(e,n=0){var r=ki(16|n,e);return t&&(r.dev_stack=Dt),r}function Bi(e,n=0){var r=ki(C|n,e);return t&&(r.dev_stack=Dt),r}function Vi(e){return ki(32|ce,e)}function Hi(e){var t=e.teardown;if(t!==null){let e=ta,n=B;na(!0),ia(null);try{t.call(null)}finally{na(e),ia(n)}}}function Ui(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&Ti(()=>{e.abort(Te)});var r=n.next;n.f&64?n.parent=null:Gi(n,t),n=r}}function Wi(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||Gi(t),t=n}}function Gi(e,n=!0){var r=!1;(n||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(Ki(e.nodes.start,e.nodes.end),r=!0),e.f|=oe,Ui(e,n&&!r),xa(e,0);var i=e.nodes&&e.nodes.t;if(i!==null)for(let e of i)e.stop();Hi(e),e.f^=oe,e.f|=ie;var a=e.parent;a!==null&&a.first!==null&&qi(e),t&&(e.component_function=null),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Ki(e,t){for(;e!==null;){var n=e===t?null:gi(e);e.remove(),e=n}}function qi(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function Ji(e,t,n=!0){var r=[];Yi(e,r,!0);var i=()=>{n&&Gi(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function Yi(e,t,n){if(!(e.f&8192)){e.f^=re;var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)(e.is_global||n)&&t.push(e);for(var i=e.first;i!==null;){var a=i.next;if(!(i.f&64)){var o=(i.f&65536)!=0||(i.f&32)!=0&&(e.f&16)!=0;Yi(i,t,o?n:!1)}i=a}}}function Xi(e){Zi(e,!0)}function Zi(e,t){if(e.f&8192){e.f^=re,e.f&1024||(qt(e,te),Dr.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=(n.f&65536)!=0||(n.f&32)!=0;Zi(n,i?t:!1),n=r}var a=e.nodes&&e.nodes.t;if(a!==null)for(let e of a)(e.is_global||t)&&e.in()}}function Qi(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:gi(n);t.append(n),n=i}}var $i=null,ea=!1,ta=!1;function na(e){ta=e}var B=null,ra=!1;function ia(e){B=e}var V=null;function aa(e){V=e}var oa=null;function sa(e){if(B!==null&&(!gt||B.f&2)){var t;((t=oa)==null?oa=new Set:t).add(e)}}var ca=null,la=0,ua=null;function da(e){ua=e}var fa=1,pa=0,ma=pa;function ha(e){ma=e}function ga(){return++fa}function _a(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~de),t&4096){for(var n=e.deps,r=n.length,i=0;ie.wv)return!0}t&512&&nr===null&&qt(e,w)}return!1}function va(e,t,n=!0){var r=e.reactions;if(r!==null&&!(!gt&&oa!==null&&oa.has(e)))for(var i=0;i{e.ac.abort(Te)}),e.ac=null);try{e.f|=fe;var u=e.fn,d=u();e.f|=ae;var f=e.deps,p=N==null?void 0:N.is_fork;if(ca!==null){var m;if(p||xa(e,la),f!==null&&la>0)for(f.length=la+ca.length,m=0;m{requestAnimationFrame(()=>e()),setTimeout(()=>e())});await Promise.resolve(),Ir()}function H(e){var n=(e.f&2)!=0;if($i==null||$i.add(e),B!==null&&!ra&&!(V!==null&&V.f&16384)&&(oa===null||!oa.has(e))){var r=B.deps;if(B.f&2097152)e.rvn==null?void 0:n.call(this,e))}return e.startsWith(`pointer`)||e.startsWith(`touch`)||e===`wheel`?zt(()=>{t.addEventListener(e,i,r)}):t.addEventListener(e,i,r),i}function Ua(e,t,n,r,i){var a={capture:r,passive:i},o=Ha(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&ji(()=>{t.removeEventListener(e,o,a)})}function U(e,t,n){var r;((r=t[za])==null?t[za]={}:r)[e]=n}function Wa(e){for(var t=0;t{throw e});throw m}}finally{e[za]=n,delete e.currentTarget,ia(f),aa(p)}}}var qa,Ja=((qa=globalThis)==null||(qa=qa.window)==null?void 0:qa.trustedTypes)&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function Ya(e){var t;return(t=Ja==null?void 0:Ja.createHTML(e))==null?e:t}function Xa(e){var t=bi(`template`);return t.innerHTML=Ya(e.replaceAll(``,``)),t.content}function Za(e,t){var n=V;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function W(e,t){var n=(t&1)!=0,r=(t&2)!=0,i,a=!e.startsWith(``);return()=>{if(T)return Za(E,null),E;i===void 0&&(i=Xa(a?e:``+e),n||(i=hi(i)));var t=r||ui?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=hi(t),s=t.lastChild;Za(o,s)}else Za(t,t);return t}}function Qa(e,t,n=`svg`){var r=!e.startsWith(``),i=(t&1)!=0,a=`<${n}>${r?e:``+e}${n}>`,o;return()=>{if(T)return Za(E,null),E;if(!o){var e=hi(Xa(a));if(i)for(o=document.createDocumentFragment();hi(e);)o.appendChild(hi(e));else o=hi(e)}var t=o.cloneNode(!0);if(i){var n=hi(t),r=t.lastChild;Za(n,r)}else Za(t,t);return t}}function $a(e,t){return Qa(e,t,`svg`)}function eo(){if(T)return Za(E,null),E;var e=document.createDocumentFragment(),t=document.createComment(``),n=mi();return e.append(t,n),Za(t,n),e}function G(e,t){if(T){var n=V;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=E),lt();return}e!==null&&e.before(t)}function K(e,t){var n,r,i=t==null?``:typeof t==`object`?`${t}`:t;i!==((r=(n=e)[Se])==null?n[Se]=e.nodeValue:r)&&(e[Se]=i,e.nodeValue=`${i}`)}function to(e,t){return ro(e,t)}var no=new Map;function ro(e,{target:t,anchor:n,props:r={},events:i,context:o,intro:s=!0,transformError:c}){pi();var l=void 0,u=Fi(()=>{var s=n==null?t.appendChild(mi()):n;an(s,{pending:()=>{}},t=>{Mt({});var n=O;if(o&&(n.c=o),i&&(r.$$events=i),T&&Za(t,null),l=e(t,r)||{},T&&(V.nodes.end=E,E===null||E.nodeType!==8||E.data!==`]`))throw rt(),Ke;Nt()},c);var u=new Set,d=e=>{for(var n=0;n{for(var e of u)for(let n of[t,document]){var r=no.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Ka),r.delete(e),r.size===0&&no.delete(n)):r.set(e,i)}if(Va.delete(d),s!==n){var a;(a=s.parentNode)==null||a.removeChild(s)}}});return io.set(l,u),l}var io=new WeakMap,ao=new WeakMap,oo=new WeakMap,so=new WeakMap,co=new WeakMap,lo=new WeakMap,uo=new WeakMap,fo=new WeakMap,po=class{constructor(e,n=!0){S(this,`anchor`,void 0),k(this,ao,new Map),k(this,oo,new Map),k(this,so,new Map),k(this,co,new Set),k(this,lo,!0),k(this,uo,e=>{if(M(ao,this).has(e)){var n=M(ao,this).get(e),r=M(oo,this).get(n);if(r)Xi(r),M(co,this).delete(n);else{var i=M(so,this).get(n);i&&(Xi(i.effect),M(oo,this).set(n,i.effect),M(so,this).delete(n),t&&(i.fragment.lastChild[we]=this.anchor),i.fragment.lastChild.remove(),this.anchor.before(i.fragment),r=i.effect)}for(let[t,n]of M(ao,this)){if(M(ao,this).delete(t),t===e)break;let r=M(so,this).get(n);r&&(Gi(r.effect),M(so,this).delete(n))}for(let[e,t]of M(oo,this)){if(e===n||M(co,this).has(e))continue;let i=()=>{if(Array.from(M(ao,this).values()).includes(e)){var n=document.createDocumentFragment();Qi(t,n),n.append(mi()),M(so,this).set(e,{effect:t,fragment:n})}else Gi(t);M(co,this).delete(e),M(oo,this).delete(e)};M(lo,this)||!r?(M(co,this).add(e),Ji(t,i,!1)):i()}}}),k(this,fo,e=>{M(ao,this).delete(e);let t=Array.from(M(ao,this).values());for(let[e,n]of M(so,this))t.includes(e)||(Gi(n.effect),M(so,this).delete(e))}),this.anchor=e,j(lo,this,n)}ensure(e,t){var n=N,r=yi();if(t&&!M(oo,this).has(e)&&!M(so,this).has(e))if(r){var i=document.createDocumentFragment(),a=mi();i.append(a),M(so,this).set(e,{effect:Vi(()=>t(a)),fragment:i})}else M(oo,this).set(e,Vi(()=>t(this.anchor)));if(M(ao,this).set(n,e),r){for(let[t,r]of M(oo,this))t===e?n.unskip_effect(r):n.skip_effect(r);for(let[t,r]of M(so,this))t===e?n.unskip_effect(r.effect):n.skip_effect(r.effect);n.oncommit(M(uo,this)),n.ondiscard(M(fo,this))}else T&&(this.anchor=E),M(uo,this).call(this,n)}};function mo(e,t,n=!1){var r;T&&(r=E,lt());var i=new po(e),a=n?se:0;function o(e,t){if(T){var n=ft(r);if(e!==parseInt(n.substring(1))){var a=dt();ct(a),i.anchor=a,st(!1),i.ensure(e,t),st(!0);return}}i.ensure(e,t)}zi(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}function ho(e,t){return t}function go(e,t,n){for(var r=[],i=t.length,o,s=t.length,c=0;c{if(o){if(o.pending.delete(n),o.done.add(n),o.pending.size===0){var t=e.outrogroups;_o(e,a(o.done)),t.delete(o),t.size===0&&(e.outrogroups=null)}}else --s},!1)}if(s===0){var l=r.length===0&&n!==null;if(l){var u=n,d=u.parentNode;vi(d),d.append(u),e.items.clear()}_o(e,t,!l)}else{var f;o={pending:new Set(t),done:new Set},((f=e.outrogroups)==null?e.outrogroups=new Set:f).add(o)}}function _o(e,t,n=!0){var r;if(e.pending.size>0){r=new Set;for(let t of e.pending.values())for(let n of t)r.add(e.items.get(n).e)}for(var i=0;i{var e=i();return n(e)?e:e==null?[]:a(e)});t&&xt(p,`{#each ...}`);var m,h=new Map,g=!0;function _(e){y.effect.f&16384||(y.pending.delete(e),y.fallback=f,xo(y,m,l,r,o),f!==null&&(m.length===0?f.f&33554432?(f.f^=ue,Co(f,null,l)):Xi(f):Ji(f,()=>{f=null})))}function v(e){y.pending.delete(e)}var y={effect:zi(()=>{m=H(p);var e=m.length;let n=!1;T&&ft(l)===`[!`!=(e===0)&&(l=dt(),ct(l),st(!1),n=!0);for(var a=new Set,d=N,y=yi(),b=0;bc(l)):(f=Vi(()=>{var e;return c((e=vo)==null?vo=mi():e)}),f.f|=ue)),e>a.size&&(t?To(m,o):Me(``,``,``)),T&&e>0&&ct(dt()),!g)if(h.set(d,a),y){for(let[e,t]of u)a.has(e)||d.skip_effect(t.e);d.oncommit(_),d.ondiscard(v)}else _(d);n&&st(!0),H(p)}),flags:r,items:u,pending:h,outrogroups:null,fallback:f};g=!1,T&&(l=E)}function bo(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function xo(e,t,n,r,i){var o=(r&8)!=0,s=t.length,c=e.items,l=bo(e.effect.first),u,d=null,f,p=[],m=[],h,g,_,v;if(o){for(v=0;v0){var se=r&4&&s===0?n:null;if(o){for(v=0;v{if(f!==void 0)for(_ of f){var e;(e=_.nodes)==null||(e=e.a)==null||e.apply()}})}function So(e,n,r,i,a,o,s,c){var l=s&1?s&16?Xr(r):Zr(r,!1,!1):null,u=s&2?Xr(a):null;return t&&l&&(l.trace=()=>{var e;c()[(e=u==null?void 0:u.v)==null?a:e]}),{v:l,i:u,e:Vi(()=>(o(n,l==null?r:l,u==null?a:u,c),()=>{e.delete(i)}))}}function Co(e,t,n){if(e.nodes)for(var r=e.nodes.start,i=e.nodes.end,a=t&&!(t.f&33554432)?t.nodes.start:n;r!==null;){var o=gi(r);if(a.before(r),r===i)return;r=o}}function wo(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function To(e,t){let n=new Map,r=e.length;for(let i=0;i{var e;let a=(e=n())==null?null:e;t&&a==null&&Re(),i.ensure(a,a&&(e=>a(e,...r)))},se)}var Do=()=>performance.now(),Oo={tick:e=>requestAnimationFrame(e),now:()=>Do(),tasks:new Set};function ko(){let e=Oo.now();Oo.tasks.forEach(t=>{t.c(e)||(Oo.tasks.delete(t),t.f())}),Oo.tasks.size!==0&&Oo.tick(ko)}function Ao(e){let t;return Oo.tasks.size===0&&Oo.tick(ko),{promise:new Promise(n=>{Oo.tasks.add(t={c:e,f:n})}),abort(){Oo.tasks.delete(t)}}}function jo(e){if(e===`float`)return`cssFloat`;if(e===`offset`)return`cssOffset`;if(e.startsWith(`--`))return e;let t=e.split(`-`);return t.length===1?t[0]:t[0]+t.slice(1).map(e=>e[0].toUpperCase()+e.slice(1)).join(``)}function Mo(e){let t={},n=e.split(`;`);for(let e of n){let[n,r]=e.split(`:`);if(!n||r===void 0)break;let i=jo(n.trim());t[i]=r.trim()}return t}var No=e=>e,Po=null;function Fo(e){Po=e}function Io(e,t,n){var r,i=((r=Po)==null?V:r).nodes,a,o,s,c=null;i.a!=null||(i.a={element:e,measure(){a=this.element.getBoundingClientRect()},apply(){if(s==null||s.abort(),o=this.element.getBoundingClientRect(),a.left!==o.left||a.right!==o.right||a.top!==o.top||a.bottom!==o.bottom){let e=t()(this.element,{from:a,to:o},n==null?void 0:n());s=Lo(this.element,e,void 0,1,()=>{},()=>{s==null||s.abort(),s=void 0})}},fix(){if(!e.getAnimations().length){var{position:t,width:n,height:r}=getComputedStyle(e);if(t!==`absolute`&&t!==`fixed`){var i=e.style;c={position:i.position,width:i.width,height:i.height,transform:i.transform},i.position=`absolute`,i.width=n,i.height=r;var o=e.getBoundingClientRect();if(a.left!==o.left||a.top!==o.top){var s=`translate(${a.left-o.left}px, ${a.top-o.top}px)`;i.transform=i.transform?`${i.transform} ${s}`:s}}}},unfix(){if(c){var t=e.style;t.position=c.position,t.width=c.width,t.height=c.height,t.transform=c.transform}}}),i.a.element=e}function Lo(e,t,n,r,i,a){var o=r===1;if(p(t)){var s,c=!1;return zt(()=>{c||(s=Lo(e,t({direction:o?`in`:`out`}),n,r,i,a))}),{abort:()=>{c=!0,s==null||s.abort()},deactivate:()=>s.deactivate(),reset:()=>s.reset(),t:()=>s.t()}}if(n==null||n.deactivate(),!(t!=null&&t.duration)&&!(t!=null&&t.delay))return i(),a(),{abort:m,deactivate:m,reset:m,t:()=>r};let{delay:l=0,css:u,tick:d,easing:f=No}=t;var h=[];if(o&&n===void 0&&(d&&d(0,1),u)){var g=Mo(u(0,1));h.push(g,g)}var _=()=>1-r,v=e.animate(h,{duration:l,fill:`forwards`});return v.onfinish=()=>{var o;v.cancel(),i();var s=(o=n==null?void 0:n.t())==null?1-r:o;n==null||n.abort();var c=r-s,l=t.duration*Math.abs(c),p=[];if(l>0){var m=!1;if(u)for(var h=Math.ceil(l/(1e3/60)),g=0;g<=h;g+=1){var y=s+c*f(g/h),b=Mo(u(y,1-y));p.push(b),m||(m=b.overflow===`hidden`)}m&&(e.style.overflow=`hidden`),_=()=>{var e=v.currentTime;return s+c*f(e/l)},d&&Ao(()=>{if(v.playState!==`running`)return!1;var e=_();return d(e,1-e),!0})}v=e.animate(p,{duration:l,fill:`forwards`}),v.onfinish=()=>{_=()=>r,d==null||d(r,1-r),a()}},{abort:()=>{v&&(v.cancel(),v.effect=null,v.onfinish=m)},deactivate:()=>{a=m},reset:()=>{r===0&&(d==null||d(1,0))},t:()=>_()}}function Ro(e,n,r,i,a,o){let s=T;T&<();var c=t&&o&&(O==null?void 0:O.function[Je]),l=null;T&&E.nodeType===1&&(l=E,lt());var u=T?E:e,d=V,f=new po(u,!1);zi(()=>{let e=n()||null;var s=a?a():r||e===`svg`?Xe:void 0;if(e===null){f.ensure(null,null);return}return f.ensure(e,n=>{if(e){if(l=T?l:bi(e,s),t&&o&&(l.__svelte_meta={parent:Dt,loc:{file:c,line:o[0],column:o[1]}}),Za(l,l),i){var r=null;T&&Ra(e)&&l.append(r=document.createComment(``));var a=T?hi(l):l.appendChild(mi());T&&(a===null?st(!1):ct(a)),Fo(d),i(l,a),r==null||r.remove(),Fo(null)}V.nodes.end=l,n.before(l)}T&&ct(n)}),()=>{}},se),ji(()=>{}),s&&(st(!0),ct(u))}function zo(e,t){var n=void 0,r;Bi(()=>{n!==(n=t())&&(r&&(Gi(r),r=null),n&&(r=Vi(()=>{Ii(()=>n(e))})))})}function Bo(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t=0;){var s=o+a;(o===0||Uo.includes(r[o-1]))&&(s===r.length||Uo.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function Go(e,t=!1){var n=t?` !important;`:`;`,r=``;for(var i of Object.keys(e)){var a=e[i];a!=null&&a!==``&&(r+=` `+i+`: `+a+n)}return r}function Ko(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function qo(e,t){if(t){var n=``,r,i;if(Array.isArray(t)?(r=t[0],i=t[1]):r=t,e){e=String(e).replaceAll(/\s*\/\*.*?\*\/\s*/g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(Ko)),i&&c.push(...Object.keys(i).map(Ko));var l=0,u=-1;let t=e.length;for(var d=0;d{Zo(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),ji(()=>{t.disconnect()})}function $o(e,t,n=t){var r=new WeakSet,i=!0;Ei(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),es);else{var o,s=(o=e.querySelector(i))==null?e.querySelector(`option:not([disabled])`):o;a=s&&es(s)}n(a),e.__value=a,N!==null&&r.add(N)}),Ii(()=>{var a=t();if(e===document.activeElement){var o=gt?tr:N;if(r.has(o))return}if(Zo(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=es(s),n(a))}e.__value=a,i=!1}),Qo(e)}function es(e){return`__value`in e?e.__value:e.value}var ts=Symbol(`class`),ns=Symbol(`style`),rs=Symbol(`is custom element`),is=Symbol(`is html`),as=Ee?`link`:`LINK`,os=Ee?`input`:`INPUT`,ss=Ee?`option`:`OPTION`,cs=Ee?`select`:`SELECT`,ls=Ee?`progress`:`PROGRESS`;function us(e){if(T){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute(`value`)){var n=e.value;ps(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;ps(e,`checked`,null),e.checked=r}}};e[Ce]=n,zt(n),wi()}}function ds(e,t){var n=gs(e);n.value===(n.value=t==null?void 0:t)||e.value===t&&(t!==0||e.nodeName!==ls)||(e.value=t==null?``:t)}function fs(e,t){t?e.hasAttribute(`selected`)||e.setAttribute(`selected`,``):e.removeAttribute(`selected`)}function ps(e,t,n,r){var i=gs(e);if(T&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===as)){r||ys(e,t,n==null?``:n);return}i[t]!==(i[t]=n)&&(t===`loading`&&(e[_e]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&vs(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function ms(e,t,n,r,i=!1,a=!1){if(T&&i&&e.nodeName===os){var o=e;(o.type===`checkbox`?`defaultChecked`:`defaultValue`)in n||us(o)}var s=gs(e),c=s[rs],l=!s[is];let u=T&&c;u&&st(!1);var d=t||{},f=e.nodeName===ss;for(var p in t)p in n||(n[p]=null);n.class?n.class=Ho(n.class):(r||n[ts])&&(n.class=null),n[ns]&&(n.style!=null||(n.style=null));var m=vs(e);if(e.nodeName===os&&`type`in n&&(`value`in n||`__value`in n)){var h=n.type;(h!==d.type||h===void 0&&e.hasAttribute(`type`))&&(d.type=h,ps(e,`type`,h,a))}for(let i in n){let o=n[i];if(f&&i===`value`&&o==null){e.value=e.__value=``,d[i]=o;continue}if(i===`class`){Jo(e,e.namespaceURI===`http://www.w3.org/1999/xhtml`,o,r,t==null?void 0:t[ts],n[ts]),d[i]=o,d[ts]=n[ts];continue}if(i===`style`){Xo(e,o,t==null?void 0:t[ns],n[ns]),d[i]=o,d[ns]=n[ns];continue}var g=d[i];if(!(o===g&&!(o===void 0&&e.hasAttribute(i)))){d[i]=o;var _=i[0]+i[1];if(_!==`$$`)if(_===`on`){let t={},n=`$$`+i,r=i.slice(2);var v=ja(r);if(ka(r)&&(r=r.slice(0,-7),t.capture=!0),!v&&g){if(o!=null)continue;e.removeEventListener(r,d[n],t),d[n]=null}if(v)U(r,e,o),Wa([r]);else if(o!=null){function y(e){d[i].call(this,e)}d[n]=Ha(r,e,y,t)}}else if(i===`style`)ps(e,i,o);else if(i===`autofocus`)Si(e,!!o);else if(!c&&(i===`__value`||i===`value`&&o!=null))e.value=e.__value=o;else if(i===`selected`&&f)fs(e,o);else{var b=i;l||(b=Pa(b));var x=b===`defaultValue`||b===`defaultChecked`;if(o==null&&!c&&!x)if(s[i]=null,b===`value`||b===`checked`){let n=e,r=t===void 0;if(b===`value`){let e=n.defaultValue;n.removeAttribute(b),n.defaultValue=e,n.value=n.__value=r?e:null}else{let e=n.defaultChecked;n.removeAttribute(b),n.defaultChecked=e,n.checked=r?e:!1}}else e.removeAttribute(i);else x||m.includes(b)&&(c||typeof o!=`string`)?(e[b]=o,b in s&&(s[b]=qe)):typeof o!=`function`&&ps(e,b,o,a)}}}return u&&st(!0),d}function hs(e,t,n=[],r=[],i=[],a,o=!1,s=!1){Pn(i,n,r,n=>{var r=void 0,i={},c=e.nodeName===cs,l=!1;if(Bi(()=>{var u=t(...n.map(H)),d=ms(e,r,u,a,o,s);l&&c&&`value`in u&&Zo(e,u.value);for(let e of Object.getOwnPropertySymbols(i))u[e]||Gi(i[e]);for(let t of Object.getOwnPropertySymbols(u)){var f=u[t];t.description===`@attach`&&(!r||f!==r[t])&&(i[t]&&Gi(i[t]),i[t]=Vi(()=>zo(e,()=>f))),d[t]=f}r=d}),c){var u=e;Ii(()=>{Zo(u,r.value,!0),Qo(u)})}l=!0})}function gs(e){var t,n;return(n=(t=e)[ye])==null?t[ye]={[rs]:e.nodeName.includes(`-`),[is]:e.namespaceURI===Ye}:n}var _s=new Map;function vs(e){var t=e.getAttribute(`is`)||e.nodeName,n=_s.get(t);if(n)return n;_s.set(t,n=[]);for(var r,i=e,a=Element.prototype;a!==i;){for(var o in r=c(i),r)r[o].set&&o!==`innerHTML`&&o!==`textContent`&&o!==`innerText`&&n.push(o);i=d(i)}return n}function ys(e,n,r){var i;t&&(n===`srcset`&&Ss(e,r)||bs((i=e.getAttribute(n))==null?``:i,r)||nt(n,e.outerHTML.replace(e.innerHTML,e.innerHTML&&`...`),String(r)))}function bs(e,t){return e===t?!0:new URL(e,document.baseURI).href===new URL(t,document.baseURI).href}function xs(e){return e.split(`,`).map(e=>e.trim().split(` `).filter(Boolean))}function Ss(e,t){var n=xs(e.srcset),r=xs(t);return r.length===n.length&&r.every(([e,t],r)=>t===n[r][1]&&(bs(n[r][0],e)||bs(e,n[r][0])))}function Cs(e,n,r=n){var i=new WeakSet;Ei(e,`input`,async a=>{t&&e.type===`checkbox`&&Ae();var o=a?e.defaultValue:e.value;if(o=ws(e)?Ts(o):o,r(o),N!==null&&i.add(N),await Ca(),o!==(o=n())){var s,c=e.selectionStart,l=e.selectionEnd,u=e.value.length;if(e.value=(s=o)==null?``:s,l!==null){var d=e.value.length;c===l&&l===u&&d>u?(e.selectionStart=d,e.selectionEnd=d):(e.selectionStart=c,e.selectionEnd=Math.min(l,d))}}}),(T&&e.defaultValue!==e.value||Ea(n)==null&&e.value)&&(r(ws(e)?Ts(e.value):e.value),N!==null&&i.add(N)),Ri(()=>{t&&e.type===`checkbox`&&Ae();var r=n();if(e===document.activeElement){var a=gt?tr:N;if(i.has(a))return}ws(e)&&r===Ts(e.value)||e.type===`date`&&!r&&!e.value||r!==e.value&&(e.value=r==null?``:r)})}function ws(e){var t=e.type;return t===`number`||t===`range`}function Ts(e){return e===``?null:+e}var Es,Ds=new WeakMap,Os=new WeakMap,ks=new WeakMap,As=new WeakSet,js=class{constructor(e){nn(this,As),k(this,Ds,new WeakMap),k(this,Os,void 0),k(this,ks,void 0),j(ks,this,e)}observe(e,t){var n=M(Ds,this).get(e)||new Set;return n.add(t),M(Ds,this).set(e,n),A(As,this,Ms).call(this).observe(e,M(ks,this)),()=>{var n=M(Ds,this).get(e);n.delete(t),n.size===0&&(M(Ds,this).delete(e),M(Os,this).unobserve(e))}}};Es=js;function Ms(){var e;return(e=M(Os,this))==null?j(Os,this,new ResizeObserver(e=>{for(var t of e){Es.entries.set(t.target,t);for(var n of M(Ds,this).get(t.target)||[])n(t)}})):e}S(js,`entries`,new WeakMap);function Ns(e,t){return e===t||(e==null?void 0:e[he])===t}function Ps(e={},t,n,r){var i=O.r,a=V;return Ii(()=>{var o,s;return Ri(()=>{o=s,s=(r==null?void 0:r())||[],Ea(()=>{Ns(n(...s),e)||(t(e,...s),o&&Ns(n(...o),e)&&t(null,...o))})}),()=>{let r=a;for(;r!==i&&r.parent!==null&&r.parent.f&33554432;)r=r.parent;let o=()=>{s&&Ns(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c==null||c()}}}),e}function Fs(e=!1){let t=O,n=t.l.u;if(!n)return;let r=()=>Da(t.s);if(e){let e=0,n={},i=Vn(()=>{let r=!1,i=t.s;for(let e in i)i[e]!==n[e]&&(n[e]=i[e],r=!0);return r&&e++,e});r=()=>H(i)}n.b.length&&Pi(()=>{Is(t,r),g(n.b)}),Mi(()=>{let e=Ea(()=>n.m.map(h));return()=>{for(let t of e)typeof t==`function`&&t()}}),n.a.length&&Mi(()=>{Is(t,r),g(n.a)})}function Is(e,t){if(e.l.s)for(let t of e.l.s)H(t);t()}function Ls(e){var t=Xr(0);return function(){return arguments.length===1?(F(t,H(t)+1),arguments[0]):(H(t),e())}}var Rs={get(e,t){if(!e.exclude.has(t))return e.props[t]},set(e,n){return t&&Be(`${e.name}.${String(n)}`),!1},getOwnPropertyDescriptor(e,t){if(!e.exclude.has(t)&&t in e.props)return{enumerable:!0,configurable:!0,value:e.props[t]}},has(e,t){return e.exclude.has(t)?!1:t in e.props},ownKeys(e){return Reflect.ownKeys(e.props).filter(t=>!e.exclude.has(t))}};function zs(e,n,r){return new Proxy(t?{props:e,exclude:n,name:r,other:{},to_proxy:[]}:{props:e,exclude:n},Rs)}var Bs={get(e,t){let n=e.props.length;for(;n--;){let r=e.props[n];if(p(r)&&(r=r()),typeof r==`object`&&r&&t in r)return r[t]}},set(e,t,n){let r=e.props.length;for(;r--;){let i=e.props[r];p(i)&&(i=i());let a=s(i,t);if(a&&a.set)return a.set(n),!0}return!1},getOwnPropertyDescriptor(e,t){let n=e.props.length;for(;n--;){let r=e.props[n];if(p(r)&&(r=r()),typeof r==`object`&&r&&t in r){let e=s(r,t);return e&&!e.configurable&&(e.configurable=!0),e}}},has(e,t){if(t===he||t===ge)return!1;for(let n of e.props)if(p(n)&&(n=n()),n!=null&&t in n)return!0;return!1},ownKeys(e){let t=[];for(let n of e.props)if(p(n)&&(n=n()),n){for(let e in n)t.includes(e)||t.push(e);for(let e of Object.getOwnPropertySymbols(n))t.includes(e)||t.push(e)}return t}};function Vs(...e){return new Proxy({props:e},Bs)}function Hs(e,n,r,i){var a=!_t||(r&2)!=0,o=(r&8)!=0,c=(r&16)!=0,l=i,u=!0,d=void 0,f=()=>c&&a?(d!=null||(d=Vn(i)),H(d)):(u&&(u=!1,l=c?Ea(i):i),l);let p;if(o){var m,h,g=he in e||ge in e;p=(m=(h=s(e,n))==null?void 0:h.set)==null?g&&n in e?t=>e[n]=t:void 0:m}var _,v=!1;o?[_,v]=$t(()=>e[n]):_=e[n],_===void 0&&i!==void 0&&(_=f(),p&&(a&&ze(n),p(_)));var y=a?()=>{var t=e[n];return t===void 0?f():(u=!0,t)}:()=>{var t=e[n];return t!==void 0&&(l=void 0),t===void 0?l:t};if(a&&!(r&4))return y;if(p){var b=e.$$legacy;return(function(e,t){return arguments.length>0?((!a||!t||b||v)&&p(t?y():e),e):y()})}var x=!1,S=(r&1?Vn:Gn)(()=>(x=!1,y()));t&&(S.label=n),o&&H(S);var ee=V;return(function(e,t){if(arguments.length>0){let n=t?H(S):a&&o?I(e):e;return F(S,n),x=!0,l!==void 0&&(l=n),e}return ta&&x||ee.f&16384?S.v:H(S)})}if(t){function Us(e){if(!(e in globalThis)){let t;Object.defineProperty(globalThis,e,{configurable:!0,get:()=>{if(t!==void 0)return t;Ve(e)},set:e=>{t=e}})}}Us(`$state`),Us(`$effect`),Us(`$derived`),Us(`$inspect`),Us(`$props`),Us(`$bindable`)}function Ws(e){O===null&&Oe(`onMount`),_t&&O.l!==null?Gs(O).m.push(e):Mi(()=>{let t=Ea(e);if(typeof t==`function`)return t})}function Gs(e){var t,n=e.l;return(t=n.u)==null?n.u={a:[],b:[],m:[]}:t}if(typeof window<`u`){var Ks,qs,Js,Ys;((qs=(Ks=(Ys=(Js=window).__svelte)==null?Js.__svelte={}:Ys).v)==null?Ks.v=new Set:qs).add(`5`)}var Xs={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`},Zs=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},Qs=Symbol(`lucide-context`),$s=()=>jt(Qs),ec=new Set([`$$slots`,`$$events`,`$$legacy`,`name`,`color`,`size`,`strokeWidth`,`absoluteStrokeWidth`,`iconNode`,`children`]),tc=$a(``);function nc(e,t){var n;Mt(t,!0);let r=(n=$s())==null?{}:n,i=Hs(t,`color`,19,()=>{var e;return(e=r.color)==null?`currentColor`:e}),a=Hs(t,`size`,19,()=>{var e;return(e=r.size)==null?24:e}),o=Hs(t,`strokeWidth`,19,()=>{var e;return(e=r.strokeWidth)==null?2:e}),s=Hs(t,`absoluteStrokeWidth`,19,()=>{var e;return(e=r.absoluteStrokeWidth)==null?!1:e}),c=Hs(t,`iconNode`,19,()=>[]),l=zs(t,ec),u=Wn(()=>s()?Number(o())*24/Number(a()):o());var d=tc();hs(d,e=>({...Xs,...e,...l,width:a(),height:a(),stroke:i(),"stroke-width":H(u),class:[`lucide-icon lucide`,r.class,t.name&&`lucide-${t.name}`,t.class]}),[()=>!t.children&&!Zs(l)&&{"aria-hidden":`true`}]);var f=L(d);yo(f,17,c,ho,(e,t)=>{var n=Wn(()=>v(H(t),2));let r=()=>H(n)[0],i=()=>H(n)[1];var a=eo();Ro(_i(a),r,!0,(e,t)=>{hs(e,()=>({...i()}))}),G(e,a)}),Eo(R(f),()=>{var e;return(e=t.children)==null?m:e}),D(d),G(e,d),Nt()}var rc=new Set([`$$slots`,`$$events`,`$$legacy`]);function ic(e,t){let n=zs(t,rc),r=[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`}]];nc(e,Vs({name:`hash`},()=>n,{get iconNode(){return r}}))}var ac=new Set([`$$slots`,`$$events`,`$$legacy`]);function oc(e,t){let n=zs(t,ac),r=[[`path`,{d:`M10 8h.01`}],[`path`,{d:`M12 12h.01`}],[`path`,{d:`M14 8h.01`}],[`path`,{d:`M16 12h.01`}],[`path`,{d:`M18 8h.01`}],[`path`,{d:`M6 8h.01`}],[`path`,{d:`M7 16h10`}],[`path`,{d:`M8 12h.01`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`}]];nc(e,Vs({name:`keyboard`},()=>n,{get iconNode(){return r}}))}var sc=new Set([`$$slots`,`$$events`,`$$legacy`]);function cc(e,t){let n=zs(t,sc),r=[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`}],[`path`,{d:`M7 11V7a5 5 0 0 1 9.9-1`}]];nc(e,Vs({name:`lock-open`},()=>n,{get iconNode(){return r}}))}var lc=new Set([`$$slots`,`$$events`,`$$legacy`]);function uc(e,t){let n=zs(t,lc),r=[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`}]];nc(e,Vs({name:`lock`},()=>n,{get iconNode(){return r}}))}var dc=new Set([`$$slots`,`$$events`,`$$legacy`]);function fc(e,t){let n=zs(t,dc),r=[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`}],[`circle`,{cx:`12`,cy:`10`,r:`3`}]];nc(e,Vs({name:`map-pin`},()=>n,{get iconNode(){return r}}))}var pc=new Set([`$$slots`,`$$events`,`$$legacy`]);function mc(e,t){let n=zs(t,pc),r=[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`}]];nc(e,Vs({name:`message-square`},()=>n,{get iconNode(){return r}}))}var hc=new Set([`$$slots`,`$$events`,`$$legacy`]);function gc(e,t){let n=zs(t,hc),r=[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`}],[`path`,{d:`M12 22V12`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`}],[`path`,{d:`m7.5 4.27 9 5.15`}]];nc(e,Vs({name:`package`},()=>n,{get iconNode(){return r}}))}var _c=new Set([`$$slots`,`$$events`,`$$legacy`]);function vc(e,t){let n=zs(t,_c),r=[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]];nc(e,Vs({name:`settings`},()=>n,{get iconNode(){return r}}))}var yc=new Set([`$$slots`,`$$events`,`$$legacy`]);function bc(e,t){let n=zs(t,yc),r=[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`}]];nc(e,Vs({name:`star`},()=>n,{get iconNode(){return r}}))}var xc=new Set([`$$slots`,`$$events`,`$$legacy`]);function Sc(e,t){let n=zs(t,xc),r=[[`circle`,{cx:`9`,cy:`12`,r:`3`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`7`}]];nc(e,Vs({name:`toggle-left`},()=>n,{get iconNode(){return r}}))}var Cc=new Set([`$$slots`,`$$events`,`$$legacy`]);function wc(e,t){let n=zs(t,Cc),r=[[`path`,{d:`M10 11v6`}],[`path`,{d:`M14 11v6`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}],[`path`,{d:`M3 6h18`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}]];nc(e,Vs({name:`trash-2`},()=>n,{get iconNode(){return r}}))}var Tc=new Set([`$$slots`,`$$events`,`$$legacy`]);function Ec(e,t){let n=zs(t,Tc),r=[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}],[`path`,{d:`M3 6h18`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}]];nc(e,Vs({name:`trash`},()=>n,{get iconNode(){return r}}))}var Dc=new Set([`$$slots`,`$$events`,`$$legacy`]);function Oc(e,t){let n=zs(t,Dc),r=[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`}],[`circle`,{cx:`12`,cy:`7`,r:`4`}]];nc(e,Vs({name:`user`},()=>n,{get iconNode(){return r}}))}var kc=new Set([`$$slots`,`$$events`,`$$legacy`]);function Ac(e,t){let n=zs(t,kc),r=[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`}]];nc(e,Vs({name:`wrench`},()=>n,{get iconNode(){return r}}))}var jc=new Set([`$$slots`,`$$events`,`$$legacy`]);function Mc(e,t){let n=zs(t,jc),r=[[`path`,{d:`M18 6 6 18`}],[`path`,{d:`m6 6 12 12`}]];nc(e,Vs({name:`x`},()=>n,{get iconNode(){return r}}))}var Nc=new Set([`$$slots`,`$$events`,`$$legacy`]);function Pc(e,t){let n=zs(t,Nc),r=[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`}]];nc(e,Vs({name:`zap`},()=>n,{get iconNode(){return r}}))}var Fc=function(e){return e.Item=`item`,e.Weapon=`weapon`,e.Armor=`armor`,e}({}),Ic=function(e){return e.General=`general`,e.Vars=`vars`,e.Switches=`switches`,e.Inv=`inv`,e.Actors=`actors`,e.Map=`map`,e.CommonEv=`commonev`,e.Locks=`locks`,e.Logs=`logs`,e.Shortcuts=`shortcuts`,e.Settings=`settings`,e}({}),Lc=function(e){return e[e.MHP=0]=`MHP`,e[e.MMP=1]=`MMP`,e[e.ATK=2]=`ATK`,e[e.DEF=3]=`DEF`,e[e.MAT=4]=`MAT`,e[e.MDF=5]=`MDF`,e[e.AGI=6]=`AGI`,e[e.LUK=7]=`LUK`,e}({}),Rc=new WeakMap,zc=new class{constructor(){k(this,Rc,P(I([])))}get toasts(){return H(M(Rc,this))}set toasts(e){F(M(Rc,this),e,!0)}show(e,t=`info`,n=1500){let r=Math.random().toString(),i={id:r,type:t,message:e,duration:n};this.toasts=[...this.toasts,i],setTimeout(()=>{this.dismiss(r)},n)}dismiss(e){this.toasts=this.toasts.filter(t=>t.id!==e)}},Bc=e=>!!e&&typeof e.then==`function`,q={vars:{count:()=>{var e;return!((e=window.$dataSystem)==null||(e=e.variables)==null)&&e.length?window.$dataSystem.variables.length-1:0},name:e=>{var t;let n=(t=window.$dataSystem)==null||(t=t.variables)==null?void 0:t[e];return n?String(n):`Variable ${e}`},get:e=>{var t;return(t=window.$gameVariables)==null?void 0:t.value(e)},set:(e,t)=>{if(!window.$gameVariables)return;let n=q.vars.get(e),r=t;if(typeof n==`number`&&typeof t==`string`){let e=Number(t);!isNaN(e)&&t.trim()!==``&&(r=e)}else typeof n==`boolean`&&typeof t==`string`&&(r=t.toLowerCase()===`true`||t===`1`);window.$gameVariables.setValue(e,r)},list:()=>{let e=q.vars.count(),t=[];for(let n=1;n<=e;n++)t.push({id:n,name:q.vars.name(n),value:q.vars.get(n)});return t}},switches:{count:()=>{var e;return!((e=window.$dataSystem)==null||(e=e.switches)==null)&&e.length?window.$dataSystem.switches.length-1:0},name:e=>{var t;let n=(t=window.$dataSystem)==null||(t=t.switches)==null?void 0:t[e];return n?String(n):`Switch ${e}`},get:e=>{var t;return!!((t=window.$gameSwitches)!=null&&t.value(e))},set:(e,t)=>{window.$gameSwitches&&window.$gameSwitches.setValue(e,!!t)},toggle:e=>{q.switches.set(e,!q.switches.get(e))},list:()=>{let e=q.switches.count(),t=[];for(let n=1;n<=e;n++)t.push({id:n,name:q.switches.name(n),value:q.switches.get(n)});return t}},inv:{table:e=>e===Fc.Item?window.$dataItems||[]:e===Fc.Weapon?window.$dataWeapons||[]:e===Fc.Armor&&window.$dataArmors||[],data:(e,t)=>q.inv.table(e)[t],count:(e,t)=>{let n=q.inv.data(e,t);return n&&window.$gameParty?window.$gameParty.numItems(n):0},maxStack:(e,t)=>{let n=q.inv.data(e,t);return n&&window.$gameParty?window.$gameParty.maxItems(n):99},grant:(e,t,n)=>{let r=q.inv.data(e,t);r&&window.$gameParty&&window.$gameParty.gainItem(r,n,!1)},setCount:(e,t,n)=>{let r=q.inv.count(e,t),i=q.inv.maxStack(e,t);n=Math.max(0,Math.min(i,n)),n!==r&&q.inv.grant(e,t,n-r)},list:e=>{let t=q.inv.table(e),n=[];for(let r=1;rwindow.$gameParty?window.$gameParty.gold():0,max:()=>window.$gameParty&&window.$gameParty.maxGold?window.$gameParty.maxGold():99999999,add:e=>{window.$gameParty&&(e>0?window.$gameParty.gainGold(e):e<0&&window.$gameParty.loseGold(-e))},set:e=>{let t=q.gold.max();e=Math.max(0,Math.min(t,e)),q.gold.add(e-q.gold.get())}},party:{members:()=>window.$gameParty?window.$gameParty.members().map(e=>({id:e.actorId(),name:e.name(),level:typeof e.level==`function`?e.level():e._level||1})):[],steps:()=>window.$gameParty?window.$gameParty.steps():0,playtime:()=>window.Graphics?Math.floor(window.Graphics.frameCount/60):0,recoverAll:()=>{window.$gameParty&&window.$gameParty.members().forEach(e=>{var t;(t=e.recoverAll)==null||t.call(e)})}},map:{list:()=>window.$dataMapInfos?window.$dataMapInfos.filter(e=>!!e).map(e=>({id:e.id,name:e.name,parentId:e.parentId})):[],current:()=>!window.$gameMap||!window.$gamePlayer?null:{mapId:window.$gameMap.mapId(),x:window.$gamePlayer.x,y:window.$gamePlayer.y,dir:window.$gamePlayer.direction()},teleport:(e,t,n,r=0,i=0)=>{window.$gamePlayer&&window.$gamePlayer.reserveTransfer(e,t,n,r,i)},speed:e=>{window.$gamePlayer&&(e=Math.max(1,Math.min(8,e)),window.$gamePlayer.setMoveSpeed(e))},events:()=>!window.$gameMap||typeof window.$gameMap.events!=`function`?[]:(window.$gameMap.events()||[]).map(e=>{let t=typeof e.event==`function`?e.event():null,n=t&&t.name?t.name:`Event ${e._eventId||0}`,r=typeof e.x==`number`?e.x:e._x||0,i=typeof e.y==`number`?e.y:e._y||0;return{id:typeof e.eventId==`function`?e.eventId():e._eventId||0,name:n,x:r,y:i}}),loadMapEvents:async e=>{if(e<=0)return[];try{let t=`data/Map${e.toString().padStart(3,`0`)}.json`,n=await(await fetch(t)).json();return!n||!n.events?[]:n.events.filter(e=>e).map(e=>{let t=e.name||`Event ${e.id}`;if(t.match(/^EV\d+$/i)){if(e.note)t=`${t} (${e.note.split(` +`)[0].trim()})`;else if(e.pages&&e.pages.length>0){let n=e.pages[0].list;if(n&&n.length>0){let e=n.find(e=>e.code===108||e.code===401);if(e&&e.parameters&&e.parameters[0]){let n=String(e.parameters[0]).substring(0,20).trim();n&&(t=`${t} [${n}]`)}}}}return{id:e.id,name:t,x:e.x,y:e.y}})}catch(t){return console.warn(`Failed to load events for map`,e,t),[]}}},commonev:{list:()=>window.$dataCommonEvents?window.$dataCommonEvents.filter(e=>e&&e.name).map(e=>({id:e.id,name:e.name})):[],run:e=>{window.$gameTemp&&window.$gameTemp.reserveCommonEvent(e)}},battle:{inBattle:()=>!window.SceneManager||!window.SceneManager._scene?!1:window.SceneManager._scene.constructor.name===`Scene_Battle`,canExecuteBattleEnd:()=>q.battle.inBattle()&&window.BattleManager&&window.BattleManager._phase!==`battleEnd`,instantWin:()=>{!q.battle.inBattle()||!window.$gameTroop||!window.BattleManager||(window.$gameTroop.members().forEach(e=>{e.isDead()||(e.setHp(0),e.deathStateId&&e.addNewState&&e.addNewState(e.deathStateId()),e.performCollapse&&e.performCollapse(),e.refresh&&e.refresh())}),window.BattleManager.checkBattleEnd())},flee:()=>{!q.battle.inBattle()||!window.BattleManager||window.BattleManager.processAbort()},forceVictory:()=>{!q.battle.canExecuteBattleEnd()||!window.$gameTroop||!window.BattleManager||(window.$gameTroop.members().forEach(e=>{e.deathStateId&&e.addNewState&&e.addNewState(e.deathStateId())}),window.BattleManager.processVictory(),zc.show(`Forced victory from battle!`,`success`))},forceDefeat:()=>{!q.battle.canExecuteBattleEnd()||!window.$gameParty||!window.BattleManager||(window.$gameParty.members().forEach(e=>{e.deathStateId&&e.addNewState&&e.addNewState(e.deathStateId())}),window.BattleManager.processDefeat(),zc.show(`Forced defeat from battle...`,`warn`))},forceEscape:()=>{!q.battle.canExecuteBattleEnd()||!window.$gameParty||!window.BattleManager||!window.SoundManager||(window.$gameParty.performEscape(),window.SoundManager.playEscape(),window.BattleManager._escaped=!0,window.BattleManager.processEscape(),zc.show(`Forced escape from battle`,`success`))},changeAllEnemyHealth:e=>{!q.battle.inBattle()||!window.$gameTroop||(window.$gameTroop.members().forEach(t=>t.setHp(e)),zc.show(`HP to ${e} for all enemies`,`success`))},recoverAllEnemy:()=>{!q.battle.inBattle()||!window.$gameTroop||(window.$gameTroop.members().forEach(e=>{e.setHp(e.mhp),e.setMp(e.mmp),e.maxTp&&e.setTp&&e.setTp(e.maxTp())}),zc.show(`Recovery all enemies`,`success`))},changeAllPartyHealth:e=>{window.$gameParty&&(window.$gameParty.members().forEach(t=>t.setHp(e)),zc.show(`HP to ${e} for all party members`,`success`))},recoverAllParty:()=>{window.$gameParty&&(window.$gameParty.members().forEach(e=>{e.setHp(e.mhp),e.setMp(e.mmp),e.maxTp&&e.setTp&&e.setTp(e.maxTp())}),zc.show(`Recovery all party members`,`success`))}},scene:{gotoTitle:()=>{window.SceneManager&&window.Scene_Title&&window.SceneManager.goto(window.Scene_Title)},toggleSaveScene:()=>{var e;if(!window.SceneManager||!window.Scene_Save||!window.Scene_Load)return;let t=(e=window.SceneManager._scene)==null?void 0:e.constructor;t===window.Scene_Save?window.SceneManager.pop():t===window.Scene_Load?window.SceneManager.goto(window.Scene_Save):window.SceneManager.push(window.Scene_Save)},toggleLoadScene:()=>{var e;if(!window.SceneManager||!window.Scene_Save||!window.Scene_Load)return;let t=(e=window.SceneManager._scene)==null?void 0:e.constructor;t===window.Scene_Load?window.SceneManager.pop():t===window.Scene_Save?window.SceneManager.goto(window.Scene_Load):window.SceneManager.push(window.Scene_Load)},quickSave:(e=1)=>{window.$gameSystem&&window.DataManager?(window.$gameSystem.onBeforeSave(),window.DataManager.saveGame(e),zc.show(`Game Saved - Slot ${e}`,`success`)):zc.show(`Quick Save failed`,`error`)},quickLoad:async(e=1)=>{if(window.DataManager&&window.SceneManager&&window.Scene_Map)try{let t=window.DataManager.loadGame(e);Bc(t)?(await t,q.scene.completeQuickLoad(e)):t?q.scene.completeQuickLoad(e):zc.show(`Quick Load failed`,`error`)}catch(e){console.error(e),zc.show(`Quick Load failed`,`error`)}else zc.show(`Quick Load failed`,`error`)},completeQuickLoad:e=>{var t,n,r,i,a,o;if(!(!window.SceneManager||!window.Scene_Map)){if(window.$gameSystem&&window.$dataSystem&&typeof window.$gameSystem.versionId==`function`&&typeof window.$dataSystem.versionId==`number`&&window.$gameSystem.versionId()!==window.$dataSystem.versionId&&window.$gameMap&&window.$gamePlayer){var s,c;let e=window.$gameMap.mapId(),t=window.$gamePlayer.x,n=window.$gamePlayer.y,r=window.$gamePlayer.direction();window.$gamePlayer.reserveTransfer(e,t,n,r,0),(s=(c=window.$gamePlayer).requestMapReload)==null||s.call(c)}(t=window.SoundManager)==null||(n=t.playLoad)==null||n.call(t),(r=window.SceneManager._scene)==null||(i=r.fadeOutAll)==null||i.call(r),window.SceneManager.goto(window.Scene_Map),(a=window.$gameSystem)==null||(o=a.onAfterLoad)==null||o.call(a),zc.show(`Game Loaded - Slot ${e}`,`success`)}}},system:{openDevTool:()=>{if(typeof window<`u`&&window.require)try{let e=window.require(`nw.gui`);e&&e.Window&&e.Window.get&&e.Window.get().showDevTools()}catch(e){}}}},J={list:()=>window.$dataActors?window.$dataActors.filter(e=>!!e).map(e=>{let t=window.$gameActors?window.$gameActors.actor(e.id):null;return{id:e.id,name:t?t.name():e.name,level:t&&(typeof t.level==`function`?t.level():t._level)||1,inParty:t&&window.$gameParty?window.$gameParty.members().includes(t):!1}}):[],get:e=>{var t;if(!window.$gameActors)return null;let n=window.$gameActors.actor(e);if(!n)return null;let r=[];for(let e=0;e<8;e++)r.push({id:e,value:n.param?n.param(e):0});let i=window.$dataSkills?window.$dataSkills.filter(e=>!!e).map(e=>({id:e.id,name:e.name,learned:n.hasSkill?n.hasSkill(e.id):!1})):[],a=n.equips&&n.equips()?n.equips().map((e,t)=>({slotId:t,name:e?e.name:`Empty`,item:e})):[],o=n.states&&n.states()?n.states().map(e=>({id:e.id,name:e.name})):[];return{id:n.actorId(),name:n.name(),level:typeof n.level==`function`?n.level()||1:n._level||1,exp:n.currentExp?n.currentExp():0,nextExp:n.nextRequiredExp?n.nextRequiredExp():0,hp:n.hp,mp:n.mp,tp:n.tp,mhp:n.mhp,mmp:n.mmp,mtp:n.maxTp?n.maxTp():100,params:r,skills:i,states:o,equips:a,inParty:(t=window.$gameParty)==null?void 0:t.members().includes(n)}},setLevel:(e,t)=>{var n;let r=(n=window.$gameActors)==null?void 0:n.actor(e);r&&r.changeLevel&&r.changeLevel(Math.max(1,Math.min(r.maxLevel?r.maxLevel():99,t)),!1)},setExp:(e,t)=>{var n;let r=(n=window.$gameActors)==null?void 0:n.actor(e);r&&r.changeExp&&r.changeExp(Math.max(0,t),!1)},setHp:(e,t)=>{var n;let r=(n=window.$gameActors)==null?void 0:n.actor(e);r&&r.setHp&&r.setHp(Math.max(0,Math.min(r.mhp,t)))},setMp:(e,t)=>{var n;let r=(n=window.$gameActors)==null?void 0:n.actor(e);r&&r.setMp&&r.setMp(Math.max(0,Math.min(r.mmp,t)))},setTp:(e,t)=>{var n;let r=(n=window.$gameActors)==null?void 0:n.actor(e),i=r&&r.maxTp?r.maxTp():100;r&&r.setTp&&r.setTp(Math.max(0,Math.min(i,t)))},addParam:(e,t,n)=>{var r;let i=(r=window.$gameActors)==null?void 0:r.actor(e);i&&i.addParam&&i.addParam(t,n)},setParam:(e,t,n)=>{var r;let i=(r=window.$gameActors)==null?void 0:r.actor(e);if(!i||!i.param||!i.addParam)return;let a=1;i.paramRate&&(a*=i.paramRate(t)),i.paramBuffRate&&(a*=i.paramBuffRate(t)),a===0&&(a=1);let o=i.paramBase?i.paramBase(t):0,s=i.paramPlus?i.paramPlus(t):0,c=Math.round(n/a)-o-s;i.addParam(t,c)},learnSkill:(e,t)=>{var n;let r=(n=window.$gameActors)==null?void 0:n.actor(e);r&&r.learnSkill&&r.learnSkill(t)},forgetSkill:(e,t)=>{var n;let r=(n=window.$gameActors)==null?void 0:n.actor(e);r&&r.forgetSkill&&r.forgetSkill(t)},recover:e=>{var t;let n=(t=window.$gameActors)==null?void 0:t.actor(e);n&&n.recoverAll&&n.recoverAll()},setName:(e,t)=>{var n;let r=(n=window.$gameActors)==null?void 0:n.actor(e);r&&r.setName&&r.setName(String(t))},addToParty:e=>{window.$gameParty&&window.$gameParty.addActor&&window.$gameParty.addActor(e)},removeFromParty:e=>{window.$gameParty&&window.$gameParty.removeActor&&window.$gameParty.removeActor(e)},listStates:()=>window.$dataStates?window.$dataStates.filter(e=>!!(e&&e.name)):[],addState:(e,t)=>{var n;let r=(n=window.$gameActors)==null?void 0:n.actor(e);r&&r.addState&&r.addState(t)},removeState:(e,t)=>{var n;let r=(n=window.$gameActors)==null?void 0:n.actor(e);r&&r.removeState&&r.removeState(t)},clearStates:e=>{var t;let n=(t=window.$gameActors)==null?void 0:t.actor(e);n&&n.clearStates&&n.clearStates()}},Y=I({vars:new Map,switches:new Map,items:new Map,gold:null,stats:new Map,noclip:!1}),Vc=!1,Hc=null,X={install:()=>{if(!Vc&&!(typeof window>`u`)&&!window.__FORGE_LOCKS__){if(window.__FORGE_LOCKS__=!0,window.Game_Variables&&window.Game_Variables.prototype.setValue){let e=window.Game_Variables.prototype.setValue;window.Game_Variables.prototype.setValue=function(t,n){Y.vars.has(t)&&(n=Y.vars.get(t)),e.call(this,t,n)}}if(window.Game_Switches&&window.Game_Switches.prototype.setValue){let e=window.Game_Switches.prototype.setValue;window.Game_Switches.prototype.setValue=function(t,n){Y.switches.has(t)&&(n=Y.switches.get(t)),e.call(this,t,n)}}if(window.Game_Party&&window.Game_Party.prototype.gainGold&&(Hc=window.Game_Party.prototype.gainGold,window.Game_Party.prototype.gainGold=function(e){Y.gold===null&&Hc.call(this,e)}),window.Scene_Base&&window.Scene_Base.prototype.update){let e=window.Scene_Base.prototype.update;window.Scene_Base.prototype.update=function(){e.call(this),X.tick()}}if(window.DataManager){if(window.DataManager.setupNewGame){let e=window.DataManager.setupNewGame;window.DataManager.setupNewGame=function(...t){e.apply(this,t)}}if(window.DataManager.extractSaveContents){let e=window.DataManager.extractSaveContents;window.DataManager.extractSaveContents=function(...t){let n=e.apply(this,t);return X.applyValueLocks(),n}}}X.loadFromStorage(),Vc=!0}},saveToStorage:()=>{try{let e={vars:Array.from(Y.vars.entries()),switches:Array.from(Y.switches.entries()),items:Array.from(Y.items.entries()),gold:Y.gold,stats:Array.from(Y.stats.entries()),noclip:Y.noclip};localStorage.setItem(`forge:locks`,JSON.stringify(e))}catch(e){}},loadFromStorage:()=>{try{let e=localStorage.getItem(`forge:locks`);if(e){let t=JSON.parse(e);Y.vars=new Map(t.vars||[]),Y.switches=new Map(t.switches||[]),Y.items=new Map(t.items||[]),Y.gold=t.gold===void 0?null:t.gold,Y.stats=new Map(t.stats||[]),t.noclip&&X.setNoclip(!0,!0)}}catch(e){}},tick:()=>{if(X.applyValueLocks(),Y.noclip&&window.$gamePlayer&&!window.$gamePlayer.isThrough()&&window.$gamePlayer.setThrough(!0),Y.gold!==null&&window.$gameParty){let e=window.$gameParty.gold();e!==Y.gold&&Hc&&Hc.call(window.$gameParty,Y.gold-e)}if(Y.stats.size>0&&window.$gameActors)for(let[e,t]of Y.stats.entries()){let[n,r]=e.split(`:`),i=parseInt(n,10),a=window.$gameActors.actor(i);if(a){if(r===`hp`&&a.hp!==t)J.setHp(i,t);else if(r===`mp`&&a.mp!==t)J.setMp(i,t);else if(r===`tp`&&a.tp!==t)J.setTp(i,t);else if(r===`level`&&(typeof a.level==`function`?a.level():a._level)!==t)J.setLevel(i,t);else if(r===`exp`&&(a.currentExp?a.currentExp():0)!==t)J.setExp(i,t);else if(r.startsWith(`param_`)){let e=parseInt(r.split(`_`)[1],10);a.param&&a.param(e)!==t&&J.setParam(i,e,t)}}}if(Y.items.size>0&&window.$gameParty)for(let[e,t]of Y.items.entries()){let[n,r]=e.split(`:`),i=parseInt(r,10),a=n;q.inv.setCount(a,i,t)}},applyValueLocks:()=>{if(Y.vars.size>0&&window.$gameVariables)for(let[e,t]of Y.vars.entries())window.$gameVariables.value(e)!==t&&window.$gameVariables.setValue(e,t);if(Y.switches.size>0&&window.$gameSwitches)for(let[e,t]of Y.switches.entries())window.$gameSwitches.value(e)!==t&&window.$gameSwitches.setValue(e,t)},freezeVar:(e,t)=>{t?Y.vars.set(e,q.vars.get(e)):Y.vars.delete(e),Y.vars=new Map(Y.vars),X.saveToStorage()},freezeSwitch:(e,t)=>{t?Y.switches.set(e,q.switches.get(e)):Y.switches.delete(e),Y.switches=new Map(Y.switches),X.saveToStorage()},freezeItem:(e,t,n)=>{let r=`${e}:${t}`;n?Y.items.set(r,q.inv.count(e,t)):Y.items.delete(r),Y.items=new Map(Y.items),X.saveToStorage()},freezeGold:e=>{e?Y.gold=q.gold.get():Y.gold=null,X.saveToStorage()},freezeStat:(e,t,n)=>{let r=`${e}:${t}`;if(n){let n=J.get(e),i=0;if(n){if(t===`hp`||t===`mp`||t===`tp`||t===`level`||t===`exp`)i=n[t];else if(t.startsWith(`param_`)){let e=parseInt(t.split(`_`)[1],10),r=n.params.find(t=>t.id===e);r&&(i=r.value)}}Y.stats.set(r,i)}else Y.stats.delete(r);Y.stats=new Map(Y.stats),X.saveToStorage()},setNoclip:(e,t=!1)=>{Y.noclip=e,window.$gamePlayer&&window.$gamePlayer.setThrough(e),t||zc.show(`Noclip: ${e?`ON`:`OFF`}`,e?`success`:`info`)},clearAll:()=>{Y.vars.clear(),Y.vars=new Map,Y.switches.clear(),Y.switches=new Map,Y.items.clear(),Y.items=new Map,Y.stats.clear(),Y.stats=new Map,Y.gold=null,X.setNoclip(!1,!0),X.saveToStorage()},summary:()=>{let e=[];return Y.vars.forEach((t,n)=>e.push({type:`var`,id:n,label:q.vars.name(n),value:t})),Y.switches.forEach((t,n)=>e.push({type:`switch`,id:n,label:q.switches.name(n),value:t})),Y.items.forEach((t,n)=>{let[r,i]=n.split(`:`),a=parseInt(i,10),o=q.inv.data(r,a);e.push({type:`item`,key:n,label:o?o.name:n,value:t})}),Y.gold!==null&&e.push({type:`gold`,id:`gold`,label:`Gold`,value:Y.gold}),Y.stats.forEach((t,n)=>{var r;let[i,a]=n.split(`:`),o=parseInt(i,10),s=((r=J.get(o))==null?void 0:r.name)||`Actor ${o}`,c=`${s} ${a.toUpperCase()}`,l=`stat`;a.startsWith(`param_`)&&(l=`param`,c=`${s} ${[`Max HP`,`Max MP`,`Attack`,`Defense`,`M. Attack`,`M. Defense`,`Agility`,`Luck`][parseInt(a.split(`_`)[1],10)]||a}`),e.push({type:l,key:n,label:c,value:t})}),e}},Z=I({god:!1,ohko:!1,noEncounter:!1,speed:1,speedBoost:2,speedUseKey:!0,speedHeld:!1,messageSkip:!1}),Uc=!1,Wc={install:()=>{if(!Uc&&!(typeof window>`u`)&&!window.__FORGE_CHEATS__){if(window.__FORGE_CHEATS__=!0,window.Game_Action&&window.Game_Action.prototype.executeHpDamage){let e=window.Game_Action.prototype.executeHpDamage;window.Game_Action.prototype.executeHpDamage=function(t,n){Z.god&&t.isActor()&&n>0&&(n=0),Z.ohko&&this.subject().isActor()&&t.isEnemy()&&(n=t.hp),e.call(this,t,n)}}if(window.Game_Battler&&window.Game_Battler.prototype.gainHp){let e=window.Game_Battler.prototype.gainHp;window.Game_Battler.prototype.gainHp=function(t){Z.god&&this.isActor()&&t<0&&(t=0),e.call(this,t)}}if(window.Game_Actor&&window.Game_Actor.prototype.executeFloorDamage){let e=window.Game_Actor.prototype.executeFloorDamage;window.Game_Actor.prototype.executeFloorDamage=function(){Z.god||e.call(this)}}if(window.Game_Player&&window.Game_Player.prototype.encounterProgressValue){let e=window.Game_Player.prototype.encounterProgressValue;window.Game_Player.prototype.encounterProgressValue=function(){return Z.noEncounter?0:e.call(this)}}if(window.SceneManager&&window.SceneManager.updateScene){let e=window.SceneManager.updateScene,t=0,n=e=>{if(e.isCurrentSceneStarted){if(!e.isCurrentSceneStarted())return!1}else if(e._scene&&e._scene.isStarted&&!e._scene.isStarted())return!1;return!(e.isSceneChanging&&e.isSceneChanging()||window.$gamePlayer&&window.$gamePlayer.isTransferring&&window.$gamePlayer.isTransferring()||window.DataManager&&window.DataManager.isMapLoaded&&!window.DataManager.isMapLoaded())};window.SceneManager.updateScene=function(){let r=Z.speedHeld?Z.speedBoost:Z.speed;if(Z.speedUseKey&&!Z.speedHeld&&(r=1),r>=1)if(e.call(this),r>1&&this._scene&&typeof this._scene.update==`function`&&n(this)){t+=r-1;let e=0;for(;t>=1&&e++<64;){--t;try{this._scene.update()}catch(e){t=0;break}}}else t=0;else if(t+=r,t>=1)--t,e.call(this);else if(this._scene){let t=this._scene.update;this._scene.update=function(){};try{e.call(this)}finally{this._scene.update=t}}}}if(window.Window_Message&&window.Window_Message.prototype.updateShowFast){let e=window.Window_Message.prototype.updateShowFast;window.Window_Message.prototype.updateShowFast=function(){e.call(this),Z.messageSkip&&(this._showFast=!0,this._pauseSkip=!0)}}if(window.Window_Message&&window.Window_Message.prototype.updateInput){let e=window.Window_Message.prototype.updateInput;window.Window_Message.prototype.updateInput=function(){let t=e.call(this);return this.pause&&Z.messageSkip?(this.pause=!1,this._textState||this.terminateMessage(),!0):t}}if(window.Window_ScrollText&&window.Window_ScrollText.prototype.scrollSpeed){let e=window.Window_ScrollText.prototype.scrollSpeed;window.Window_ScrollText.prototype.scrollSpeed=function(){let t=e.call(this);return Z.messageSkip&&(t*=100),t}}if(window.Window_BattleLog&&window.Window_BattleLog.prototype.messageSpeed){let e=window.Window_BattleLog.prototype.messageSpeed;window.Window_BattleLog.prototype.messageSpeed=function(){let t=e.call(this);return Z.messageSkip&&(t=1),t}}Uc=!0}},setGod:e=>{Z.god=e},setOhko:e=>{Z.ohko=e},setNoEncounter:e=>{Z.noEncounter=e},setSpeed:e=>{Z.speed=e},setSpeedBoost:e=>{Z.speedBoost=e},setSpeedUseKey:e=>{Z.speedUseKey=e},startSpeedHold:()=>{Z.speedHeld=!0},stopSpeedHold:()=>{Z.speedHeld=!1},setMessageSkip:e=>{Z.messageSkip=e}},Gc={backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,"pause/break":19,capslock:20,esc:27,space:32,pageup:33,pagedown:34,end:35,home:36,left:37,up:38,right:39,down:40,insert:45,delete:46,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,a:65,b:66,c:67,d:68,e:69,f:70,g:71,h:72,i:73,j:74,k:75,l:76,m:77,n:78,o:79,p:80,q:81,r:82,s:83,t:84,u:85,v:86,w:87,x:88,y:89,z:90,meta:91,rightclick:93,numpad0:96,numpad1:97,numpad2:98,numpad3:99,numpad4:100,numpad5:101,numpad6:102,numpad7:103,numpad8:104,numpad9:105,"numpad*":106,"numpad+":107,"numpad-":109,"numpad.":110,"numpad/":111,f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123,numlock:144,scrolllock:145,mycomputer:182,mycalculator:183,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222},Kc={};for(let e of Object.keys(Gc))Kc[e.toLowerCase()]=Gc[e];var qc={};for(let e of Object.keys(Kc))qc[Kc[e]]=e;var Jc=new Set([17,18,16,91]),Yc=class e{constructor(e,t,n,r,i){S(this,`code`,void 0),S(this,`ctrl`,void 0),S(this,`alt`,void 0),S(this,`shift`,void 0),S(this,`meta`,void 0),this.code=e,this.ctrl=t,this.alt=n,this.shift=r,this.meta=i}static createEmpty(){return new e(256,!1,!1,!1,!1)}static fromKey(t){return new e(t.code,t.ctrl,t.alt,t.shift,t.meta)}static fromString(t){if(!t||t===``)return e.createEmpty();let n=t.toLowerCase().split(` `);if(n.length===0)throw Error(`No keymap found`);let r=null,i=!1,a=!1,o=!1,s=!1;for(let e of n)switch(e=e.trim(),e){case`ctrl`:case`control`:i=!0;break;case`alt`:a=!0;break;case`shift`:o=!0;break;case`meta`:s=!0;break;default:if(r!==null)throw Error(`Cannot combine multiple standard keys`);if(!Object.prototype.hasOwnProperty.call(Kc,e))throw Error(`Unknown key: ${e}`);r=Kc[e]}return r===null&&(r=256),new e(r,i,a,o,s)}static fromEvent(t){var k=window.__dazedKeyCode(t);return Jc.has(k)?e._fromCombiningAloneEvent(t):new e(k,t.ctrlKey,t.altKey,t.shiftKey,t.metaKey)}static _fromCombiningAloneEvent(t){return new e(256,t.keyCode===17||t.ctrlKey,t.keyCode===18||t.altKey,t.keyCode===16||t.shiftKey,t.keyCode===91||t.metaKey)}isEmpty(){return this.code===256&&!this.ctrl&&!this.alt&&!this.shift&&!this.meta}isCombiningKey(){return this.code===256&&!this.isEmpty()}equals(e){return this.code===e.code&&this.ctrl===e.ctrl&&this.alt===e.alt&&this.shift===e.shift&&this.meta===e.meta}contains(e){return(!e.ctrl||this.ctrl)&&(!e.alt||this.alt)&&(!e.shift||this.shift)&&(!e.meta||this.meta)&&(e.isCombiningKey()||e.code===this.code)}countPressingKeys(){let e=0;return this.code!==256&&(e+=1),this.ctrl&&(e+=1),this.alt&&(e+=1),this.shift&&(e+=1),this.meta&&(e+=1),e}asStringArray(){if(this.isEmpty())return[];let e=[];return this.ctrl&&e.push(`ctrl`),this.alt&&e.push(`alt`),this.shift&&e.push(`shift`),this.meta&&e.push(`meta`),this.code!==256&&e.push(qc[this.code]||`key_${this.code}`),e}adjustCombiningKey(e){this.ctrl=e.ctrlKey,this.alt=e.altKey,this.shift=e.shiftKey,this.meta=e.metaKey}add(e){if(Jc.has(e)){this._setCombiningKey(e,!0);return}this.code=e}remove(e){if(Jc.has(e)){this._setCombiningKey(e,!1);return}this.code===e&&(this.code=256)}_setCombiningKey(e,t){switch(e){case 17:this.ctrl=t;break;case 18:this.alt=t;break;case 16:this.shift=t;break;case 91:this.meta=t;break}}capitalize(e){return e.length===0?``:e.length===1?e.charAt(0).toUpperCase():e.charAt(0).toUpperCase()+e.slice(1)}asString(){return this.asStringArray().join(` `)}asDisplayString(){return this.asStringArray().map(e=>this.capitalize(e)).join(` + `)}},Q=I({visible:!1,activeTab:Ic.General,targetActorId:null,targetActorStat:null,targetVarId:null,targetSwitchId:null,targetItemKey:null}),$={currentKey:Yc.createEmpty(),shortcuts:[],activeShortcutIds:new Set,init:e=>{let t=localStorage.getItem(`forge:shortcuts`),n={};if(t)try{n=JSON.parse(t)}catch(e){}$.shortcuts=e.map(e=>{let t=n[e.id];return{...e,keyStr:(t==null?void 0:t.keyStr)===void 0?e.keyStr:t.keyStr,enabled:(t==null?void 0:t.enabled)===void 0?e.enabled:t.enabled,params:(t==null?void 0:t.params)||e.params}}),window.addEventListener(`keydown`,$.onKeyDown.bind($),{capture:!0}),window.addEventListener(`keyup`,$.onKeyUp.bind($),{capture:!0})},save:()=>{let e={};$.shortcuts.forEach(t=>{e[t.id]={keyStr:t.keyStr,enabled:t.enabled,params:t.params}}),localStorage.setItem(`forge:shortcuts`,JSON.stringify(e))},get:e=>$.shortcuts.find(t=>t.id===e),update:(e,t)=>{let n=$.get(e);n&&(Object.assign(n,t),$.save())},_isFocusedOnInput:()=>{let e=document.activeElement;for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e&&(e.tagName===`INPUT`||e.tagName===`TEXTAREA`||e.isContentEditable)},_hasSelection:()=>{var e;if(!Q.visible)return!1;let t=((e=window.getSelection())==null?void 0:e.toString())||``;if(!t){let e=document.getElementById(`forge-mvmz-host`);e&&e.shadowRoot&&e.shadowRoot.getSelection&&(t=e.shadowRoot.getSelection().toString()||``)}return t.trim().length>0},onKeyDown:e=>{if(!$._isFocusedOnInput()&&!$._hasSelection()){if(e.repeat){let t=!1;for(let e of $.activeShortcutIds){let n=$.get(e);n&&n.onRepeat&&(n.onRepeat(n.params),t=!0)}t&&(e.preventDefault(),e.stopPropagation());return}$.currentKey.add(window.__dazedKeyCode(e)),$.currentKey.adjustCombiningKey(e),$.processTransitions(e)}},onKeyUp:e=>{$._isFocusedOnInput()||($.currentKey.remove(window.__dazedKeyCode(e)),$.currentKey.adjustCombiningKey(e),$.processTransitions(e))},processTransitions:e=>{let t=new Set;for(let e of $.shortcuts)if(!(!e.enabled||!e.keyStr))try{let n=Yc.fromString(e.keyStr),r=!1;r=e.combiningKeyAlone?$.currentKey.contains(n):n.equals($.currentKey),r&&t.add(e.id)}catch(t){console.error(`[FORGE] Error parsing keyStr for ${e.id}:`,t)}let n=Array.from($.activeShortcutIds);for(let e of n)if(!t.has(e)){let t=$.get(e);if(t){var r;(r=t.onLeave)==null||r.call(t,t.params)}$.activeShortcutIds.delete(e)}let i=!1;for(let e of t)if(!$.activeShortcutIds.has(e)){let t=$.get(e);if(t){var a;(a=t.onEnter)==null||a.call(t,t.params),$.activeShortcutIds.add(e),i=!0}}i&&e.type===`keydown`&&(e.preventDefault(),e.stopPropagation())}},Xc=I({inactiveOpacity:80,autoOpen:!1,rememberPosition:!0,favorites:{},showLauncher:!0,quickSaveSlot:1}),Zc={load:()=>{try{let e=localStorage.getItem(`forge:config`);if(e){let t=JSON.parse(e);typeof t.inactiveOpacity==`number`&&(Xc.inactiveOpacity=t.inactiveOpacity),typeof t.autoOpen==`boolean`&&(Xc.autoOpen=t.autoOpen),typeof t.rememberPosition==`boolean`&&(Xc.rememberPosition=t.rememberPosition),t.favorites&&typeof t.favorites==`object`&&(Xc.favorites=t.favorites),typeof t.showLauncher==`boolean`&&(Xc.showLauncher=t.showLauncher),typeof t.quickSaveSlot==`number`&&(Xc.quickSaveSlot=t.quickSaveSlot)}}catch(e){}},save:()=>{localStorage.setItem(`forge:config`,JSON.stringify({inactiveOpacity:Xc.inactiveOpacity,autoOpen:Xc.autoOpen,rememberPosition:Xc.rememberPosition,favorites:Xc.favorites,showLauncher:Xc.showLauncher,quickSaveSlot:Xc.quickSaveSlot}))},toggleFavorite:(e,t)=>{Xc.favorites[e]||(Xc.favorites[e]=[]);let n=Xc.favorites[e].indexOf(t);n===-1?Xc.favorites[e].push(t):Xc.favorites[e].splice(n,1),Zc.save()},isFavorite:(e,t)=>{var n;return((n=Xc.favorites[e])==null?void 0:n.includes(t))||!1},resetAll:()=>{confirm(`Are you sure you want to reset all Forge settings, locks, and saved data? This cannot be undone.`)&&(localStorage.clear(),window.location.reload())}},Qc=I({entries:[]}),$c=!1,el=1,tl={install:()=>{if(!$c&&!(typeof window>`u`)&&!window.__FORGE_LOGS__){if(window.__FORGE_LOGS__=!0,window.Game_Message&&window.Game_Message.prototype.add){let e=window.Game_Message.prototype.add;window.Game_Message.prototype.add=function(t){e.call(this,t);let n=``;typeof this.speakerName==`function`&&(n=this.speakerName()||``),tl.addEntry(n,t)}}$c=!0}},addEntry:(e,t)=>{let n=t;if(n=n.replace(/\\\\/g,`\x1B`),n=n.replace(/\\x1b/g,`\x1B`),n=n.replace(/\\V\[(\d+)\]/gi,(e,t)=>window.$gameVariables?String(window.$gameVariables.value(parseInt(t))):``),n=n.replace(/\\N\[(\d+)\]/gi,(e,t)=>{var n;return window.$gameActors&&((n=window.$gameActors.actor(parseInt(t)))==null?void 0:n.name())||``}),n=n.replace(/\\P\[(\d+)\]/gi,(e,t)=>{let n=(window.$gameParty?window.$gameParty.members():[])[parseInt(t)-1];return n?n.name():``}),n=n.replace(/\\G/gi,()=>window.TextManager?window.TextManager.currencyUnit:``),n=n.replace(/\x1bC\[\d+\]/gi,``),n=n.replace(/\x1bI\[\d+\]/gi,``),n=n.replace(/\x1b[\\{\\}\.\|!><\^]/g,``),n=n.replace(/\x1b[A-Z]\[.*?\]/gi,``),n=n.replace(/\x1b/g,``),!e){let t=n.match(/^\\n<([^>]+)>/i);t&&(e=t[1],n=n.replace(/^\\n<([^>]+)>/i,``))}if(n=n.replace(/\n/g,` `),n=n.replace(/\s+/g,` `),n=n.trim(),!n)return;let r=Date.now(),i=Qc.entries[Qc.entries.length-1];i&&i.speaker===e&&r-i.timestamp<100?(i.text+=` ${n}`,i.timestamp=r):Qc.entries.push({id:el++,speaker:e,text:n,timestamp:r})},clear:()=>{Qc.entries=[]}},nl=[{id:`toggle_ui`,name:`Toggle Cheat UI`,desc:`Show/Hide the cheat panel`,keyStr:`f8`,enabled:!0,required:!0,onEnter:()=>Q.visible=!Q.visible},{id:`toggle_save_recall`,name:`Toggle Save Locations Tab`,desc:`Open/close panel on Bookmarks`,keyStr:`Ctrl M`,enabled:!0,onEnter:()=>{Q.visible=!0,Q.activeTab=Ic.Map}},{id:`quick_save`,name:`Quick Save`,desc:`Quick save to configured slot`,keyStr:`Ctrl S`,enabled:!0,onEnter:()=>q.scene.quickSave(Xc.quickSaveSlot)},{id:`quick_load`,name:`Quick Load`,desc:`Quick load from configured slot`,keyStr:`Ctrl Q`,enabled:!0,onEnter:()=>q.scene.quickLoad(Xc.quickSaveSlot)},{id:`open_save_scene`,name:`Open Save Scene`,desc:`Push or pop Save scene`,keyStr:`Ctrl [`,enabled:!0,onEnter:()=>q.scene.toggleSaveScene()},{id:`open_load_scene`,name:`Open Load Scene`,desc:`Push or pop Load scene`,keyStr:`Ctrl ]`,enabled:!0,onEnter:()=>q.scene.toggleLoadScene()},{id:`goto_title`,name:`Go to Title`,desc:`Return to title screen`,keyStr:`Ctrl T`,enabled:!0,onEnter:()=>q.scene.gotoTitle()},{id:`force_victory`,name:`Force Victory`,desc:`Force battle victory`,keyStr:`Ctrl V`,enabled:!0,onEnter:()=>q.battle.forceVictory()},{id:`force_defeat`,name:`Force Defeat`,desc:`Force battle defeat`,keyStr:`Ctrl D`,enabled:!0,onEnter:()=>q.battle.forceDefeat()},{id:`force_escape`,name:`Force Escape`,desc:`Force battle escape`,keyStr:`Ctrl E`,enabled:!0,onEnter:()=>q.battle.forceEscape()},{id:`toggle_noclip`,name:`Toggle Noclip`,desc:`Walk through walls`,keyStr:`Alt W`,enabled:!0,onEnter:()=>X.setNoclip(!Y.noclip)},{id:`enemy_wound`,name:`Enemies HP to 1`,desc:`Wound all active enemies`,keyStr:`Alt 1`,enabled:!0,onEnter:()=>q.battle.changeAllEnemyHealth(1)},{id:`enemy_recovery`,name:`Recover Enemies`,desc:`Fully recover enemies`,keyStr:`Alt 0`,enabled:!0,onEnter:()=>q.battle.recoverAllEnemy()},{id:`party_wound`,name:`Party HP to 1`,desc:`Wound all party members`,keyStr:`Alt 2`,enabled:!0,onEnter:()=>q.battle.changeAllPartyHealth(1)},{id:`party_recovery`,name:`Recover Party`,desc:`Fully recover party members`,keyStr:`Alt 9`,enabled:!0,onEnter:()=>q.battle.recoverAllParty()},{id:`trigger_encounter`,name:`Trigger Encounter`,desc:`Next step triggers random battle`,keyStr:``,enabled:!0,onEnter:()=>{window.$gamePlayer&&(window.$gamePlayer._encounterCount=0)}},{id:`speed_hold`,name:`Speed Hold Key`,desc:`Hold to fast forward game`,keyStr:`Ctrl`,enabled:!0,combiningKeyAlone:!0,onEnter:()=>Wc.startSpeedHold(),onLeave:()=>Wc.stopSpeedHold()},{id:`skip_message`,name:`Skip Message Key`,desc:`Hold to skip dialogs`,keyStr:``,enabled:!0,combiningKeyAlone:!0,onEnter:()=>Wc.setMessageSkip(!0),onLeave:()=>Wc.setMessageSkip(!1)},{id:`open_dev_tool`,name:`Open Dev Tools`,desc:`Show Nw.js developer tools`,keyStr:`F12`,enabled:!0,onEnter:()=>q.system.openDevTool()}],rl=W(``);function il(e,t){var n=rl();U(`mousedown`,n,function(...e){var n;(n=t.onmousedown)==null||n.apply(this,e)}),G(e,n)}Wa([`mousedown`]);var al=W(``);function ol(e,t){Mt(t,!0);let n=P(0),r=P(0);Ws(()=>{try{let e=JSON.parse(localStorage.getItem(`forge:launcherPos`)||`null`);e?(F(n,e.x,!0),F(r,e.y,!0)):(F(n,(window.innerWidth||800)-56),F(r,(window.innerHeight||600)-56))}catch(e){F(n,100),F(r,100)}});let i=P(!1),a=P(0),o=P(0),s=P(0),c=P(0),l=P(!1),u=e=>{if(!H(i))return;e.stopPropagation(),e.preventDefault();let t=e.clientX-H(a),u=e.clientY-H(o);Math.abs(t)+Math.abs(u)>3&&F(l,!0),F(n,Math.max(4,Math.min(window.innerWidth-46,H(s)+t)),!0),F(r,Math.max(4,Math.min(window.innerHeight-46,H(c)+u)),!0)},d=e=>{H(i)&&(e.stopPropagation(),e.preventDefault()),F(i,!1),window.removeEventListener(`mousemove`,u,!0),window.removeEventListener(`mouseup`,d,!0);try{localStorage.setItem(`forge:launcherPos`,JSON.stringify({x:H(n),y:H(r)}))}catch(e){}setTimeout(()=>{F(l,!1)},0)},f=e=>{e.preventDefault(),F(i,!0),F(l,!1),F(a,e.clientX,!0),F(o,e.clientY,!0),F(s,H(n),!0),F(c,H(r),!0),window.addEventListener(`mousemove`,u,!0),window.addEventListener(`mouseup`,d,!0)},p=()=>{H(l)||(Q.visible=!Q.visible)};var m=eo(),h=_i(m),g=e=>{var t=al();Ac(L(t),{size:20}),D(t),z(()=>{var e,i;return Xo(t,`left: ${(e=H(n))==null?``:e}px; top: ${(i=H(r))==null?``:i}px;`)}),U(`mousedown`,t,e=>{e.stopPropagation(),f(e)}),U(`click`,t,e=>{e.stopPropagation(),p()}),G(e,t)};mo(h,e=>{Xc.showLauncher&&e(g)}),G(e,m),Nt()}Wa([`mousedown`,`click`]);var sl=W(``),cl=W(`Nothing here`),ll=W(` `);function ul(e,t){Mt(t,!0);let n=Hs(t,`items`,19,()=>[]),r=Hs(t,`itemHeight`,3,32),i=Hs(t,`containerHeight`,3,400),a=P(0),o=P(void 0),s=Wn(()=>n().length*r()),c=Wn(()=>Math.floor(H(a)/r())),l=Wn(()=>Math.min(n().length-1,H(c)+Math.ceil(i()/r())+2)),u=Wn(()=>n().slice(H(c),H(l)+1).map((e,t)=>({...e,_index:H(c)+t}))),d=e=>{F(a,e.target.scrollTop,!0)};var f={resetScroll:()=>{H(o)&&(H(o).scrollTop=0)},scrollToBottom:()=>{H(o)&&(H(o).scrollTop=H(o).scrollHeight)},scrollToIndex:e=>{setTimeout(()=>{H(o)&&(F(a,e*r()),H(o).scrollTop=e*r())},100)}},p=ll(),m=L(p),h=L(m);yo(h,21,()=>H(u),e=>e.id,(e,n)=>{var i=sl();Eo(L(i),()=>t.itemTemplate,()=>H(n),()=>H(n)._index),D(i),z(()=>{var e;return Xo(i,`height: ${(e=r())==null?``:e}px;`)}),G(e,i)}),D(h),D(m);var g=R(m,2),_=e=>{G(e,cl())};return mo(g,e=>{n().length===0&&e(_)}),D(p),Ps(p,e=>F(o,e),()=>H(o)),z(()=>{var e;Xo(m,`height: ${(e=H(s))==null?``:e}px;`),Xo(h,`transform: translateY(${H(c)*r()}px);`)}),Ua(`scroll`,p,d),G(e,p),Nt(f)}var dl=W(`- +`);function fl(e,t){Mt(t,!0);let n=Hs(t,`value`,15,0),r=Hs(t,`min`,19,()=>-1/0),i=Hs(t,`max`,3,1/0),a=P(I(String(n())));Mi(()=>{F(a,String(n()),!0)});let o=()=>{var e;let o=parseFloat(H(a));isNaN(o)&&(o=n()),o=Math.max(r(),Math.min(i(),o)),n(o),F(a,String(o),!0),(e=t.onchange)==null||e.call(t,n())},s=(e,o)=>{var s;o.shiftKey&&(e*=10);let c=n()+e;c=Math.max(r(),Math.min(i(),c)),n(c),F(a,String(c),!0),(s=t.onchange)==null||s.call(t,n())},c=e=>{e.stopPropagation(),e.key===`Enter`?(o(),e.target.blur()):e.key===`Escape`&&(F(a,String(n()),!0),e.target.blur())};var l=dl(),u=L(l),d=R(u,2);us(d);var f=R(d,2);D(l),U(`click`,u,e=>s(-1,e)),Ua(`blur`,d,o),U(`keydown`,d,c),Cs(d,()=>H(a),e=>F(a,e)),U(`click`,f,e=>s(1,e)),G(e,l),Nt()}Wa([`click`,`keydown`]);var pl=W(``);function ml(e,t){Mt(t,!0);let n=Hs(t,`locked`,3,!1);var r=pl(),i=L(r),a=e=>{uc(e,{size:14})},o=e=>{cc(e,{size:14})};mo(i,e=>{n()?e(a):e(o,-1)}),D(r),z(()=>{Jo(r,1,`flex h-6 w-6 shrink-0 items-center justify-center rounded transition-colors focus:outline-none ${n()?`bg-frozen/20 text-frozen hover:bg-frozen/30`:`hover:bg-border text-gray-500 hover:text-gray-300`}`),ps(r,`title`,n()?`Unfreeze`:`Freeze`),ps(r,`aria-label`,n()?`Unfreeze state`:`Freeze state`)}),U(`click`,r,()=>{var e;return(e=t.ontoggle)==null?void 0:e.call(t,!n())}),G(e,r),Nt()}Wa([`click`]);var hl=W(`TrueFalse`),gl=W(``),_l=W(` `),vl=W(` `);function yl(e,t){Mt(t,!0);let n=P(I([])),r=P(I([])),i=P(``),a=P(void 0);Mi(()=>{if(Q.targetVarId!==null&&H(a)&&H(r).length>0){let e=H(r).findIndex(e=>e.id===Q.targetVarId);e!==-1&&H(a).scrollToIndex(e),Q.targetVarId=null}});let o,s=P(!1),c=new Set,l=I({}),u=()=>{if(!H(i).trim())c=new Set(H(n).map(e=>e.id));else{let e=H(i).trim().toLowerCase(),t=H(n).filter(t=>String(t.id)===e||t.name.toLowerCase().includes(e)||t.value!==void 0&&t.value!==null&&String(t.value).toLowerCase().includes(e));c=new Set(t.map(e=>e.id))}},d=()=>{F(r,H(n).filter(e=>c.has(e.id)).sort((e,t)=>{let n=Zc.isFavorite(`variables`,e.id),r=Zc.isFavorite(`variables`,t.id);return n&&!r?-1:!n&&r?1:e.id-t.id}),!0)},f=()=>{F(n,q.vars.list(),!0),u(),d()},p=e=>{F(i,e.target.value,!0),clearTimeout(o),o=setTimeout(()=>{u(),d()},300)};Ws(()=>{f();let e=setInterval(()=>{H(s)||(F(n,q.vars.list(),!0),d())},1e3);return()=>clearInterval(e)});let h=(e,t)=>{q.vars.set(e,t),Y.vars.has(e)&&X.freezeVar(e,!0);let r=H(n).find(t=>t.id===e);r&&(r.value=t)};var g=vl(),_=L(g),v=L(_);us(v);var y=R(v,2),b=L(y);D(y),D(_);var x=R(_,2);Ps(ul(L(x),{get items(){return H(r)},itemHeight:36,itemTemplate:(e,t=m)=>{let r=Wn(()=>l[t().id]||typeof t().value);var i=_l(),a=L(i),o=L(a,!0);D(a);var c=R(a,2),u=L(c),f=L(u,!0);D(u),D(c);var p=R(c,2),g=L(p),_=L(g);{let e=Wn(()=>Zc.isFavorite(`variables`,t().id)?`fill-current`:``);bc(_,{size:16,get class(){return H(e)}})}D(g);var v=R(g,2),y=L(v,!0);D(v);var b=R(v,2),x=e=>{{let n=Wn(()=>Number(t().value)||0);fl(e,{get value(){return H(n)},onchange:e=>h(t().id,e)})}},S=e=>{var n=hl(),r=L(n);r.value=r.__value=`true`;var i=R(r);i.value=i.__value=`false`,D(n);var a;Qo(n),z(()=>{a!==(a=t().value?`true`:`false`)&&(n.value=n.__value=t().value?`true`:`false`,Zo(n,t().value?`true`:`false`))}),U(`change`,n,e=>h(t().id,e.currentTarget.value===`true`)),G(e,n)},ee=e=>{var n=gl();us(n),z(e=>ds(n,e),[()=>String(t().value===void 0||t().value===null?``:t().value)]),Ua(`blur`,n,e=>h(t().id,e.currentTarget.value)),U(`keydown`,n,e=>{e.stopPropagation(),e.key===`Enter`&&e.currentTarget.blur()}),G(e,n)};mo(b,e=>{H(r)===`number`?e(x):H(r)===`boolean`?e(S,1):e(ee,-1)});var C=R(b,2),w=L(C);{let e=Wn(()=>Y.vars.has(t().id));ml(w,{get locked(){return H(e)},ontoggle:e=>{X.freezeVar(t().id,e),F(n,[...H(n)],!0),d()}})}D(C),D(p),D(i),z((e,n,a)=>{Jo(i,1,`border-border/50 hover:bg-border/30 flex h-full items-center border-b px-4 transition-colors ${e==null?``:e}`),K(o,n),ps(u,`title`,t().name),K(f,t().name),Jo(g,1,`mr-2 flex items-center justify-center transition-colors ${a==null?``:a}`),K(y,H(r)===`number`?`NUM`:H(r)===`string`?`STR`:`BOOL`)},[()=>Y.vars.has(t().id)?`border-l-frozen border-l-4 pl-3`:``,()=>t().id.toString().padStart(4,`0`),()=>Zc.isFavorite(`variables`,t().id)?`text-yellow-400 hover:text-yellow-300`:`text-gray-600 hover:text-gray-400`]),U(`focusin`,p,()=>F(s,!0)),U(`focusout`,p,()=>F(s,!1)),U(`click`,g,()=>{Zc.toggleFavorite(`variables`,t().id),d()}),U(`click`,v,()=>{(l[t().id]||typeof t().value)===`number`?l[t().id]=`string`:l[t().id]=`number`}),G(e,i)},$$slots:{itemTemplate:!0}}),e=>F(a,e,!0),()=>H(a)),D(x),D(g),z(()=>{var e;ds(v,H(i)),K(b,`${(e=H(r).length)==null?``:e} items`)}),U(`input`,v,p),G(e,g),Nt()}Wa([`input`,`focusin`,`focusout`,`click`,`change`,`keydown`]);var bl=W(``);function xl(e,t){Mt(t,!0);let n=Hs(t,`value`,15,!1),r=()=>{var e;n(!n()),(e=t.onchange)==null||e.call(t,n())};var i=bl(),a=L(i);D(i),z(()=>{Jo(i,1,`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors ${n()?`bg-ok`:`bg-[#3a3f4d]`}`),Jo(a,1,`absolute top-[4px] h-4 w-4 rounded-full bg-white shadow transition-all ${n()?`left-[24px]`:`left-[4px]`}`)}),U(`click`,i,r),G(e,i),Nt()}Wa([`click`]);var Sl=W(` `),Cl=W(` All ON All OFF `);function wl(e,t){Mt(t,!0);let n=P(I([])),r=P(I([])),i=P(``),a=P(void 0);Mi(()=>{if(Q.targetSwitchId!==null&&H(a)&&H(r).length>0){let e=H(r).findIndex(e=>e.id===Q.targetSwitchId);e!==-1&&H(a).scrollToIndex(e),Q.targetSwitchId=null}});let o,s=P(!1),c=new Set,l=()=>{if(!H(i).trim())c=new Set(H(n).map(e=>e.id));else{let e=H(i).trim().toLowerCase(),t=H(n).filter(t=>String(t.id)===e||t.name.toLowerCase().includes(e)||(t.value?`true`:`false`).includes(e));c=new Set(t.map(e=>e.id))}},u=()=>{F(r,H(n).filter(e=>c.has(e.id)).sort((e,t)=>{let n=Zc.isFavorite(`switches`,e.id),r=Zc.isFavorite(`switches`,t.id);return n&&!r?-1:!n&&r?1:e.id-t.id}),!0)},d=()=>{F(n,q.switches.list(),!0),l(),u()},f=e=>{F(i,e.target.value,!0),clearTimeout(o),o=setTimeout(()=>{l(),u()},300)};Ws(()=>{d();let e=setInterval(()=>{H(s)||(F(n,q.switches.list(),!0),u())},1e3);return()=>clearInterval(e)});let p=(e,t)=>{q.switches.set(e,t),Y.switches.has(e)&&X.freezeSwitch(e,!0);let r=H(n).find(t=>t.id===e);r&&(r.value=t)},h=e=>{H(r).forEach(t=>p(t.id,e)),d(),zc.show(`All filtered switches turned ${e?`ON`:`OFF`}`,`success`)};var g=Cl(),_=L(g),v=L(_);us(v);var y=R(v,2),b=L(y),x=R(b,2),S=R(x,2),ee=L(S);D(S),D(y),D(_);var C=R(_,2);Ps(ul(L(C),{get items(){return H(r)},itemHeight:36,itemTemplate:(e,t=m)=>{var r=Sl(),i=L(r),a=L(i,!0);D(i);var o=R(i,2),c=L(o),l=L(c,!0);D(c),D(o);var d=R(o,2),f=L(d),h=L(f);{let e=Wn(()=>Zc.isFavorite(`switches`,t().id)?`fill-current`:``);bc(h,{size:16,get class(){return H(e)}})}D(f);var g=R(f,2);xl(g,{get value(){return t().value},onchange:e=>p(t().id,e)});var _=R(g,2),v=L(_);{let e=Wn(()=>Y.switches.has(t().id));ml(v,{get locked(){return H(e)},ontoggle:e=>{X.freezeSwitch(t().id,e),F(n,[...H(n)],!0),u()}})}D(_),D(d),D(r),z((e,n,i)=>{Jo(r,1,`border-border/50 hover:bg-border/30 flex h-full items-center border-b px-4 transition-colors ${e==null?``:e}`),K(a,n),Jo(c,1,`truncate text-sm select-text cursor-text ${t().value?`text-white font-bold`:`text-gray-400`}`),K(l,t().name),Jo(f,1,`flex items-center justify-center transition-colors ${i==null?``:i}`)},[()=>Y.switches.has(t().id)?`border-l-frozen border-l-4 pl-3`:``,()=>t().id.toString().padStart(4,`0`),()=>Zc.isFavorite(`switches`,t().id)?`text-yellow-400 hover:text-yellow-300`:`text-gray-600 hover:text-gray-400`]),Ua(`mouseenter`,d,()=>F(s,!0)),Ua(`mouseleave`,d,()=>F(s,!1)),U(`click`,f,()=>{Zc.toggleFavorite(`switches`,t().id),u()}),G(e,r)},$$slots:{itemTemplate:!0}}),e=>F(a,e,!0),()=>H(a)),D(C),D(g),z(()=>{var e;ds(v,H(i)),K(ee,`${(e=H(r).length)==null?``:e} items`)}),U(`input`,v,f),U(`click`,b,()=>h(!0)),U(`click`,x,()=>h(!1)),G(e,g),Nt()}Wa([`input`,`click`]);var Tl=W(` `),El=W(` `),Dl=W(`Items Weapons Armors `);function Ol(e,t){Mt(t,!0);let n=P(I([])),r=P(I([])),i=P(``),a=P(void 0);Mi(()=>{if(Q.targetItemKey!==null&&H(a)){let[e,t]=Q.targetItemKey.split(`:`);if(e===H(o)){if(H(r).length>0){let e=H(r).findIndex(e=>e.id===parseInt(t,10));e!==-1&&H(a).scrollToIndex(e),Q.targetItemKey=null}}else p(e)}});let o=P(I(Fc.Item)),s,c=P(!1),l=new Set,u=()=>{if(!H(i).trim())l=new Set(H(n).map(e=>e.id));else{let e=H(i).trim().toLowerCase(),t=H(n).filter(t=>String(t.id)===e||t.name.toLowerCase().includes(e)||String(t.count).includes(e)||t.description&&t.description.toLowerCase().includes(e));l=new Set(t.map(e=>e.id))}},d=()=>{let e=H(o)===Fc.Item?`items`:H(o)===Fc.Weapon?`weapons`:`armors`;F(r,H(n).filter(e=>l.has(e.id)).sort((t,n)=>{let r=Zc.isFavorite(e,t.id),i=Zc.isFavorite(e,n.id);return r&&!i?-1:!r&&i?1:t.id-n.id}),!0)},f=()=>{F(n,q.inv.list(H(o)),!0),u(),d()},p=e=>{F(o,e,!0),f(),H(a)&&H(a).resetScroll()},h=e=>{F(i,e.target.value,!0),clearTimeout(s),s=setTimeout(()=>{u(),d()},300)};Ws(()=>{f();let e=setInterval(()=>{H(c)||(F(n,q.inv.list(H(o)),!0),d())},1e3);return()=>clearInterval(e)});let g=(e,t)=>{q.inv.setCount(H(o),e,t),Y.items.has(`${H(o)}:${e}`)&&X.freezeItem(H(o),e,!0)};var _=Dl(),v=L(_),y=L(v),b=L(y),x=R(b,2),S=R(x,2);D(y);var ee=R(y,2);us(ee),D(v);var C=R(v,2);Ps(ul(L(C),{get items(){return H(r)},itemHeight:48,itemTemplate:(e,t=m)=>{var r=El(),i=L(r),a=L(i,!0);D(i);var s=R(i,2),l=L(s),u=L(l,!0);D(l);var f=R(l,2),p=e=>{var n=Tl(),r=L(n,!0);D(n),z((e,t)=>{ps(n,`title`,e),K(r,t)},[()=>t().description.replace(/\n/g,` `),()=>t().description.replace(/\n/g,` `)]),G(e,n)};mo(f,e=>{t().description&&e(p)}),D(s);var h=R(s,2),_=L(h),v=L(_);{let e=Wn(()=>Zc.isFavorite(H(o)===Fc.Item?`items`:H(o)===Fc.Weapon?`weapons`:`armors`,t().id)?`fill-current`:``);bc(v,{size:16,get class(){return H(e)}})}D(_);var y=R(_,2);{let e=Wn(()=>q.inv.maxStack(H(o),t().id));fl(y,{get value(){return t().count},min:0,get max(){return H(e)},onchange:e=>g(t().id,e)})}var b=R(y,2),x=L(b);{let e=Wn(()=>Y.items.has(`${H(o)}:${t().id}`));ml(x,{get locked(){return H(e)},ontoggle:e=>{X.freezeItem(H(o),t().id,e),F(n,[...H(n)],!0),d()}})}D(b),D(h),D(r),z((e,n,i)=>{Jo(r,1,`border-border/50 hover:bg-border/30 flex h-full items-center border-b px-4 transition-colors ${e==null?``:e}`),K(a,n),ps(l,`title`,t().name),K(u,t().name),Jo(_,1,`mr-1 flex items-center justify-center transition-colors ${i==null?``:i}`)},[()=>Y.items.has(`${H(o)}:${t().id}`)?`border-l-frozen border-l-4 pl-3`:``,()=>t().id.toString().padStart(4,`0`),()=>Zc.isFavorite(H(o)===Fc.Item?`items`:H(o)===Fc.Weapon?`weapons`:`armors`,t().id)?`text-yellow-400 hover:text-yellow-300`:`text-gray-600 hover:text-gray-400`]),U(`focusin`,h,()=>F(c,!0)),U(`focusout`,h,()=>F(c,!1)),U(`click`,_,()=>{let e=H(o)===Fc.Item?`items`:H(o)===Fc.Weapon?`weapons`:`armors`;Zc.toggleFavorite(e,t().id),d()}),G(e,r)},$$slots:{itemTemplate:!0}}),e=>F(a,e,!0),()=>H(a)),D(C),D(_),z(()=>{Jo(b,1,`rounded px-3 py-1.5 text-sm font-semibold transition-colors ${H(o)===Fc.Item?`bg-accent text-white`:`bg-border hover:bg-border/80 text-gray-300`}`),Jo(x,1,`rounded px-3 py-1.5 text-sm font-semibold transition-colors ${H(o)===Fc.Weapon?`bg-accent text-white`:`bg-border hover:bg-border/80 text-gray-300`}`),Jo(S,1,`rounded px-3 py-1.5 text-sm font-semibold transition-colors ${H(o)===Fc.Armor?`bg-accent text-white`:`bg-border hover:bg-border/80 text-gray-300`}`),ds(ee,H(i))}),U(`click`,b,()=>p(Fc.Item)),U(`click`,x,()=>p(Fc.Weapon)),U(`click`,S,()=>p(Fc.Armor)),U(`input`,ee,h),G(e,_),Nt()}Wa([`click`,`input`,`focusin`,`focusout`]);var kl=W(``),Al=W(` `),jl=W(` `),Ml=W(` `),Nl=W(`No skills in database.`),Pl=W(`Clear All States`),Fl=W(` ×`),Il=W(`No active states.`),Ll=W(` `),Rl=W(` Recover All Core Status Level EXP HP MP TP Parameters Skills States Select a state to apply... Add State`,1),zl=W(`Start a game or select an actor to edit stats.`),Bl=W(`Actors `);function Vl(e,t){Mt(t,!0);let n=P(I([])),r=P(null),i=P(null),a=P(null),o=P(``),s=P(``);Mi(()=>{Q.targetActorId!==null&&H(n).length>0&&(F(r,Q.targetActorId,!0),Q.targetActorId=null,Q.targetActorStat=null,c())});let c=()=>{F(n,J.list(),!0),H(r)===null&&H(n).length>0&&F(r,H(n)[0].id,!0),H(r)!==null&&F(i,J.get(H(r)),!0)};Ws(()=>{c();let e=setInterval(()=>{c()},1e3);return()=>clearInterval(e)});let l=e=>{F(r,e,!0),F(i,J.get(e),!0)},u=(e,t)=>{H(r)!==null&&(e===`hp`?J.setHp(H(r),t):e===`mp`?J.setMp(H(r),t):e===`tp`&&J.setTp(H(r),t),Y.stats.has(`${H(r)}:${e}`)&&X.freezeStat(H(r),e,!0),F(i,J.get(H(r)),!0))},d=(e,t)=>{H(r)!==null&&(J.setParam(H(r),e,t),F(i,J.get(H(r)),!0))},f=()=>{H(r)===null||!H(i)||(H(i).inParty?J.removeFromParty(H(r)):J.addToParty(H(r)),c())},p=(e,t)=>{H(r)!==null&&(t?J.forgetSkill(H(r),e):J.learnSkill(H(r),e),F(i,J.get(H(r)),!0))},m={[Lc.MHP]:`Max HP`,[Lc.MMP]:`Max MP`,[Lc.ATK]:`Attack`,[Lc.DEF]:`Defense`,[Lc.MAT]:`M. Attack`,[Lc.MDF]:`M. Defense`,[Lc.AGI]:`Agility`,[Lc.LUK]:`Luck`};var h=Bl(),g=L(h),_=R(L(g),2);yo(_,21,()=>H(n),ho,(e,t)=>{var n=Al(),i=L(n),a=L(i),o=e=>{G(e,kl())};mo(a,e=>{H(t).inParty&&e(o)});var s=R(a,2),c=L(s,!0);D(s),D(i);var u=R(i,2),d=L(u);D(u),D(n),z(()=>{var e;ps(n,`id`,`actor-btn-${H(t).id}`),Jo(n,1,`flex w-full items-center justify-between rounded px-2.5 py-2 text-left text-sm transition-colors ${H(r)===H(t).id?`bg-accent text-white font-semibold`:`hover:bg-border/50 text-gray-300`}`),K(c,H(t).name),K(d,`Lv.${(e=H(t).level)==null?``:e}`)}),U(`click`,n,()=>l(H(t).id)),G(e,n)}),D(_),D(g);var v=R(g,2),y=L(v),b=e=>{var t,n=Rl(),l=_i(n),h=L(l),g=L(h),_=L(g,!0);D(g);var v=R(g,2),y=L(v);D(v),D(h);var b=R(h,2),x=L(b),S=R(x,2),ee=L(S,!0);D(S),D(b),D(l);var C=R(l,2),w=L(C),te=R(L(w),2),ne=R(L(te),2),re=L(ne);fl(re,{get value(){return H(i).level},min:1,max:99,onchange:e=>{H(r)!==null&&(J.setLevel(H(r),e),Y.stats.has(`${H(r)}:level`)&&X.freezeStat(H(r),`level`,!0),F(i,J.get(H(r)),!0),c())}});var ie=R(re,2);{let e=Wn(()=>Y.stats.has(`${H(r)}:level`));ml(ie,{get locked(){return H(e)},ontoggle:e=>{H(r)!==null&&(X.freezeStat(H(r),`level`,e),F(i,J.get(H(r)),!0))}})}D(ne),D(te);var ae=R(te,2),oe=R(L(ae),2),se=L(oe);fl(se,{get value(){return H(i).exp},min:0,onchange:e=>{H(r)!==null&&(J.setExp(H(r),e),Y.stats.has(`${H(r)}:exp`)&&X.freezeStat(H(r),`exp`,!0),F(i,J.get(H(r)),!0),c())}});var ce=R(se,2);{let e=Wn(()=>Y.stats.has(`${H(r)}:exp`));ml(ce,{get locked(){return H(e)},ontoggle:e=>{H(r)!==null&&(X.freezeStat(H(r),`exp`,e),F(i,J.get(H(r)),!0))}})}D(oe),D(ae);var le=R(ae,2),ue=R(L(le),2),de=L(ue);fl(de,{get value(){return H(i).hp},min:0,get max(){return H(i).mhp},onchange:e=>u(`hp`,e)});var fe=R(de,2);{let e=Wn(()=>Y.stats.has(`${H(r)}:hp`));ml(fe,{get locked(){return H(e)},ontoggle:e=>{H(r)!==null&&(X.freezeStat(H(r),`hp`,e),F(i,J.get(H(r)),!0))}})}D(ue),D(le);var pe=R(le,2),me=R(L(pe),2),he=L(me);fl(he,{get value(){return H(i).mp},min:0,get max(){return H(i).mmp},onchange:e=>u(`mp`,e)});var ge=R(he,2);{let e=Wn(()=>Y.stats.has(`${H(r)}:mp`));ml(ge,{get locked(){return H(e)},ontoggle:e=>{H(r)!==null&&(X.freezeStat(H(r),`mp`,e),F(i,J.get(H(r)),!0))}})}D(me),D(pe);var _e=R(pe,2),ve=R(L(_e),2),ye=L(ve);fl(ye,{get value(){return H(i).tp},min:0,get max(){return H(i).mtp},onchange:e=>u(`tp`,e)});var be=R(ye,2);{let e=Wn(()=>Y.stats.has(`${H(r)}:tp`));ml(be,{get locked(){return H(e)},ontoggle:e=>{H(r)!==null&&(X.freezeStat(H(r),`tp`,e),F(i,J.get(H(r)),!0))}})}D(ve),D(_e),D(w);var xe=R(w,2);yo(R(L(xe),2),17,()=>H(i).params,e=>e.id,(e,t)=>{var n=jl(),a=L(n),o=L(a,!0);D(a);var s=R(a,2),c=L(s);fl(c,{get value(){return H(t).value},min:1,onchange:e=>{d(H(t).id,e),Y.stats.has(`${H(r)}:param_${H(t).id}`)&&X.freezeStat(H(r),`param_${H(t).id}`,!0)}});var l=R(c,2);{let e=Wn(()=>Y.stats.has(`${H(r)}:param_${H(t).id}`));ml(l,{get locked(){return H(e)},ontoggle:e=>{H(r)!==null&&(X.freezeStat(H(r),`param_${H(t).id}`,e),F(i,J.get(H(r)),!0))}})}D(s),D(n),z(()=>{ps(n,`id`,`stat-param_${H(t).id}`),K(o,m[H(t).id]||`Stat`)}),G(e,n)}),D(xe),D(C);var Se=R(C,2),Ce=L(Se),we=R(L(Ce),2);us(we),D(Ce);var Te=R(Ce,2);yo(Te,21,()=>H(i).skills.filter(e=>!H(o).trim()||e.name.toLowerCase().includes(H(o).trim().toLowerCase())||e.id.toString().includes(H(o).trim())),e=>e.id,(e,t)=>{var n=Ml(),r=L(n),i=L(r);D(r);var a=R(r,2),o=L(a,!0);D(a),D(n),z(e=>{var n;K(i,`${e==null?``:e}: ${(n=H(t).name)==null?``:n}`),Jo(a,1,`rounded border px-3 py-1 text-xs font-semibold transition-colors ${H(t).learned?`border-danger/30 text-danger bg-danger/10 hover:bg-danger/20`:`border-accent/30 text-accent bg-accent/10 hover:bg-accent/20`}`),K(o,H(t).learned?`Forget`:`Learn`)},[()=>H(t).id.toString().padStart(3,`0`)]),U(`click`,a,()=>p(H(t).id,H(t).learned)),G(e,n)},e=>{G(e,Nl())}),D(Te),D(Se);var Ee=R(Se,2),De=L(Ee),Oe=R(L(De),2),ke=L(Oe);us(ke);var Ae=R(ke,2),je=e=>{var t=Pl();U(`click`,t,()=>{H(r)!==null&&(J.clearStates(H(r)),F(i,J.get(H(r)),!0))}),G(e,t)};mo(Ae,e=>{H(i).states.length>0&&e(je)}),D(Oe),D(De);var Me=R(De,2);yo(Me,21,()=>H(i).states,ho,(e,t)=>{var n=Fl(),a=L(n),o=L(a,!0);D(a);var s=R(a,2);D(n),z(()=>K(o,H(t).name)),U(`click`,s,()=>{H(r)!==null&&(J.removeState(H(r),H(t).id),F(i,J.get(H(r)),!0))}),G(e,n)},e=>{G(e,Il())}),D(Me);var Ne=R(Me,2),Pe=L(Ne),Fe=L(Pe);Fe.value=(t=Fe.__value=null)!=null&&t!==void 0?t:``,yo(R(Fe),17,()=>J.listStates().filter(e=>!H(s).trim()||e.name.toLowerCase().includes(H(s).trim().toLowerCase())||e.id.toString().includes(H(s).trim())),ho,(e,t)=>{var n=Ll(),r=L(n);D(n);var i={};z(e=>{var a;if(K(r,`${e==null?``:e}: ${(a=H(t).name)==null?``:a}`),i!==(i=H(t).id)){var o;n.value=(o=n.__value=H(t).id)==null?``:o}},[()=>H(t).id.toString().padStart(3,`0`)]),G(e,n)}),D(Pe);var Ie=R(Pe,2);D(Ne),D(Ee),z(()=>{var e;K(_,H(i).name),K(y,`Actor ID: ${(e=H(i).id)==null?``:e}`),Jo(S,1,`rounded border px-3 py-1.5 text-xs font-semibold transition-colors ${H(i).inParty?`border-danger/30 bg-danger/20 text-danger hover:bg-danger/30`:`border-ok/30 bg-ok/20 text-ok hover:bg-ok/30`}`),K(ee,H(i).inParty?`Remove Party`:`Add Party`),Ie.disabled=H(a)===null}),U(`click`,x,()=>{H(r)!==null&&(J.recover(H(r)),F(i,J.get(H(r)),!0))}),U(`click`,S,f),Cs(we,()=>H(o),e=>F(o,e)),Cs(ke,()=>H(s),e=>F(s,e)),$o(Pe,()=>H(a),e=>F(a,e)),U(`click`,Ie,()=>{H(r)!==null&&H(a)!==null&&(J.addState(H(r),H(a)),F(i,J.get(H(r)),!0),F(a,null))}),G(e,n)},x=e=>{G(e,zl())};mo(y,e=>{H(i)?e(b):e(x,-1)}),D(v),D(h),G(e,h),Nt()}Wa([`click`]);function Hl(e){let t=e-1;return t*t*t+1}function Ul(e,{from:t,to:n},r={}){var{delay:i=0,duration:a=e=>Math.sqrt(e)*120,easing:o=Hl}=r,s=getComputedStyle(e),c=s.transform===`none`?``:s.transform,[l,u]=s.transformOrigin.split(` `).map(parseFloat);l/=e.clientWidth,u/=e.clientHeight;var d=Wl(e),f=e.clientWidth/n.width/d,p=e.clientHeight/n.height/d,m=t.left+t.width*l,h=t.top+t.height*u,g=n.left+n.width*l,_=n.top+n.height*u,v=(m-g)*f,y=(h-_)*p,b=t.width/n.width,x=t.height/n.height;return{delay:i,duration:typeof a==`function`?a(Math.sqrt(v*v+y*y)):a,easing:o,css:(e,t)=>`transform: ${c} translate(${t*v}px, ${t*y}px) scale(${e+t*b}, ${e+t*x});`}}function Wl(e){if(`currentCSSZoom`in e)return e.currentCSSZoom;for(var t=e,n=1;t!==null;)n*=+getComputedStyle(t).zoom,t=t.parentElement;return n}var Gl=W(` `),Kl=W(` `),ql=W(` `),Jl=W(`Configure the hold key in the Keys panel.`),Yl=W(`Warning: Game is permanently sped up. Turn this back on to require holding a key.`),Xl=W(` `),Zl=W(` `),Ql=W(`Active Enemies `),$l=W(`LEAD`),eu=W(`⋮⋮ `),tu=W(`No active party members found (start/load a game).`),nu=W(`Quick Actions Party Resources Gold Steps Playtime Battle Settings God Mode One-Hit Kill Disable Encounters Movement Noclip (Walk Through Walls) Move Speed Game Speed Hold Key to Fast Forward Speed Multiplier Party Members Status `);function ru(e,t){Mt(t,!0);let n=P(0),r=P(0),i=P(0),a=P(4),o=P(!1),s=P(I([])),c=P(I([])),l=[{title:`System & Menus`,actions:[`quick_save`,`quick_load`,`open_save_scene`,`open_load_scene`,`goto_title`]},{title:`Battle Actions`,actions:[`force_victory`,`force_defeat`,`force_escape`,`trigger_encounter`]},{title:`Health Controls`,actions:[`party_recovery`,`party_wound`,`enemy_recovery`,`enemy_wound`]}],u=()=>{F(n,q.gold.get(),!0),F(r,q.party.steps(),!0),F(i,q.party.playtime(),!0),window.$gamePlayer&&F(a,window.$gamePlayer._moveSpeed||4,!0),F(o,!!(window.SceneManager&&window.SceneManager._scene&&window.SceneManager._scene.constructor.name===`Scene_Battle`)),H(o)&&window.$gameTroop?F(s,window.$gameTroop.members().map(e=>({ref:e,name:e.name(),hp:e.hp,mhp:e.mhp,mp:e.mp,mmp:e.mmp,tp:e.tp,maxTp:e.maxTp()})),!0):F(s,[],!0),window.$gameParty?F(c,window.$gameParty.members().map(e=>({ref:e,id:e.actorId(),name:e.name(),level:typeof e.level==`function`?e.level():e._level||1,hp:e.hp,mhp:e.mhp,mp:e.mp,mmp:e.mmp,tp:e.tp,maxTp:e.maxTp()})),!0):F(c,[],!0)};Ws(()=>{u();let e=setInterval(u,1e3);return()=>clearInterval(e)});let d=e=>{q.gold.set(e),Y.gold!==null&&X.freezeGold(!0),F(n,q.gold.get(),!0)},f=e=>{let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60;return`${t.toString().padStart(2,`0`)}:${n.toString().padStart(2,`0`)}:${r.toString().padStart(2,`0`)}`},p=(e,t)=>{e.ref.setHp(t),u()},m=(e,t)=>{e.ref.setMp(t),u()},h=(e,t)=>{e.ref.setTp?e.ref.setTp(t):e.ref.tp=t,u()},g=P(null),_=(e,t)=>{e!==t&&window.$gameParty&&typeof window.$gameParty.swapOrder==`function`&&(window.$gameParty.swapOrder(e,t),u())};var v=nu(),y=L(v),b=R(L(y),2);yo(b,21,()=>l,ho,(e,t)=>{var n=ql(),r=L(n),i=L(r,!0);D(r);var a=R(r,2);yo(a,21,()=>H(t).actions,ho,(e,t)=>{let n=Wn(()=>nl.find(e=>e.id===H(t)));var r=eo(),i=_i(r),a=e=>{var t=Kl(),r=L(t),i=L(r,!0);D(r);var a=R(r,2),o=e=>{var t=Gl(),r=L(t,!0);D(t),z(e=>K(r,e),[()=>{var e;return Yc.fromString(((e=$.get(H(n).id))==null?void 0:e.keyStr)||``).asDisplayString()}]),G(e,t)},s=Wn(()=>{var e;return(e=$.get(H(n).id))==null?void 0:e.keyStr});mo(a,e=>{H(s)&&e(o)}),D(t),z(()=>K(i,H(n).name)),U(`click`,t,()=>{var e,t;(e=(t=H(n)).onEnter)==null||e.call(t),u()}),G(e,t)};mo(i,e=>{H(n)&&e(a)}),G(e,r)}),D(a),D(n),z(()=>K(i,H(t).title)),G(e,n)}),D(b),D(y);var x=R(y,2),S=L(x),ee=R(L(S),2),C=R(L(ee),2),w=L(C);fl(w,{get value(){return H(n)},min:0,max:99999999,onchange:d});var te=R(w,2);{let e=Wn(()=>Y.gold!==null);ml(te,{get locked(){return H(e)},ontoggle:e=>{X.freezeGold(e),u()}})}D(C),D(ee);var ne=R(ee,2),re=R(L(ne),2),ie=L(re,!0);D(re),D(ne);var ae=R(ne,2),oe=R(L(ae),2),se=L(oe,!0);D(oe),D(ae),D(S);var ce=R(S,2),le=R(L(ce),2),ue=L(le);xl(R(L(ue),2),{get value(){return Z.god},onchange:e=>Wc.setGod(e)}),D(ue);var de=R(ue,2);xl(R(L(de),2),{get value(){return Z.ohko},onchange:e=>Wc.setOhko(e)}),D(de);var fe=R(de,2);xl(R(L(fe),2),{get value(){return Z.noEncounter},onchange:e=>Wc.setNoEncounter(e)}),D(fe),D(le),D(ce),D(x);var pe=R(x,2),me=R(L(pe),2),he=L(me);xl(R(L(he),2),{get value(){return Y.noclip},onchange:e=>X.setNoclip(e)}),D(he);var ge=R(he,2);fl(R(L(ge),2),{get value(){return H(a)},min:1,max:8,onchange:e=>q.map.speed(e)}),D(ge),D(me),D(pe);var _e=R(pe,2),ve=R(L(_e),2),ye=L(ve),be=L(ye);xl(R(L(be),2),{get value(){return Z.speedUseKey},onchange:e=>{Wc.setSpeedUseKey(e),e?Wc.setSpeed(1):Wc.setSpeed(Z.speedBoost)}}),D(be);var xe=R(be,2),Se=e=>{G(e,Jl())},Ce=e=>{G(e,Yl())};mo(xe,e=>{Z.speedUseKey?e(Se):e(Ce,-1)}),D(ye);var we=R(ye,2),Te=R(L(we),2);yo(Te,20,()=>[.5,1,2,3,5,8],ho,(e,t)=>{var n=Xl(),r=L(n);D(n),z(()=>{Jo(n,1,`border-border h-7 w-9 rounded border text-xs transition-colors ${Z.speedBoost===t?`border-accent bg-accent text-white font-semibold`:`bg-bg hover:bg-border/50 text-gray-300`}`),K(r,`${t==null?``:t}x`)}),U(`click`,n,()=>{Wc.setSpeedBoost(t),Z.speedUseKey||Wc.setSpeed(t)}),G(e,n)}),D(Te),D(we),D(ve),D(_e);var Ee=R(_e,2),De=e=>{var t=Ql(),n=R(L(t),2);yo(n,21,()=>H(s),ho,(e,t)=>{var n=Zl(),r=L(n),i=L(r),a=L(i,!0);D(i),D(r);var o=R(r,2),s=L(o),c=L(s),l=L(c);D(c),fl(R(c,2),{get value(){return H(t).hp},min:0,get max(){return H(t).mhp},onchange:e=>p(H(t),e)}),D(s);var u=R(s,2),d=L(u),f=L(d);D(d),fl(R(d,2),{get value(){return H(t).mp},min:0,get max(){return H(t).mmp},onchange:e=>m(H(t),e)}),D(u);var g=R(u,2),_=L(g),v=L(_);D(_),fl(R(_,2),{get value(){return H(t).tp},min:0,get max(){return H(t).maxTp},onchange:e=>h(H(t),e)}),D(g),D(o),D(n),z(()=>{var e,n,r,i,o;K(a,H(t).name),K(l,`HP (${(e=H(t).hp)==null?``:e}/${(n=H(t).mhp)==null?``:n})`),K(f,`MP (${(r=H(t).mp)==null?``:r}/${(i=H(t).mmp)==null?``:i})`),K(v,`TP (${(o=H(t).tp)==null?``:o})`)}),G(e,n)}),D(n),D(t),G(e,t)};mo(Ee,e=>{H(o)&&H(s).length>0&&e(De)});var Oe=R(Ee,2),ke=R(L(Oe),2);yo(ke,31,()=>H(c),e=>e.id,(e,t,n)=>{var r=eu(),i=L(r),a=L(i),o=L(a),s=R(L(o),2),c=L(s),l=R(c),u=e=>{G(e,$l())};mo(l,e=>{H(n)===0&&e(u)}),D(s),D(o);var d=R(o,2),f=L(d);D(d),D(a);var v=R(a,2),y=L(v),b=L(y),x=L(b);D(b),fl(R(b,2),{get value(){return H(t).hp},min:0,get max(){return H(t).mhp},onchange:e=>p(H(t),e)}),D(y);var S=R(y,2),ee=L(S),C=L(ee);D(ee),fl(R(ee,2),{get value(){return H(t).mp},min:0,get max(){return H(t).mmp},onchange:e=>m(H(t),e)}),D(S);var w=R(S,2),te=L(w),ne=L(te);D(te),fl(R(te,2),{get value(){return H(t).tp},min:0,get max(){return H(t).maxTp},onchange:e=>h(H(t),e)}),D(w),D(v),D(i),D(r),z(()=>{var e,o,s,l,u,d,p;Jo(r,1,`rounded p-2.5 transition-all duration-200 ${H(g)===H(n)?`border border-dashed border-accent/50 bg-accent/5`:`border border-border bg-bg`}`),Jo(i,1,`space-y-2 ${H(g)===H(n)?`invisible`:``}`),Jo(a,1,`flex w-full items-center justify-between pb-2 text-xs font-bold text-white ${H(g)===null?`cursor-grab active:cursor-grabbing`:``}`),K(c,`${(e=H(t).name)==null?``:e} `),K(f,`Lv.${(o=H(t).level)==null?``:o}`),K(x,`HP (${(s=H(t).hp)==null?``:s}/${(l=H(t).mhp)==null?``:l})`),K(C,`MP (${(u=H(t).mp)==null?``:u}/${(d=H(t).mmp)==null?``:d})`),K(ne,`TP (${(p=H(t).tp)==null?``:p})`)}),Ua(`dragenter`,r,e=>e.preventDefault()),Ua(`dragover`,r,e=>{if(e.preventDefault(),H(g)!==null&&H(g)!==H(n)){let t=e.currentTarget.getBoundingClientRect(),r=t.top+t.height/2;if(H(g)H(n)&&e.clientY>r)return;_(H(g),H(n)),F(g,H(n),!0)}}),Ua(`dragstart`,a,e=>{if(e.dataTransfer){e.dataTransfer.effectAllowed=`move`;let t=e.currentTarget.closest(`[role="listitem"]`);t&&e.dataTransfer.setDragImage(t,20,20)}setTimeout(()=>{F(g,H(n),!0)},0)}),Ua(`dragend`,a,()=>{F(g,null)}),Io(r,()=>Ul,()=>({duration:250})),G(e,r)},e=>{G(e,tu())}),D(ke),D(Oe),D(v),z(e=>{K(ie,H(r)),K(se,e)},[()=>f(H(i))]),Ua(`dragenter`,Oe,e=>e.preventDefault()),Ua(`dragover`,Oe,e=>e.preventDefault()),Ua(`dragenter`,ke,e=>e.preventDefault()),Ua(`dragover`,ke,e=>e.preventDefault()),G(e,v),Nt()}Wa([`click`]);var iu=W(` `),au=W(`No saved locations yet.`),ou=W(` Teleport `),su=W(`Teleport Target Map Point of Interest (POI) -- Select a POI -- X Y Teleport Now Saved Locations Save Current `);function cu(e,t){Mt(t,!0);let n=P(I({mapId:0,x:0,y:0,dir:0})),r=P(I([])),i=P(0),a=P(0),o=P(0),s=P(I([])),c=P(``),l=P(``),u=P(``);Mi(()=>{H(o)>0&&q.map.loadMapEvents(H(o)).then(e=>{F(s,e,!0),e.find(e=>e.id.toString()===H(c))||F(c,``)})});let d=P(I([])),f=P(``),p=()=>{let e=q.map.current();e&&(F(n,e,!0),F(o,H(o)||e.mapId,!0),F(i,e.x,!0),F(a,e.y,!0)),F(r,q.map.list(),!0);try{let e=localStorage.getItem(`forge:locations`);e&&F(d,JSON.parse(e),!0)}catch(e){}};Ws(()=>{p();let e=setInterval(()=>{let e=q.map.current();e&&(e.mapId!==H(n).mapId||e.x!==H(n).x||e.y!==H(n).y)&&F(n,e,!0)},1e3);return()=>clearInterval(e)});let m=()=>{q.map.teleport(H(o),H(i),H(a),0,0)},h=()=>{let e=q.map.current();if(!e)return;let t=H(r).find(t=>t.id===e.mapId);F(d,[...H(d),{id:Date.now().toString(),name:H(f)||`Saved Location`,mapId:e.mapId,mapName:t?t.name:`Map ${e.mapId}`,x:e.x,y:e.y}],!0),F(f,``),localStorage.setItem(`forge:locations`,JSON.stringify(H(d)))},g=e=>{F(d,H(d).filter(t=>t.id!==e),!0),localStorage.setItem(`forge:locations`,JSON.stringify(H(d)))},_=e=>{q.map.teleport(e.mapId,e.x,e.y,0,0)};var v=su(),y=L(v),b=R(L(y),2),x=L(b);D(b);var S=R(b,2),ee=L(S),C=L(ee),w=R(L(C),2);us(w),D(C);var te=R(C,2);yo(te,21,()=>H(r).filter(e=>!H(l).trim()||e.name.toLowerCase().includes(H(l).trim().toLowerCase())||e.id.toString().includes(H(l).trim())),ho,(e,t)=>{var r=iu(),i=L(r);D(r);var a={};z(e=>{var o;if(K(i,`${H(t).id===H(n).mapId?`[CURRENT] `:``}${e==null?``:e}: ${(o=H(t).name)==null?``:o}`),a!==(a=H(t).id)){var s;r.value=(s=r.__value=H(t).id)==null?``:s}},[()=>H(t).id.toString().padStart(3,`0`)]),G(e,r)}),D(te),D(ee);var ne=R(ee,2),re=L(ne),ie=R(L(re),2);us(ie),D(re);var ae=R(re,2),oe=L(ae);oe.value=oe.__value=``,yo(R(oe),17,()=>H(s).filter(e=>!H(u).trim()||e.name.toLowerCase().includes(H(u).trim().toLowerCase())||e.id.toString().includes(H(u).trim())),ho,(e,t)=>{var n=iu(),r=L(n);D(n);var i={};z(()=>{var e,a,o;if(K(r,`${(e=H(t).name)==null?``:e} (X:${(a=H(t).x)==null?``:a}, Y:${(o=H(t).y)==null?``:o})`),i!==(i=H(t).id)){var s;n.value=(s=n.__value=H(t).id)==null?``:s}}),G(e,n)}),D(ae),D(ne);var se=R(ne,2),ce=L(se),le=R(L(ce),2);us(le),D(ce);var ue=R(ce,2),de=R(L(ue),2);us(de),D(ue),D(se);var fe=R(se,2);D(S),D(y);var pe=R(y,2),me=R(L(pe),2),he=L(me);us(he);var ge=R(he,2);D(me);var _e=R(me,2),ve=L(_e),ye=e=>{G(e,au())},be=e=>{var t=eo();yo(_i(t),17,()=>H(d),e=>e.id,(e,t)=>{var n=ou(),r=L(n),i=L(r),a=L(i,!0);D(i);var o=R(i,2),s=L(o);D(o),D(r);var c=R(r,2),l=L(c),u=R(l,2);Ec(L(u),{size:14}),D(u),D(c),D(n),z(()=>{var e,n,r,i;K(a,H(t).name),K(s,`${(e=H(t).mapName)==null?``:e} (Map ${(n=H(t).mapId)==null?``:n}) • X:${(r=H(t).x)==null?``:r} Y:${(i=H(t).y)==null?``:i}`)}),U(`click`,l,()=>_(H(t))),U(`click`,u,()=>g(H(t).id)),G(e,n)}),G(e,t)};mo(ve,e=>{H(d).length===0?e(ye):e(be,-1)}),D(_e),D(pe),D(v),z(()=>{var e,t,r;return K(x,`Current: Map ${(e=H(n).mapId)==null?``:e} (${(t=H(n).x)==null?``:t}, ${(r=H(n).y)==null?``:r})`)}),Cs(w,()=>H(l),e=>F(l,e)),$o(te,()=>H(o),e=>F(o,e)),Cs(ie,()=>H(u),e=>F(u,e)),U(`change`,ae,e=>{let t=parseInt(e.target.value);if(isNaN(t))return;let n=H(s).find(e=>e.id===t);n&&(F(i,n.x,!0),F(a,n.y,!0))}),$o(ae,()=>H(c),e=>F(c,e)),Cs(le,()=>H(i),e=>F(i,e)),Cs(de,()=>H(a),e=>F(a,e)),U(`click`,fe,m),U(`keydown`,he,e=>{e.stopPropagation(),e.key===`Enter`&&h()}),Cs(he,()=>H(f),e=>F(f,e)),U(`click`,ge,h),G(e,v),Nt()}Wa([`change`,`click`,`keydown`]);var lu=W(`Confirm? Cancel`,1),uu=W(`Run`),du=W(` `),fu=W(` `);function pu(e,t){Mt(t,!0);let n=P(I([])),r=P(I([])),i=P(``),a=P(null),o,s=()=>{let e=H(n);if(H(i).trim()){let t=H(i).trim().toLowerCase();e=H(n).filter(e=>String(e.id)===t||e.name.toLowerCase().includes(t))}F(r,e.sort((e,t)=>{let n=Zc.isFavorite(`commonEvents`,e.id),r=Zc.isFavorite(`commonEvents`,t.id);return n&&!r?-1:!n&&r?1:e.id-t.id}),!0)},c=()=>{F(n,q.commonev.list(),!0),s()},l=e=>{F(i,e.target.value,!0),s()};Ws(()=>{c()});let u=e=>{H(a)===e?(q.commonev.run(e),F(a,null),clearTimeout(o)):(F(a,e,!0),clearTimeout(o),o=setTimeout(()=>{H(a)===e&&F(a,null)},3e3))},d=()=>{F(a,null),clearTimeout(o)};var f=fu(),p=L(f),h=L(p);us(h);var g=R(h,2),_=L(g);D(g),D(p);var v=R(p,2);ul(L(v),{get items(){return H(r)},itemHeight:38,itemTemplate:(e,t=m)=>{var n=du(),r=L(n),i=L(r),o=L(i,!0);D(i);var c=R(i,2),l=L(c,!0);D(c),D(r);var f=R(r,2),p=L(f),h=L(p);{let e=Wn(()=>Zc.isFavorite(`commonEvents`,t().id)?`fill-current`:``);bc(h,{size:16,get class(){return H(e)}})}D(p);var g=R(p,2),_=L(g),v=e=>{var n=lu(),r=_i(n),i=R(r,2);U(`click`,r,()=>u(t().id)),U(`click`,i,d),G(e,n)},y=e=>{var n=uu();U(`click`,n,()=>u(t().id)),G(e,n)};mo(_,e=>{H(a)===t().id?e(v):e(y,-1)}),D(g),D(f),D(n),z((e,n)=>{K(o,e),ps(c,`title`,t().name),K(l,t().name),Jo(p,1,`mr-2 flex items-center justify-center transition-colors ${n==null?``:n}`)},[()=>t().id.toString().padStart(4,`0`),()=>Zc.isFavorite(`commonEvents`,t().id)?`text-yellow-400 hover:text-yellow-300`:`text-gray-600 hover:text-gray-400`]),U(`click`,p,()=>{Zc.toggleFavorite(`commonEvents`,t().id),s()}),G(e,n)},$$slots:{itemTemplate:!0}}),D(v),D(f),z(()=>{var e;ds(h,H(i)),K(_,`${(e=H(r).length)==null?``:e} items`)}),U(`input`,h,l),G(e,f),Nt()}Wa([`input`,`click`]);var mu=W(`Unfreeze All`),hu=W(` Unfreeze`),gu=W(`No active data locks. Use the lock icon on variables, switches, items, or stats to freeze their value.`),_u=W(` `);function vu(e,t){Mt(t,!0);let n=P(I([])),r=()=>{F(n,X.summary(),!0)};Ws(()=>{r();let e=setInterval(r,1e3);return()=>clearInterval(e)});let i=e=>{if(e.type===`var`)X.freezeVar(e.id,!1);else if(e.type===`switch`)X.freezeSwitch(e.id,!1);else if(e.type===`item`){let[t,n]=e.key.split(`:`);X.freezeItem(t,parseInt(n,10),!1)}else if(e.type===`stat`||e.type===`param`){let[t,n]=e.key.split(`:`);X.freezeStat(parseInt(t,10),n,!1)}else e.type===`gold`&&X.freezeGold(!1);r()},a=e=>{if(e.type===`var`)Q.targetVarId=e.id,Q.activeTab=Ic.Vars;else if(e.type===`switch`)Q.targetSwitchId=e.id,Q.activeTab=Ic.Switches;else if(e.type===`item`)Q.targetItemKey=e.key,Q.activeTab=Ic.Inv;else if(e.type===`gold`)Q.activeTab=Ic.General;else if(e.type===`stat`||e.type===`param`){let[t,n]=e.key.split(`:`);Q.targetActorId=parseInt(t,10),Q.targetActorStat=n,Q.activeTab=Ic.Actors}},o=()=>{X.clearAll(),r()},s=e=>e===`var`?`VAR`:e===`switch`?`SW`:e===`item`?`ITEM`:e===`stat`?`STAT`:e===`param`?`PARAM`:e===`gold`?`GOLD`:`LOCK`,c=e=>e===`var`?`border-accent/30 bg-accent/10 text-accent`:e===`switch`?`border-ok/30 bg-ok/10 text-ok`:e===`item`?`border-warn/30 bg-warn/10 text-warn`:e===`stat`?`border-danger/30 bg-danger/10 text-danger`:e===`param`?`border-fuchsia-500/30 bg-fuchsia-500/10 text-fuchsia-500`:e===`gold`?`border-yellow-500/30 bg-yellow-500/10 text-yellow-500`:`border-gray-500/30 bg-gray-500/10 text-gray-400`;var l=_u(),u=L(l),d=L(u),f=L(d);D(d);var p=R(d,2),m=e=>{var t=mu();U(`click`,t,o),G(e,t)};mo(p,e=>{H(n).length>0&&e(m)}),D(u);var h=R(u,2);yo(h,21,()=>H(n),ho,(e,t)=>{var n=hu(),r=L(n),o=L(r),l=L(o,!0);D(o);var u=R(o,2),d=L(u,!0);D(u),D(r);var f=R(r,2),p=L(f),m=L(p,!0);D(p);var h=R(p,2);D(f),D(n),z((e,n)=>{Jo(o,1,`rounded border px-1.5 py-0.5 text-[10px] font-bold font-mono tracking-wide ${e==null?``:e}`),K(l,n),ps(u,`title`,H(t).label),K(d,H(t).label),K(m,typeof H(t).value==`boolean`?H(t).value?`ON`:`OFF`:H(t).value)},[()=>c(H(t).type),()=>s(H(t).type)]),U(`keydown`,n,e=>e.key===`Enter`&&a(H(t))),U(`click`,n,()=>a(H(t))),U(`click`,h,e=>{e.stopPropagation(),i(H(t))}),G(e,n)},e=>{G(e,gu())}),D(h),D(l),z(()=>{var e;return K(f,`${(e=H(n).length)==null?``:e} active locks`)}),G(e,l),Nt()}Wa([`click`,`keydown`]);var yu=W(`Press a key...`),bu=W(` `),xu=W(``),Su=W(` `);function Cu(e,t){Mt(t,!0);let n=Hs(t,`value`,15,``),r=Hs(t,`required`,3,!1),i=Hs(t,`combiningKeyAlone`,3,!1),a=P(!1),o=()=>{F(a,!0);let e=e=>{var a;e.preventDefault(),e.stopPropagation();let o=Yc.fromEvent(e);o.isCombiningKey()&&!i()||(n(o.asString()),(a=t.onchange)==null||a.call(t,n()),r())},r=()=>{F(a,!1),window.removeEventListener(`keydown`,e,{capture:!0})};window.addEventListener(`keydown`,e,{capture:!0}),setTimeout(()=>{window.addEventListener(`click`,r,{capture:!0,once:!0})},100)},s=e=>{if(!e)return`None`;try{return Yc.fromString(e).asDisplayString()}catch(t){return e}};var c=Su(),l=L(c),u=e=>{G(e,yu())},d=e=>{var t=bu(),r=L(t,!0);D(t),z(e=>{Jo(t,1,`border-border bg-bg2 hover:bg-border/50 flex h-8 flex-1 items-center rounded border px-3 text-sm font-medium transition-colors ${n()?`text-white`:`text-gray-500`}`),K(r,e)},[()=>s(n())]),U(`click`,t,o),G(e,t)};mo(l,e=>{H(a)?e(u):e(d,-1)});var f=R(l,2),p=e=>{var r=xu();Mc(L(r),{size:14}),D(r),U(`click`,r,()=>{var e;n(``),(e=t.onchange)==null||e.call(t,n())}),G(e,r)};mo(f,e=>{!r()&&n()&&!H(a)&&e(p)}),D(c),G(e,c),Nt()}Wa([`click`]);var wu=W(` `),Tu=W(` Restore Defaults `);function Eu(e,t){Mt(t,!0);let n=P(I([])),r=P(``),i=P(I([])),a=()=>{if(!H(r).trim())F(i,H(n),!0);else{let e=H(r).trim().toLowerCase();F(i,H(n).filter(t=>t.name.toLowerCase().includes(e)||t.desc.toLowerCase().includes(e)||t.keyStr.toLowerCase().includes(e)),!0)}},o=()=>{F(n,$.shortcuts.map(e=>({...e})),!0),a()};Ws(()=>{o()});let s=e=>{F(r,e.target.value,!0),a()},c=(e,t)=>{$.update(e,{keyStr:t}),o()},l=(e,t)=>{$.update(e,{enabled:t}),o()},u=()=>{localStorage.removeItem(`forge:shortcuts`),zc.show(`Defaults restored. Please reload the game.`,`success`)};var d=Tu(),f=L(d),p=L(f);us(p);var m=R(p,2);D(f);var h=R(f,2);yo(h,21,()=>H(i),e=>e.id,(e,t)=>{var n=wu(),r=L(n),i=L(r),a=L(i,!0);D(i);var o=R(i,2),s=L(o,!0);D(o),D(r);var u=R(r,2),d=L(u);{let e=Wn(()=>H(t).id===`speed_hold`||H(t).id===`skip_message`);Cu(d,{get value(){return H(t).keyStr},get required(){return H(t).required},get combiningKeyAlone(){return H(e)},onchange:e=>c(H(t).id,e)})}D(u);var f=R(u,2);xl(L(f),{get value(){return H(t).enabled},onchange:e=>l(H(t).id,e)}),D(f),D(n),z(()=>{Jo(i,1,`font-semibold text-sm ${H(t).enabled?`text-white`:`text-gray-500`}`),K(a,H(t).name),K(s,H(t).desc)}),G(e,n)}),D(h),D(d),z(()=>ds(p,H(r))),U(`input`,p,s),U(`click`,m,u),G(e,d),Nt()}Wa([`input`,`click`]),yt();var Du=Ls(()=>Xc),Ou=W(`UI Preferences Inactive Opacity Controls how transparent the panel becomes when the mouse leaves. Remember Window Position Save the exact window dimensions and position between game boots. Auto-Open on Boot Automatically display the Forge panel when the game finishes loading. Show Launcher Icon Display a draggable icon to open the panel without a shortcut. Gameplay Quick Save / Load Slot The save file slot used by the Quick Save and Quick Load shortcuts. Data Management Factory Reset Wipes all Forge settings, locks, and saved layout data. Reset Everything`);function ku(e,t){Mt(t,!1);let n=()=>Zc.save();Fs();var r=Ou(),i=L(r),a=R(L(i),2),o=R(L(a),2);fl(L(o),{get value(){return Du().inactiveOpacity},min:10,max:100,onchange:e=>{Du(Du().inactiveOpacity=e),n()}}),D(o),D(a);var s=R(a,2);xl(R(L(s),2),{onchange:()=>n(),get value(){return Du().rememberPosition},set value(e){Du(Du().rememberPosition=e)},$$legacy:!0}),D(s);var c=R(s,2);xl(R(L(c),2),{onchange:()=>n(),get value(){return Du().autoOpen},set value(e){Du(Du().autoOpen=e)},$$legacy:!0}),D(c);var l=R(c,2);xl(R(L(l),2),{onchange:()=>n(),get value(){return Du().showLauncher},set value(e){Du(Du().showLauncher=e)},$$legacy:!0}),D(l),D(i);var u=R(i,2),d=R(L(u),2),f=R(L(d),2);fl(L(f),{get value(){return Du().quickSaveSlot},min:1,max:20,onchange:e=>{Du(Du().quickSaveSlot=e),n()}}),D(f),D(d),D(u);var p=R(u,2),m=R(L(p),2),h=R(L(m),2);D(m),D(p),D(r),U(`click`,h,()=>Zc.resetAll()),G(e,r),Nt()}Wa([`click`]);var Au=W(` No logs recorded yet.`),ju=W(` `),Mu=W(`Narrator / Unknown`),Nu=W(` `),Pu=W(`Game Dialogue Logs CLEAR `);function Fu(e,t){Mt(t,!0);let n=P(void 0),r=e=>{let t=new Date(e);return`${t.getHours().toString().padStart(2,`0`)}:${t.getMinutes().toString().padStart(2,`0`)}:${t.getSeconds().toString().padStart(2,`0`)}`};Mi(()=>{Qc.entries.length&&setTimeout(()=>{var e,t;H(n)&&((e=(t=H(n)).scrollToBottom)==null||e.call(t))},10)});var i=Pu(),a=L(i),o=L(a),s=R(L(o),2);wc(L(s),{size:14}),ut(2),D(s),D(o);var c=R(o,2),l=L(c),u=e=>{var t=Au();mc(L(t),{size:32,class:`opacity-50`}),ut(2),D(t),G(e,t)},d=e=>{Ps(ul(e,{get items(){return Qc.entries},itemHeight:80,containerHeight:400,itemTemplate:(e,t=m)=>{var n=Nu(),i=L(n),a=L(i),o=e=>{var n=ju(),r=L(n,!0);D(n),z(()=>K(r,t().speaker)),G(e,n)},s=e=>{G(e,Mu())};mo(a,e=>{t().speaker?e(o):e(s,-1)});var c=R(a,2),l=L(c,!0);D(c),D(i);var u=R(i,2),d=L(u,!0);D(u),D(n),z(e=>{K(l,e),K(d,t().text)},[()=>r(t().timestamp)]),G(e,n)},$$slots:{itemTemplate:!0}}),e=>F(n,e,!0),()=>H(n))};mo(l,e=>{Qc.entries.length===0?e(u):e(d,-1)}),D(c),D(a),D(i),U(`click`,s,()=>tl.clear()),G(e,i),Nt()}Wa([`click`]);var Iu=W(` `),Lu=W(`Forge `),Ru=W(` `),zu=W(` `,1);function Bu(e,t){Mt(t,!0),Mi(()=>{let e=document.getElementById(`forge-mvmz-host`);if(!e)return;let t=!1,n=()=>{t=!1},r=[`mousedown`,`mousemove`,`mouseup`,`click`,`dblclick`,`pointerdown`,`pointermove`,`pointerup`,`contextmenu`,`wheel`,`touchstart`,`touchmove`,`touchend`,`keydown`,`keyup`],i=e=>{(e.type===`mousedown`||e.type===`pointerdown`||e.type===`touchstart`)&&(t=!0);let n=e.type===`mousemove`||e.type===`pointermove`||e.type===`touchmove`,r=e.type===`mouseup`||e.type===`pointerup`||e.type===`touchend`;if(n){let n=!1;if(`buttons`in e?n=e.buttons>0:`touches`in e&&(n=e.touches.length>0),n&&!t)return}r&&!t||e.stopPropagation()};if(window.addEventListener(`mouseup`,n,{capture:!0}),window.addEventListener(`pointerup`,n,{capture:!0}),window.addEventListener(`touchend`,n,{capture:!0}),Q.visible)for(let t of r)e.addEventListener(t,i,!1);else for(let t of r)e.removeEventListener(t,i,!1);return()=>{window.removeEventListener(`mouseup`,n,{capture:!0}),window.removeEventListener(`pointerup`,n,{capture:!0}),window.removeEventListener(`touchend`,n,{capture:!0});for(let t of r)e.removeEventListener(t,i,!1)}});let n=[{id:Ic.General,label:`General`},{id:Ic.Vars,label:`Variables`},{id:Ic.Switches,label:`Switches`},{id:Ic.Inv,label:`Inventory`},{id:Ic.Actors,label:`Actors`},{id:Ic.Map,label:`Map`},{id:Ic.CommonEv,label:`Events`},{id:Ic.Locks,label:`Locks`},{id:Ic.Logs,label:`Logs`},{id:Ic.Shortcuts,label:`Keys`},{id:Ic.Settings,label:`Settings`}],r=P(0),i=P(0),a=P(840),o=P(520),s=P(!1);Ws(()=>{Zc.load(),X.install(),Wc.install(),tl.install(),$.init(nl);try{let e=JSON.parse(localStorage.getItem(`forge:panel`)||`null`);e&&Xc.rememberPosition?(F(r,e.x,!0),F(i,e.y,!0),F(a,e.w,!0),F(o,e.h,!0)):typeof window<`u`&&(F(r,0),F(i,0),F(a,Math.min(840,window.innerWidth||840),!0),F(o,Math.min(520,window.innerHeight||520),!0));let t=localStorage.getItem(`forge:lastTab`);t&&Object.values(Ic).includes(t)&&(Q.activeTab=t)}catch(e){}Xc.autoOpen&&!Q.visible&&(Q.visible=!0)});let c=()=>{Xc.rememberPosition&&localStorage.setItem(`forge:panel`,JSON.stringify({x:H(r),y:H(i),w:H(a),h:H(o)})),localStorage.setItem(`forge:lastTab`,Q.activeTab)},l=P(!1),u=P(0),d=P(0),f=P(0),p=P(0),m=e=>{H(l)&&(F(r,Math.max(0,Math.min(window.innerWidth-H(a),H(f)+e.clientX-H(u))),!0),F(i,Math.max(0,Math.min(window.innerHeight-H(o),H(p)+e.clientY-H(d))),!0))},h=()=>{F(l,!1),window.removeEventListener(`mousemove`,m,!0),window.removeEventListener(`mouseup`,h,!0),c()},g=e=>{e.target.closest(`button, input, select`)||(F(l,!0),F(u,e.clientX,!0),F(d,e.clientY,!0),F(f,H(r),!0),F(p,H(i),!0),window.addEventListener(`mousemove`,m,!0),window.addEventListener(`mouseup`,h,!0))},_=P(!1),v=P(0),y=P(0),b=e=>{H(_)&&(F(a,Math.max(560,Math.min(window.innerWidth-H(r),H(v)+e.clientX-H(u))),!0),F(o,Math.max(360,Math.min(window.innerHeight-H(i),H(y)+e.clientY-H(d))),!0))},x=()=>{F(_,!1),window.removeEventListener(`mousemove`,b,!0),window.removeEventListener(`mouseup`,x,!0),c()},S=e=>{F(_,!0),F(u,e.clientX,!0),F(d,e.clientY,!0),F(v,H(a),!0),F(y,H(o),!0),window.addEventListener(`mousemove`,b,!0),window.addEventListener(`mouseup`,x,!0),e.stopPropagation()};var ee=zu(),C=_i(ee),w=e=>{var t=Lu(),u=L(t),d=L(u),f=R(d,2);yo(f,21,()=>n,ho,(e,t)=>{var n=Iu(),r=L(n),i=e=>{Ac(e,{size:14})},a=e=>{ic(e,{size:14})},o=e=>{Sc(e,{size:14})},s=e=>{gc(e,{size:14})},l=e=>{Oc(e,{size:14})},u=e=>{fc(e,{size:14})},d=e=>{Pc(e,{size:14})},f=e=>{uc(e,{size:14})},p=e=>{mc(e,{size:14})},m=e=>{oc(e,{size:14})},h=e=>{vc(e,{size:14})};mo(r,e=>{H(t).id===`general`?e(i):H(t).id===`vars`?e(a,1):H(t).id===`switches`?e(o,2):H(t).id===`inv`?e(s,3):H(t).id===`actors`?e(l,4):H(t).id===`map`?e(u,5):H(t).id===`commonev`?e(d,6):H(t).id===`locks`?e(f,7):H(t).id===`logs`?e(p,8):H(t).id===`shortcuts`?e(m,9):H(t).id===`settings`&&e(h,10)});var g=R(r,2),_=L(g,!0);D(g),D(n),z(()=>{Jo(n,1,`w-full text-left rounded px-3 py-2 text-xs font-semibold transition-all flex items-center space-x-2.5 focus:outline-none ${Q.activeTab===H(t).id?`bg-[#7ba4ff]/10 text-[#7ba4ff] shadow-sm`:`text-gray-400 hover:bg-[#2a2d3a] hover:text-gray-200`}`),K(_,H(t).label)}),U(`click`,n,()=>{var e;Q.activeTab=H(t).id,(e=window.getSelection())==null||e.removeAllRanges(),c()}),G(e,n)}),D(f);var p=R(f,2),m=L(p);ps(m,`title`,`1.0.0`),m.textContent=`1.0.0`,D(p),D(u);var h=R(u,2),v=L(h),y=L(v),b=L(y,!0);D(y);var x=R(y,2);Mc(L(x),{size:14}),D(x),D(v);var ee=R(v,2),C=L(ee),w=e=>{yl(e,{})},te=e=>{wl(e,{})},ne=e=>{Ol(e,{})},re=e=>{Vl(e,{})},ie=e=>{ru(e,{})},ae=e=>{cu(e,{})},oe=e=>{pu(e,{})},se=e=>{vu(e,{})},ce=e=>{Fu(e,{})},le=e=>{Eu(e,{})},ue=e=>{ku(e,{})};mo(C,e=>{Q.activeTab===Ic.Vars?e(w):Q.activeTab===Ic.Switches?e(te,1):Q.activeTab===Ic.Inv?e(ne,2):Q.activeTab===Ic.Actors?e(re,3):Q.activeTab===Ic.General?e(ie,4):Q.activeTab===Ic.Map?e(ae,5):Q.activeTab===Ic.CommonEv?e(oe,6):Q.activeTab===Ic.Locks?e(se,7):Q.activeTab===Ic.Logs?e(ce,8):Q.activeTab===Ic.Shortcuts?e(le,9):Q.activeTab===Ic.Settings&&e(ue,10)}),D(ee),D(h),il(R(h,2),{onmousedown:S}),D(t),z(e=>{var n,c,u,d;Xo(t,`opacity: ${H(l)||H(_)||H(s)?1:Xc.inactiveOpacity/100}; left: ${(n=H(r))==null?``:n}px; top: ${(c=H(i))==null?``:c}px; width: ${(u=H(a))==null?``:u}px; height: ${(d=H(o))==null?``:d}px; background: #13151a; color: #d4d8e3;`),K(b,e)},[()=>{var e;return((e=n.find(e=>e.id===Q.activeTab))==null?void 0:e.label)||``}]),Ua(`mouseenter`,t,()=>F(s,!0)),Ua(`mouseleave`,t,()=>F(s,!1)),U(`mousedown`,d,g),U(`mousedown`,v,g),U(`click`,x,()=>Q.visible=!1),G(e,t)};mo(C,e=>{Q.visible&&e(w)});var te=R(C,2);yo(te,21,()=>zc.toasts,e=>e.id,(e,t)=>{var n=Ru(),r=L(n),i=R(r,2),a=L(i,!0);D(i),D(n),z(()=>{Xo(n,`background: #1a1d24; border-color: ${H(t).type===`success`?`#10b981`:H(t).type===`warn`?`#fb923c`:H(t).type===`error`?`#ef4444`:`#6366f1`}; opacity: 0.95; min-width: 160px; max-width: 320px;`),Xo(r,`background: ${H(t).type===`success`?`#10b981`:H(t).type===`warn`?`#fb923c`:H(t).type===`error`?`#ef4444`:`#6366f1`};`),K(a,H(t).message)}),G(e,n)}),D(te),ol(R(te,2),{}),G(e,ee),Nt()}Wa([`mousedown`,`click`]);var Vu=`forge-mvmz-host`,Hu=document.getElementById(Vu);Hu||(Hu=document.createElement(`div`),Hu.id=Vu,Hu.style.position=`fixed`,Hu.style.top=`0`,Hu.style.left=`0`,Hu.style.width=`100vw`,Hu.style.height=`100vh`,Hu.style.pointerEvents=`none`,Hu.style.zIndex=`2147483647`,document.body.appendChild(Hu));var Uu=document.createElement(`style`);Uu.textContent=`#${Vu} { z-index: 2147483647 !important; }`,document.head.appendChild(Uu);var Wu=null,Gu;typeof Hu.attachShadow==`function`?(Wu=Hu.attachShadow({mode:`open`}),Gu=Wu,setTimeout(()=>{for(let e of document.head.querySelectorAll(`style`)){let t=e.textContent||``;if(t.includes(`tailwind`)||t.includes(`--color-bg`)){let e=document.createElement(`style`);e.textContent=t,Wu.appendChild(e)}}},0)):(Gu=Hu,setTimeout(()=>{for(let e of document.head.querySelectorAll(`style`)){let t=e.textContent||``;if(t.includes(`tailwind`)||t.includes(`--color-bg`)){let e=document.createElement(`style`);e.textContent=t,document.head.appendChild(e)}}},0));var Ku=document.createElement(`div`);Ku.style.pointerEvents=`none`,Ku.style.width=`100%`,Ku.style.height=`100%`,Gu.appendChild(Ku);try{to(Bu,{target:Ku})}catch(e){console.error(`[FORGE] Error mounting Svelte App:`,e)}if(window.Input!==void 0&&window.Input._onKeyDown){let e=window.Input._onKeyDown;window.Input._onKeyDown=function(t){let n=t.composedPath&&t.composedPath()[0]||t.target;Hu.contains(n)||e.call(this,t)}}if(window.Input!==void 0&&window.Input._onKeyUp){let e=window.Input._onKeyUp;window.Input._onKeyUp=function(t){let n=t.composedPath&&t.composedPath()[0]||t.target;Hu.contains(n)||e.call(this,t)}}})(); \ No newline at end of file diff --git a/js/plugins/TLInspector.js b/js/plugins/TLInspector.js new file mode 100644 index 0000000..01c28cc --- /dev/null +++ b/js/plugins/TLInspector.js @@ -0,0 +1,3041 @@ +//============================================================================= +// TLInspector.js +// Idea by Sakura · Plugin by Kao_SSS +//============================================================================= +/*: + * @plugindesc Translation Source Inspector - shows which source file/line every + * on-screen line of text and image comes from, and jumps to it in VSCode. + * @author Kao_SSS + * + * @help + * ---------------------------------------------------------------------------- + * TLInspector (RPGMaker MV / MZ, NW.js) + * Credits: Idea by Sakura · Plugin by Kao_SSS + * ---------------------------------------------------------------------------- + * A drop-in proofreading aid for translators. While the game runs, it tracks + * every message / choice / scrolling-text line and every on-screen image, and + * maps each one back to its EXACT source file and line number: + * + * - Dialogue / choices / scroll text -> www/data/MapXXX.json, + * CommonEvents.json, Troops.json (by identity-matching the running event + * list, so duplicate strings are never confused). + * - Scenario-plugin dialogue -> scenario/Scenario.json and similar + * (plugin scenario engines such as Nore/"Tes" that keep command-lists in one + * big JSON dictionary keyed by scene name, loaded into $dataScenario). Both + * in-game location and "Locate in Files" cover these. + * - Pictures and other images -> img/... path + the event command + * (or JS call stack) that loaded them. + * - Plugin / menu UI text (Bitmap.drawText / drawTextEx) -> where the VALUE + * itself lives whenever it can be resolved: a TextManager vocab assignment + * in a plugin .js, a System.json term, a database name/description, a + * notetag , or a plugins.js parameter. Strings built with + * String.prototype.format ("%1 remaining") are traced back to their + * template. The draw call site is kept as secondary info. + * + * Press the hotkey (default F10) to open the inspector overlay. Each row has an + * "Open in VSCode" button (runs `code -g file:line`) and an **edit** button to + * change the text and save it back to the source file without leaving the game. + * + * Live refresh (NW.js playtest only): + * In-game overlay "save to file" reloads that JSON into memory immediately. + * VSCode / external saves: we watch data/*.json; once the file mtime is stable + * (save finished), reload instantly. The game cannot hook Ctrl+S in VSCode itself. + * + * Limitations: + * - NW.js desktop playtest only (not browser) + * - Text already shown by a running event won't update until re-triggered + * (in-game overlay edit still updates the current message box) + * - Plugin .js / plugins.js changes still need F5 + * + * ---------------------------------------------------------------------------- + * Install: drop this file in www/js/plugins/ and add one line to plugins.js: + * { "name": "TLInspector", "status": true, "description": "TL source inspector", "parameters": {} } + * Place it LAST in the list. Remove that line to fully disable for a release. + * + * Config: edit the CFG object a few lines below. + * ---------------------------------------------------------------------------- + */ + +(function () { + 'use strict'; + + //========================================================================= + // Config + //========================================================================= + var CFG = { + enabled: true, + hotkey: "F9", // key (event.key) that toggles the overlay + editorCmd: "auto", // 'auto' = auto-detect installed editors (VS Code, Cursor, + // VSCodium, Insiders, Windsurf). Or set an absolute path to + // force a specific editor exe. + editor: 'auto', // which editor click-to-source opens files in: + // 'auto' = VSCode if it's installed, else the built-in + // in-game editor (also the fallback if a + // VSCode launch fails). + // 'builtin' = always the built-in in-game editor (view & + // edit the source file right inside the game). + // 'vscode' = always VSCode (uses editorCmd above). + workspaceFolder: "auto",// 'auto' = open files inside the game ROOT folder as the + // VSCode workspace (so they don't land in whatever window + // happened to be open last). Or set an absolute folder. + editorReuseWindow: true,// pass -r so VSCode reuses its current window + historySize: 80, // how many past text lines to keep + captureUiText: true, // capture plugin / menu / UI text drawn via Bitmap.drawText + // (so e.g. status-window strings from plugins.js are locatable) + dataDirOverride: null, // set an absolute path to force the data dir + uiScale: "2.5" // overlay scale: 'auto' from game width, or a number (1.5, 2, …) + }; + + if (!CFG.enabled) { return; } + + function resolveUiScale(v) { + if (v !== 'auto' && v != null && String(v).trim() !== '') { + var n = parseFloat(v); + if (!isNaN(n) && n > 0) { return Math.max(0.75, Math.min(3, n)); } + } + var base = 816; + var viewW = window.innerWidth || document.documentElement.clientWidth || base; + // The overlay lives in WINDOW pixels, so scale from the window size only. + // Using the game's internal resolution made a 1920px-wide game in a ~1366px + // window zoom 2.35x, with the 460px panel swallowing >80% of the screen. + var scale = viewW / base; + var dpr = window.devicePixelRatio || 1; + if (dpr > 1.15) { scale *= Math.min(2, 0.75 + dpr * 0.35); } + // Whatever the math says, keep the panel under ~45% of the window + // (the >=1 floor below still wins for small windows). + scale = Math.min(scale, (viewW * 0.45) / 460); + return Math.max(1, Math.min(2.75, scale)); + } + + function currentUiScale() { + return resolveUiScale(CFG.uiScale); + } + + function applyOverlayScale() { + var s = currentUiScale(); + var z = (s === 1) ? '' : String(s); + if (ui.root) { + ui.root.style.zoom = z; + ui.root.style.transformOrigin = (ui.side === 'left') ? 'top left' : 'top right'; + } + if (editor.root) { + editor.root.style.zoom = z; + editor.root.style.transformOrigin = 'top center'; + } + if (ui.pickLabel) { ui.pickLabel.style.zoom = z; } + } + + //========================================================================= + // Node / environment bootstrap (NW.js exposes require) + //========================================================================= + var nodeOk = false, fs = null, path = null, cp = null; + try { + if (typeof require === 'function') { + fs = require('fs'); + path = require('path'); + cp = require('child_process'); + nodeOk = true; + } + } catch (e) { nodeOk = false; } + + var ENGINE = (typeof Utils !== 'undefined' && Utils.RPGMAKER_NAME) || 'MV'; + + // Resolve the www root (where index.html lives) -> data dir. + // Primary method = exactly how the engine itself resolves paths + // (StorageManager.localFileDirectoryPath uses process.mainModule.filename), + // which is reliable regardless of the page URL scheme NW.js uses. + function resolveWwwRoot() { + try { + if (nodeOk && process.mainModule && process.mainModule.filename) { + return path.dirname(process.mainModule.filename); + } + } catch (e) { /* fall through */ } + try { + var href = window.location.href; // file:///C:/.../www/index.html + var p = decodeURIComponent(new URL(href).pathname); + if (/^\/[A-Za-z]:\//.test(p)) { p = p.slice(1); } // strip leading slash on Windows + return path ? path.dirname(p) : p.replace(/\/[^\/]*$/, ''); + } catch (e2) { + return nodeOk ? process.cwd() : ''; + } + } + var WWW_ROOT = resolveWwwRoot(); + var DATA_DIR = CFG.dataDirOverride || (path ? path.join(WWW_ROOT, 'data') : WWW_ROOT + '/data'); + + // The game root = folder holding the .exe. On MV that's the PARENT of www/; on MZ + // there is no www/, so it IS the resolved root. Used as the VSCode workspace folder + // so opened files land in the game's own project window, not the last-used one. + var GAME_ROOT = (function () { + try { + if (path && WWW_ROOT && path.basename(WWW_ROOT).toLowerCase() === 'www') { + return path.dirname(WWW_ROOT); + } + } catch (e) { /* ignore */ } + return WWW_ROOT; + })(); + + function mapFile(mapId) { + var n = ('000' + mapId).slice(-3); + return path ? path.join(DATA_DIR, 'Map' + n + '.json') : DATA_DIR + '/Map' + n + '.json'; + } + function dataFile(name) { + return path ? path.join(DATA_DIR, name) : DATA_DIR + '/' + name; + } + + // Scenario systems (e.g. the Nore / "Tes" engine) keep event command-lists OUTSIDE + // Map/CommonEvents/Troops: one big JSON dictionary under scenario/, keyed by scene + // name, loaded into a global ($dataScenario) and run via Game_Interpreter.setupChild. + // Each value is a plain MZ command list, so once we know the file + key it resolves + // to a line just like any other data file. + var SCENARIO_DIR = 'scenario'; + var SCENARIO_SETS = [ + { global: '$dataScenario', file: 'Scenario.json' }, + { global: '$dataScenario_en', file: 'Scenario_en.json' } + ]; + function scenarioPath(fileName) { + return path ? path.join(WWW_ROOT, SCENARIO_DIR, fileName) + : WWW_ROOT + '/' + SCENARIO_DIR + '/' + fileName; + } + // Every *.json actually present in the scenario/ folder (empty for normal games). + function scenarioFiles() { + var out = []; + if (!nodeOk) { return out; } + try { + fs.readdirSync(scenarioPath('')).forEach(function (f) { + if (/\.json$/i.test(f)) { out.push(scenarioPath(f)); } + }); + } catch (e) { /* no scenario/ folder -> normal for most games */ } + return out; + } + // If a scenario file's dictionary is already parsed into a known global, return the + // global name so callers can reuse it instead of re-parsing a (often huge) file. + function scenarioGlobalForFile(file) { + var base = baseName(file).toLowerCase(); + for (var i = 0; i < SCENARIO_SETS.length; i++) { + if (SCENARIO_SETS[i].file.toLowerCase() === base) { return SCENARIO_SETS[i].global; } + } + return null; + } + + function log() { + if (window.console) { console.log.apply(console, ['[TLInspector]'].concat([].slice.call(arguments))); } + } + log('init', { engine: ENGINE, node: nodeOk, dataDir: DATA_DIR, credits: 'Idea by Sakura · Plugin by Kao_SSS' }); + + //========================================================================= + // File cache + JSON value locator (path -> char offset -> line:col) + //========================================================================= + var fileCache = {}; // path -> { mtime, text, lineStarts } + + function readFileCached(file) { + if (!nodeOk) { return null; } + try { + var st = fs.statSync(file); + var mt = st.mtimeMs; + var c = fileCache[file]; + if (c && c.mtime === mt) { return c; } + var text = fs.readFileSync(file, 'utf8'); + var lineStarts = [0]; + for (var i = 0; i < text.length; i++) { + if (text.charCodeAt(i) === 10) { lineStarts.push(i + 1); } + } + c = { mtime: mt, text: text, lineStarts: lineStarts }; + fileCache[file] = c; + return c; + } catch (e) { return null; } + } + + function offsetToLineCol(c, off) { + var ls = c.lineStarts, lo = 0, hi = ls.length - 1, mid; + while (lo < hi) { + mid = (lo + hi + 1) >> 1; + if (ls[mid] <= off) { lo = mid; } else { hi = mid - 1; } + } + return { line: lo + 1, col: off - ls[lo] + 1 }; + } + + // --- minimal structural JSON scanner ------------------------------------ + function skipWs(t, i) { + while (i < t.length) { + var ch = t.charCodeAt(i); + if (ch === 32 || ch === 9 || ch === 10 || ch === 13) { i++; } else { break; } + } + return i; + } + function scanString(t, i) { // i at opening quote -> returns index after closing quote + i++; // past " + while (i < t.length) { + var ch = t[i]; + if (ch === '\\') { i += 2; continue; } + if (ch === '"') { return i + 1; } + i++; + } + return i; + } + function readKey(t, i) { // i at opening quote -> { end, value } + var start = i + 1, j = i + 1, out = ''; + while (j < t.length) { + var ch = t[j]; + if (ch === '\\') { out += t[j + 1]; j += 2; continue; } + if (ch === '"') { return { end: j + 1, value: out }; } + out += ch; j++; + } + return { end: j, value: out }; + } + function skipValue(t, i) { + i = skipWs(t, i); + var ch = t[i]; + if (ch === '"') { return scanString(t, i); } + if (ch === '{' || ch === '[') { + var open = ch, close = ch === '{' ? '}' : ']', depth = 0; + for (; i < t.length; i++) { + var c = t[i]; + if (c === '"') { i = scanString(t, i) - 1; continue; } + if (c === open) { depth++; } + else if (c === close) { depth--; if (depth === 0) { return i + 1; } } + } + return i; + } + // number / true / false / null + while (i < t.length && ',}] \t\r\n'.indexOf(t[i]) === -1) { i++; } + return i; + } + + // Walk `path` (array of string keys / number indices) -> start offset of value, or -1. + function locateOffset(t, pathArr) { + var i = skipWs(t, 0); + for (var s = 0; s < pathArr.length; s++) { + var step = pathArr[s]; + i = skipWs(t, i); + if (typeof step === 'number') { + if (t[i] !== '[') { return -1; } + i = skipWs(t, i + 1); + if (t[i] === ']') { return -1; } + for (var k = 0; k < step; k++) { + i = skipValue(t, i); + i = skipWs(t, i); + if (t[i] !== ',') { return -1; } + i = skipWs(t, i + 1); + } + // i now at target element value start + } else { + if (t[i] !== '{') { return -1; } + i = skipWs(t, i + 1); + var found = false; + while (i < t.length && t[i] !== '}') { + if (t[i] !== '"') { return -1; } + var key = readKey(t, i); + i = skipWs(t, key.end); + if (t[i] !== ':') { return -1; } + i = skipWs(t, i + 1); + if (key.value === step) { found = true; break; } + i = skipValue(t, i); + i = skipWs(t, i); + if (t[i] === ',') { i = skipWs(t, i + 1); } + } + if (!found) { return -1; } + } + } + return skipWs(t, i); + } + + // File drifted under a structural path (e.g. the scenario JSON was re-exported while + // the game held an older parse, shifting command indices): find the exact quoted + // value instead, preferring the occurrence nearest the path's top-level container so + // duplicate lines in other scenes/events don't win. + function reanchorByText(c, pathArr, quoted) { + var hits = [], p = c.text.indexOf(quoted), CAP = 5000; + while (p >= 0 && hits.length < CAP) { hits.push(p); p = c.text.indexOf(quoted, p + quoted.length); } + if (!hits.length) { return null; } + if (hits.length === 1) { return offsetToLineCol(c, hits[0]); } + var anchor = locateOffset(c.text, pathArr.slice(0, 1)); // start of the scene / list + var best = hits[0]; + if (anchor >= 0) { + var bd = Math.abs(hits[0] - anchor); + for (var k = 1; k < hits.length; k++) { var dd = Math.abs(hits[k] - anchor); if (dd < bd) { bd = dd; best = hits[k]; } } + } + return offsetToLineCol(c, best); + } + + var lineCache = {}; // file::pathKey::mtime -> {line,col} + function locateLine(file, pathArr, expectedText) { + if (!file || !pathArr || !nodeOk) { return null; } + var c = readFileCached(file); + if (!c) { return null; } + var key = file + '::' + pathArr.join('/') + '::' + c.mtime; + if (lineCache.hasOwnProperty(key)) { return lineCache[key]; } + var off = locateOffset(c.text, pathArr); + var quoted = (expectedText != null && expectedText !== '') ? JSON.stringify(String(expectedText)) : null; + var res; + if (off >= 0 && (!quoted || c.text.substr(off, quoted.length) === quoted)) { + res = offsetToLineCol(c, off); // path still valid (verified against the text) + } else if (quoted) { + // Path drifted (or the text isn't where the path points) -> re-anchor by exact + // text; if that finds nothing, still fall back to the structural offset. + res = reanchorByText(c, pathArr, quoted) || (off >= 0 ? offsetToLineCol(c, off) : null); + } else { + res = off >= 0 ? offsetToLineCol(c, off) : null; + } + lineCache[key] = res; + return res; + } + + //========================================================================= + // Provenance: map a running event command-list to its source file + path + //========================================================================= + function resolveList(list) { + try { + if (typeof $dataMap !== 'undefined' && $dataMap && $dataMap.events && + typeof $gameMap !== 'undefined' && $gameMap) { + var evs = $dataMap.events; + for (var e = 0; e < evs.length; e++) { + var ev = evs[e]; + if (!ev || !ev.pages) { continue; } + for (var p = 0; p < ev.pages.length; p++) { + if (ev.pages[p].list === list) { + return { file: mapFile($gameMap.mapId()), + prefix: ['events', e, 'pages', p, 'list'], + label: 'Map' + ('000' + $gameMap.mapId()).slice(-3) + ' ev' + e }; + } + } + } + } + if (typeof $dataCommonEvents !== 'undefined' && $dataCommonEvents) { + for (var c = 0; c < $dataCommonEvents.length; c++) { + var ce = $dataCommonEvents[c]; + if (ce && ce.list === list) { + return { file: dataFile('CommonEvents.json'), + prefix: [c, 'list'], label: 'CommonEvent ' + c }; + } + } + } + if (typeof $gameTroop !== 'undefined' && $gameTroop && $gameTroop._troopId && + typeof $dataTroops !== 'undefined' && $dataTroops) { + var tr = $dataTroops[$gameTroop._troopId]; + if (tr && tr.pages) { + for (var tp = 0; tp < tr.pages.length; tp++) { + if (tr.pages[tp].list === list) { + return { file: dataFile('Troops.json'), + prefix: [$gameTroop._troopId, 'pages', tp, 'list'], + label: 'Troop ' + $gameTroop._troopId }; + } + } + } + } + // Scenario dictionaries: the running list is a value of $dataScenario keyed + // by scene name (setupChild runs the list by reference, so identity holds). + for (var si = 0; si < SCENARIO_SETS.length; si++) { + var sg = SCENARIO_SETS[si], dict = window[sg.global]; + if (!dict || typeof dict !== 'object') { continue; } + for (var sk in dict) { + if (dict.hasOwnProperty(sk) && dict[sk] === list) { + return { file: scenarioPath(sg.file), prefix: [sk], + label: sg.file.replace(/\.json$/i, '') + ':' + sk }; + } + } + } + } catch (e) { log('resolveList error', e); } + return null; + } + + function pathToString(arr) { + var s = ''; + for (var i = 0; i < arr.length; i++) { + s += typeof arr[i] === 'number' ? '[' + arr[i] + ']' : (i ? '.' : '') + arr[i]; + } + return s; + } + + //========================================================================= + // Record store + //========================================================================= + var groupSeq = 0; + var currentGroup = -1; + var textRecords = []; // {kind,text,file,prefix,tail,group,ts,_key} + var imageTriggers = {}; // picture filename -> {file,prefix,tail,label} + var BUMP_GUARD_MS = 1000; + + function findByKey(key) { + for (var i = 0; i < textRecords.length; i++) { if (textRecords[i]._key === key) { return i; } } + return -1; + } + // Text seen again -> move it to the top (newest) so it never feels "undetected" + // when it was buried in history. Guard against churn from per-frame UI redraws. + function seenExisting(i, group) { + var r = textRecords[i], now = Date.now(); + if (now - r.ts < BUMP_GUARD_MS) { + r.ts = now; if (group != null && group !== -1) { r.group = group; } + return; // recently seen: keep its position + } + textRecords.splice(i, 1); + r.ts = now; if (group != null && group !== -1) { r.group = group; } + textRecords.push(r); + scheduleRefresh(); + } + + function pushText(kind, prov, tail, text, group, srcIndex, srcEventId) { + if (text == null || text === '') { return; } + var file = prov ? prov.file : null; + var key = 't\u0000' + kind + '\u0000' + text + '\u0000' + (file || '') + '\u0000' + (tail ? JSON.stringify(tail) : ''); + var i = findByKey(key); + if (i >= 0) { seenExisting(i, group); return; } + textRecords.push({ + kind: kind, text: text, file: file, + prefix: prov ? prov.prefix : null, + tail: tail, label: prov ? prov.label : '(unresolved)', + group: group, ts: Date.now(), + srcIndex: (srcIndex == null ? null : srcIndex), + srcEventId: (srcEventId == null ? 0 : srcEventId), + _key: key + }); + while (textRecords.length > CFG.historySize) { textRecords.shift(); } + scheduleRefresh(); + } + + function captureFromList(list, startIdx, textCode, eventId) { + var prov = resolveList(list); + var group = ++groupSeq; + currentGroup = group; + var i = startIdx + 1; + while (i < list.length && list[i] && list[i].code === textCode) { + pushText('text', prov, prov ? prov.prefix.concat([i, 'parameters', 0]) : null, + list[i].parameters[0], group, i, eventId); + i++; + } + // inline "Show Choices" immediately following the text block + if (list[i] && list[i].code === 102) { + captureChoices(list, i, prov, group, eventId); + } + } + + function captureChoices(list, idx, prov, group, eventId) { + if (prov === undefined) { prov = resolveList(list); } + if (group === undefined) { group = ++groupSeq; currentGroup = group; } + var choices = list[idx] && list[idx].parameters && list[idx].parameters[0]; + if (!Array.isArray(choices)) { return; } + for (var n = 0; n < choices.length; n++) { + pushText('choice', prov, + prov ? prov.prefix.concat([idx, 'parameters', 0, n]) : null, + choices[n], group, idx, eventId); + } + } + + //========================================================================= + // Hooks: text + //========================================================================= + if (typeof Game_Interpreter !== 'undefined') { + var GI = Game_Interpreter.prototype; + + var _c101 = GI.command101; + GI.command101 = function () { + var list = this._list, start = this._index; + var r = _c101.apply(this, arguments); + try { if (this._index !== start) { captureFromList(list, start, 401, this._eventId); } } + catch (e) { log('c101', e); } + return r; + }; + + var _c105 = GI.command105; + GI.command105 = function () { + var list = this._list, start = this._index; + var r = _c105.apply(this, arguments); + try { if (this._index !== start) { captureFromList(list, start, 405, this._eventId); } } + catch (e) { log('c105', e); } + return r; + }; + + var _c102 = GI.command102; + GI.command102 = function () { + // A STANDALONE "Show Choices" (not following a message — those are consumed + // inside command101) doesn't advance this._index within the method: MV bumps + // it later in executeCommand, MZ takes params as an arg. So gating on an index + // change missed standalone choice menus entirely. Instead capture exactly when + // the choices get set up: this call, while the message box wasn't already busy. + var list = this._list, idx = this._index; + var wasBusy = (typeof $gameMessage !== 'undefined') && $gameMessage && + $gameMessage.isBusy && $gameMessage.isBusy(); + var r = _c102.apply(this, arguments); + try { + if (!wasBusy && list && list[idx] && list[idx].code === 102) { + captureChoices(list, idx, undefined, undefined, this._eventId); + } + } catch (e) { log('c102', e); } + return r; + }; + + // Show Picture -> remember which command triggered each picture file + var _c231 = GI.command231; + GI.command231 = function () { + try { + var list = this._list, idx = this._index; + var name = this._params && this._params[1]; + if (name) { + var prov = resolveList(list); + imageTriggers['img/pictures/' + name + '.png'] = { + file: prov ? prov.file : null, + path: prov ? prov.prefix.concat([idx, 'parameters', 1]) : null, + label: prov ? prov.label : '(unresolved)' + }; + } + } catch (e) { log('c231', e); } + return _c231.apply(this, arguments); + }; + } + + // Clear "live" marker when the message box closes + if (typeof Game_Message !== 'undefined') { + var _clear = Game_Message.prototype.clear; + Game_Message.prototype.clear = function () { + currentGroup = -1; + scheduleRefresh(); + return _clear.apply(this, arguments); + }; + } + + // Capture plugin / menu / UI text. The true chokepoint is Bitmap.drawText: + // Window_Base.drawText/drawTextEx AND direct `this.contents.drawText(...)` calls + // inside plugins all funnel through it. We skip while a message box is showing + // (that text is captured precisely via the interpreter hooks) and de-duplicate by + // a digit-normalized key so a ticking value ("Money: 12"/"Money: 13") logs once. + if (CFG.captureUiText && typeof Bitmap !== 'undefined' && Bitmap.prototype.drawText) { + // Direct draws (Window_Base.drawText, plugin `this.contents.drawText(...)`). + // drawTextEx renders one character per call here, so single chars are dropped. + var _bmDrawText = Bitmap.prototype.drawText; + Bitmap.prototype.drawText = function (text) { + try { maybeCaptureUiText(text); } catch (e) { /* ignore */ } + return _bmDrawText.apply(this, arguments); + }; + } + if (CFG.captureUiText && typeof Window_Base !== 'undefined' && Window_Base.prototype.drawTextEx) { + // Escape-processed text (item descriptions, help text, names) arrives here as a + // whole string before being drawn character-by-character. + var _drawTextEx = Window_Base.prototype.drawTextEx; + Window_Base.prototype.drawTextEx = function (text) { + try { maybeCaptureUiText(text); } catch (e) { /* ignore */ } + return _drawTextEx.apply(this, arguments); + }; + } + function maybeCaptureUiText(text) { + if (typeof text !== 'string') { return; } + if (text.replace(/\s/g, '').length < 2) { return; } // drop single chars (per-char draws) + if (!/[^\s\d.,:%/+\-()]/.test(text)) { return; } // require a real letter + if (typeof $gameMessage !== 'undefined' && $gameMessage && $gameMessage.isBusy && $gameMessage.isBusy()) { return; } + var key = 'ui ' + text.replace(/\d+/g, '#'); // digit-normalized: "Money: 12/13" -> one entry + var i = findByKey(key); + if (i >= 0) { seenExisting(i, -1); return; } + var site = firstUserFrame(new Error().stack); + var rec = { kind: 'ui', text: text, file: site.file, prefix: null, + tail: null, label: site.label, uiLine: site.line, uiCol: null, + group: -1, ts: Date.now(), _key: key }; + // Prefer the VALUE's own home (vocab assignment / term / notetag / parameter) + // over the draw call site; keep the site as secondary info. + try { + var src = resolveUiSource(text); + if (src) { + rec.srcKind = src.kind; rec.label = src.label; rec.expText = src.expText; + if (src.file) { + rec.file = src.file; rec.uiLine = src.line || null; rec.uiCol = src.col || null; + rec.tail = src.tail || null; + rec.siteFile = site.file; rec.siteLine = site.line; rec.siteLabel = site.label; + } + } + } catch (e) { log('uiSource', e); } + textRecords.push(rec); + while (textRecords.length > CFG.historySize) { textRecords.shift(); } + scheduleRefresh(); + } + + function firstUserFrame(stack) { + var lines = (stack || '').split('\n'); + for (var i = 1; i < lines.length; i++) { + var m = lines[i].match(/(js\/plugins\/[^):]+|js\/[^):]+):(\d+):(\d+)/); + if (m && m[1].indexOf('TLInspector') === -1) { + var f = m[1]; + return { file: path ? path.join(WWW_ROOT, f) : WWW_ROOT + '/' + f, + line: parseInt(m[2], 10), label: f + ':' + m[2] }; + } + } + return { file: null, line: null, label: '(unknown)' }; + } + + //========================================================================= + // UI text provenance: map a drawn string back to the VALUE's own home + // (TextManager vocab assignment, System.json term, database field, notetag + // meta value, or plugins.js parameter) instead of just the draw call site. + // Index is built lazily from live game state; invalidated on F9 reload. + //========================================================================= + var uiValueIndex = null, uiIndexBuiltAt = 0; + + function uiIndexAdd(map, value, cand) { + if (typeof value !== 'string') { return; } + if (value.replace(/\s/g, '').length < 2) { return; } // same floor as capture + (map[value] || (map[value] = [])).push(cand); + } + + function buildUiValueIndex() { + // null prototype: game text can legitimately be 'constructor'/'toString'… + var map = Object.create(null); + // TextManager vocab: plugin-assigned own DATA properties. (The engine's own + // terms are accessor properties reading $dataSystem.terms -> indexed below.) + try { + if (typeof TextManager !== 'undefined') { + Object.getOwnPropertyNames(TextManager).forEach(function (p) { + var d = Object.getOwnPropertyDescriptor(TextManager, p); + if (d && !d.get && typeof d.value === 'string') { + uiIndexAdd(map, d.value, { t: 'tm', prop: p }); + } + }); + } + } catch (e) { log('uiIndex tm', e); } + // System.json: terms, type-name lists, and a few top-level strings. + try { + if (typeof $dataSystem !== 'undefined' && $dataSystem) { + var sysFile = dataFile('System.json'); + var terms = $dataSystem.terms || {}; + ['basic', 'commands', 'params'].forEach(function (g) { + (terms[g] || []).forEach(function (v, i) { + uiIndexAdd(map, v, { t: 'json', file: sysFile, path: ['terms', g, i], + label: 'System terms.' + g + '[' + i + ']' }); + }); + }); + var msgs = terms.messages || {}; + Object.keys(msgs).forEach(function (k) { + uiIndexAdd(map, msgs[k], { t: 'json', file: sysFile, path: ['terms', 'messages', k], + label: 'System terms.messages.' + k }); + }); + ['elements', 'skillTypes', 'weaponTypes', 'armorTypes', 'equipTypes'].forEach(function (g) { + ($dataSystem[g] || []).forEach(function (v, i) { + uiIndexAdd(map, v, { t: 'json', file: sysFile, path: [g, i], + label: 'System ' + g + '[' + i + ']' }); + }); + }); + uiIndexAdd(map, $dataSystem.gameTitle, { t: 'json', file: sysFile, path: ['gameTitle'], label: 'System gameTitle' }); + uiIndexAdd(map, $dataSystem.currencyUnit, { t: 'json', file: sysFile, path: ['currencyUnit'], label: 'System currencyUnit' }); + } + } catch (e) { log('uiIndex system', e); } + // Database display fields + notetag meta values. A meta value resolves to the + // object's "note" line; locateMetaValue narrows to the value inside the tag. + [ + ['$dataActors', 'Actors.json', ['name', 'nickname', 'profile']], + ['$dataClasses', 'Classes.json', ['name']], + ['$dataSkills', 'Skills.json', ['name', 'description', 'message1', 'message2']], + ['$dataItems', 'Items.json', ['name', 'description']], + ['$dataWeapons', 'Weapons.json', ['name', 'description']], + ['$dataArmors', 'Armors.json', ['name', 'description']], + ['$dataEnemies', 'Enemies.json', ['name']], + ['$dataStates', 'States.json', ['name', 'message1', 'message2', 'message3', 'message4']] + ].forEach(function (spec) { + try { + var arr = window[spec[0]]; + if (!Array.isArray(arr)) { return; } + var file = dataFile(spec[1]), short = spec[1].replace(/\.json$/i, ''); + for (var id = 1; id < arr.length; id++) { + var o = arr[id]; + if (!o) { continue; } + spec[2].forEach(function (f) { + uiIndexAdd(map, o[f], { t: 'json', file: file, path: [id, f], + label: short + '[' + id + '].' + f }); + }); + if (o.meta) { + Object.keys(o.meta).forEach(function (mk) { + if (typeof o.meta[mk] === 'string') { + uiIndexAdd(map, o.meta[mk], { t: 'meta', file: file, path: [id, 'note'], + label: short + '[' + id + '] note <' + mk + ':…>' }); + } + }); + } + } + } catch (e) { log('uiIndex ' + spec[0], e); } + }); + // Plugin parameters (plugins.js). + try { + if (window.$plugins) { + window.$plugins.forEach(function (pl) { + if (!pl || pl.status === false || !pl.parameters) { return; } + Object.keys(pl.parameters).forEach(function (pk) { + uiIndexAdd(map, pl.parameters[pk], { t: 'param', plugin: pl.name, param: pk }); + }); + }); + } + } catch (e) { log('uiIndex params', e); } + return map; + } + + function uiValueCandidates(text) { + if (!uiValueIndex) { uiValueIndex = buildUiValueIndex(); uiIndexBuiltAt = Date.now(); } + if (!jsLitIndex) { jsLitIndex = buildJsLitIndex(); } + var c = uiValueIndex[text] || null; + var lits = jsLitIndex[text] || null; + if (!c && !lits && Date.now() - uiIndexBuiltAt > 5000) { + // Vocab tables can be rewritten at runtime (language toggles): on a miss, + // rebuild against current state, at most once every 5s. + uiValueIndex = buildUiValueIndex(); uiIndexBuiltAt = Date.now(); + c = uiValueIndex[text] || null; + } + if (lits) { c = (c || []).concat(lits); } + return c; + } + + // Parse a JS string literal starting at t[i] (the quote) -> {value, end} or null. + function parseJsString(t, i) { + var q = t[i]; + if (q !== '"' && q !== "'" && q !== '`') { return null; } + var out = '', j = i + 1; + while (j < t.length) { + var ch = t[j]; + if (ch === '\\') { + var n = t[j + 1]; + if (n === 'n') { out += '\n'; } + else if (n === 't') { out += '\t'; } + else if (n === 'r') { out += '\r'; } + else if (n === 'u') { out += String.fromCharCode(parseInt(t.substr(j + 2, 4), 16) || 0); j += 4; } + else if (n === 'x') { out += String.fromCharCode(parseInt(t.substr(j + 2, 2), 16) || 0); j += 2; } + else { out += n; } + j += 2; continue; + } + if (ch === q) { return { value: out, end: j + 1 }; } + if (ch === '\n' && q !== '`') { return null; } // unterminated + out += ch; j++; + } + return null; + } + + // Plugin .js files in LOAD order (later plugins overwrite earlier assignments, so + // "last literal match" below = the assignment that actually won at runtime). + function pluginFilesInLoadOrder() { + var out = []; + if (!nodeOk) { return out; } + var pdir = path.join(WWW_ROOT, 'js', 'plugins'); + try { + if (window.$plugins) { + window.$plugins.forEach(function (pl) { + if (pl && pl.status !== false && pl.name && pl.name !== 'TLInspector') { + out.push(path.join(pdir, pl.name + '.js')); + } + }); + } + } catch (e) { /* ignore */ } + if (!out.length) { + try { + fs.readdirSync(pdir).forEach(function (f) { + if (/\.js$/.test(f) && f !== 'TLInspector.js') { out.push(path.join(pdir, f)); } + }); + } catch (e) { /* ignore */ } + } + return out; + } + + // Find the plugin-file assignment `TextManager. = ''` whose literal + // equals the property's CURRENT runtime value — this is what distinguishes an + // English vocab file from the Japanese one when both assign the same property. + // Falls back to the last assignment site in load order (value built at runtime). + var tmAssignCache = {}; // prop \0 value -> {file,line,col,exact} | null + function locateTextManagerAssignment(prop, value) { + var key = prop + '\u0000' + value; + if (tmAssignCache.hasOwnProperty(key)) { return tmAssignCache[key]; } + var safe = String(prop).replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + var re = new RegExp('TextManager\\s*(?:\\.\\s*' + safe + + '|\\[\\s*[\'"]' + safe + '[\'"]\\s*\\])\\s*=(?![=>])', 'g'); + var literalHit = null, lastSite = null; + pluginFilesInLoadOrder().forEach(function (file) { + var c = readFileCached(file); + if (!c) { return; } + re.lastIndex = 0; + var m; + while ((m = re.exec(c.text))) { + if (inComment(c, m.index)) { continue; } + var vi = skipWs(c.text, m.index + m[0].length); + var site = { file: file, off: vi }; + lastSite = site; + var lit = parseJsString(c.text, vi); + if (lit && lit.value === value) { literalHit = site; } + } + }); + var hit = literalHit || lastSite, res = null; + if (hit) { + var lc = offsetToLineCol(readFileCached(hit.file), hit.off); + res = { file: hit.file, line: lc.line, col: lc.col, off: hit.off, exact: !!literalHit }; + } + tmAssignCache[key] = res; + return res; + } + + // Locate a plugin parameter value inside plugins.js (bounded to that plugin's entry). + function locatePluginParam(plugin, param, value) { + if (!nodeOk) { return null; } + var file = path.join(WWW_ROOT, 'js', 'plugins.js'); + var c = readFileCached(file); + if (!c) { return null; } + var anchor = c.text.indexOf('"name":"' + plugin + '"'); + if (anchor < 0) { + anchor = c.text.search(new RegExp('"name"\\s*:\\s*"' + + String(plugin).replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '"')); + } + if (anchor < 0) { return null; } + var next = c.text.indexOf('"name":', anchor + 7); // start of the NEXT plugin entry + var p = c.text.indexOf(JSON.stringify(String(value)), anchor); + var lc = offsetToLineCol(c, (p >= 0 && (next < 0 || p < next)) ? p : anchor); + return { file: file, line: lc.line, col: lc.col }; + } + + // Line/col of a notetag VALUE inside an object's "note" string. The JSON path + // points at the whole note; narrow to the meta value's escaped text within it. + function locateMetaValue(file, pathArr, value) { + if (!file || !pathArr || !nodeOk) { return null; } + var c = readFileCached(file); + if (!c) { return null; } + var key = file + '::meta:' + pathArr.join('/') + '::' + value + '::' + c.mtime; + if (lineCache.hasOwnProperty(key)) { return lineCache[key]; } + var res = null; + var off = locateOffset(c.text, pathArr); + if (off >= 0 && c.text[off] === '"') { + var end = scanString(c.text, off); + var esc = JSON.stringify(String(value)).slice(1, -1); + var p = esc ? c.text.indexOf(esc, off) : -1; + res = offsetToLineCol(c, (p >= 0 && p < end) ? p : off); + } else if (off >= 0) { + res = offsetToLineCol(c, off); + } + lineCache[key] = res; + return res; + } + + // String literals hardcoded in plugin .js code — e.g. a medal/skill table defined + // as arrays right in a plugin ("Great Sage" in Nore_MedalParam.js). Lowest-priority + // source: a drawn string can coincidentally equal an unrelated code literal, so + // vocab/data/notetag/param sources always win over this. Built once, lazily + // (plugin files can't change without F5); dropped on F9 in case one was edited + // through the built-in editor. + var jsLitIndex = null; + var JSLIT_MAX_PER_VALUE = 8; + function buildJsLitIndex() { + // null prototype: plugin code is full of literals like 'constructor'/'toString' + var map = Object.create(null); + pluginFilesInLoadOrder().forEach(function (file) { + var c = readFileCached(file); + if (!c) { return; } + var t = c.text, i = 0, n = t.length; + while (i < n) { + var ch = t[i], nx = t[i + 1]; + if (ch === '/' && nx === '/') { var e1 = t.indexOf('\n', i); i = e1 < 0 ? n : e1 + 1; continue; } + if (ch === '/' && nx === '*') { var e2 = t.indexOf('*/', i + 2); i = e2 < 0 ? n : e2 + 2; continue; } + if (ch === '"' || ch === "'" || ch === '`') { + var lit = parseJsString(t, i); + if (lit) { + var v = lit.value; + // same floors as maybeCaptureUiText: >=2 non-space chars + a real letter + if (v.replace(/\s/g, '').length >= 2 && /[^\s\d.,:%/+\-()]/.test(v)) { + var arr = map[v] || (map[v] = []); + if (arr.length < JSLIT_MAX_PER_VALUE) { arr.push({ t: 'jslit', file: file, off: i }); } + } + i = lit.end; continue; + } + } + i++; + } + }); + return map; + } + + // Recent String.prototype.format calls (template -> output), so a drawn string + // like "2 turn(s) remaining" resolves to its '%1 turn(s) remaining' template even + // though the drawn form never exists in any file. + var FORMAT_LOG = [], FORMAT_LOG_MAX = 40; + if (CFG.captureUiText && String.prototype.format) { + var _strFormat = String.prototype.format; + String.prototype.format = function () { + var out = _strFormat.apply(this, arguments); + try { + if (arguments.length && typeof out === 'string' && out.length >= 2) { + var tpl = String(this); + if (tpl !== out) { + var last = FORMAT_LOG[FORMAT_LOG.length - 1]; + if (!last || last.out !== out || last.tpl !== tpl) { + FORMAT_LOG.push({ tpl: tpl, out: out }); + if (FORMAT_LOG.length > FORMAT_LOG_MAX) { FORMAT_LOG.shift(); } + } + } + } + } catch (e) { /* ignore */ } + return out; + }; + } + + // Drawn string -> best value-source descriptor, or null if unknown. + function resolveUiSource(text) { + var val = text, via = '', cands = uiValueCandidates(text); + if (!cands) { + for (var i = FORMAT_LOG.length - 1; i >= 0; i--) { + if (FORMAT_LOG[i].out === text) { + cands = uiValueCandidates(FORMAT_LOG[i].tpl); + if (cands) { val = FORMAT_LOG[i].tpl; via = ' ← format()'; } + break; + } + } + } + if (!cands || !cands.length) { return null; } + var ORDER = { tm: 0, json: 1, meta: 2, param: 3, jslit: 4 }; + var best = cands[0]; + for (var k = 1; k < cands.length; k++) { + if (ORDER[cands[k].t] < ORDER[best.t]) { best = cands[k]; } + } + var loc = null; + if (best.t === 'tm') { + loc = locateTextManagerAssignment(best.prop, val); + // The assignment's own RHS literal is also in the jslit index — that's the + // SAME location, not an "other match": drop it before counting extras. + if (loc) { + cands = cands.filter(function (x) { + return !(x.t === 'jslit' && x.file === loc.file && x.off === loc.off); + }); + } + } + var extra = cands.length - 1; + var suffix = via + (extra > 0 ? ' (+' + extra + ' other match' + (extra > 1 ? 'es' : '') + ')' : ''); + if (best.t === 'tm') { + if (loc) { + return { kind: 'tm', file: loc.file, line: loc.line, col: loc.col, + label: 'TextManager.' + best.prop + suffix, expText: val }; + } + return { kind: 'tm', file: null, expText: val, + label: 'TextManager.' + best.prop + ' (assignment not in plugin files)' + suffix }; + } + if (best.t === 'param') { + var pp = locatePluginParam(best.plugin, best.param, val); + return { kind: 'param', file: pp && pp.file, line: pp && pp.line, col: pp && pp.col, + label: 'plugins.js ' + best.plugin + ' → ' + best.param + suffix, expText: val }; + } + if (best.t === 'jslit') { + var cf = readFileCached(best.file); + if (!cf) { return null; } + var ll = offsetToLineCol(cf, best.off); + return { kind: 'jslit', file: best.file, line: ll.line, col: ll.col, + label: baseName(best.file) + ' string literal' + suffix, expText: val }; + } + return { kind: best.t, file: best.file, tail: best.path, label: best.label + suffix, expText: val }; + } + + //========================================================================= + // Hooks: images (load log with call-site) + //========================================================================= + var imageLog = []; // {url, label, ts, bitmap} + if (typeof ImageManager !== 'undefined') { + var _loadBitmap = ImageManager.loadBitmap; + ImageManager.loadBitmap = function (folder, filename) { + var bm = _loadBitmap.apply(this, arguments); + try { + if (filename) { + var url = folder + filename + '.png'; + var last = imageLog[imageLog.length - 1]; + if (!last || last.url !== url) { + var site = firstUserFrame(new Error().stack); + imageLog.push({ url: url, label: site.label, ts: Date.now(), bitmap: bm }); + while (imageLog.length > CFG.historySize) { imageLog.shift(); } + } else if (last && !last.bitmap) { last.bitmap = bm; } + } + } catch (e) { /* ignore */ } + return bm; + }; + } + + //========================================================================= + // Live on-screen image collection (walk the sprite tree) + //========================================================================= + function collectOnScreenImages() { + var out = [], seen = {}; + var scene = (typeof SceneManager !== 'undefined') && SceneManager._scene; + if (!scene) { return out; } + var canvas = getGameCanvas(); + var rect = canvas ? canvas.getBoundingClientRect() : null; + var scale = rect && typeof Graphics !== 'undefined' && Graphics.width ? + rect.width / Graphics.width : 1; + + (function walk(obj) { + if (!obj) { return; } + if (obj.visible === false) { return; } + var bmp = obj.bitmap; + if (bmp && bmp._url) { + var vis = ('worldVisible' in obj) ? obj.worldVisible : true; + if (vis) { + var b = null; + try { b = obj.getBounds && obj.getBounds(); } catch (e) { b = null; } + if (b && b.width > 0 && b.height > 0) { + if (!seen[bmp._url]) { seen[bmp._url] = true; } + out.push({ + url: decodeUrl(bmp._url), + bitmap: bmp, + screen: rect ? { + x: rect.left + b.x * scale, y: rect.top + b.y * scale, + w: b.width * scale, h: b.height * scale + } : null + }); + } + } + } + var kids = obj.children; + if (kids) { for (var i = 0; i < kids.length; i++) { walk(kids[i]); } } + })(scene); + return out; + } + + function getGameCanvas() { + if (typeof Graphics !== 'undefined') { + if (Graphics._canvas) { return Graphics._canvas; } + if (Graphics._renderer && Graphics._renderer.view) { return Graphics._renderer.view; } + } + return document.querySelector('canvas'); + } + + // Bitmap URLs are percent-encoded (ImageManager uses encodeURIComponent on the + // filename), e.g. "img/pictures/%E3%83%90%E3%82%B9.png" for "バス". Decode so the + // path matches the real file on disk. + function decodeUrl(u) { + if (!u) { return u; } + try { return decodeURIComponent(u); } catch (e) { return u; } + } + + function urlToAbsPath(url) { + if (!url) { return null; } + var rel = decodeUrl(url).replace(/^\.?\//, ''); + return path ? path.join(WWW_ROOT, rel) : WWW_ROOT + '/' + rel; + } + + //========================================================================= + // External actions (VSCode / file explorer) + //========================================================================= + // Auto-locate installed editors so the user never has to touch the system PATH. + // We support the whole VS Code family (VS Code, Insiders, Cursor, VSCodium, + // Windsurf): they share an identical CLI (" -g file:line:col"), so the + // same launch path works for all of them. The user picks which one to use from a + // dropdown in the panel (see the editor ); the choice is remembered. + // + // Each candidate is [id, display name, absolute exe path]. The first existing + // path for a given id wins; ids are de-duplicated so each editor lists once. + function editorCandidates() { + var defs = []; + if (!nodeOk) { return defs; } + var env = process.env, plat = process.platform; + function J() { return path.join.apply(path, arguments); } + if (plat === 'win32') { + [env.LOCALAPPDATA, env.ProgramFiles, env['ProgramFiles(x86)']].forEach(function (b) { + if (!b) { return; } + defs.push(['vscode', 'VS Code', J(b, 'Programs', 'Microsoft VS Code', 'Code.exe')]); + defs.push(['vscode', 'VS Code', J(b, 'Microsoft VS Code', 'Code.exe')]); + defs.push(['insiders', 'VS Code Insiders', J(b, 'Programs', 'Microsoft VS Code Insiders', 'Code - Insiders.exe')]); + defs.push(['cursor', 'Cursor', J(b, 'Programs', 'cursor', 'Cursor.exe')]); + defs.push(['cursor', 'Cursor', J(b, 'cursor', 'Cursor.exe')]); + defs.push(['vscodium', 'VSCodium', J(b, 'Programs', 'VSCodium', 'VSCodium.exe')]); + defs.push(['vscodium', 'VSCodium', J(b, 'VSCodium', 'VSCodium.exe')]); + defs.push(['windsurf', 'Windsurf', J(b, 'Programs', 'Windsurf', 'Windsurf.exe')]); + }); + } else if (plat === 'darwin') { + defs.push(['vscode', 'VS Code', '/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code']); + defs.push(['insiders', 'VS Code Insiders', '/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code']); + defs.push(['cursor', 'Cursor', '/Applications/Cursor.app/Contents/Resources/app/bin/cursor']); + defs.push(['vscodium', 'VSCodium', '/Applications/VSCodium.app/Contents/Resources/app/bin/codium']); + defs.push(['windsurf', 'Windsurf', '/Applications/Windsurf.app/Contents/Resources/app/bin/windsurf']); + } else { + defs.push(['vscode', 'VS Code', '/usr/bin/code']); + defs.push(['vscode', 'VS Code', '/usr/share/code/bin/code']); + defs.push(['vscode', 'VS Code', '/snap/bin/code']); + defs.push(['cursor', 'Cursor', '/usr/bin/cursor']); + defs.push(['vscodium', 'VSCodium', '/usr/bin/codium']); + defs.push(['windsurf', 'Windsurf', '/usr/bin/windsurf']); + } + return defs; + } + + var _editorList = null; + function detectEditors() { + if (_editorList) { return _editorList; } + _editorList = []; + var seen = {}; + // An explicit CFG.editorCmd path always wins and heads the list. + if (CFG.editorCmd && CFG.editorCmd !== 'auto') { + _editorList.push({ id: 'custom', name: 'Custom (config)', cmd: CFG.editorCmd }); + seen.custom = true; + } + editorCandidates().forEach(function (d) { + var id = d[0]; + if (seen[id]) { return; } + try { + if (fs.existsSync(d[2])) { + seen[id] = true; + _editorList.push({ id: id, name: d[1], cmd: d[2] }); + log('editor found', d[1], d[2]); + } + } catch (e) { /* ignore */ } + }); + // Always offer a PATH-based VS Code fallback so there's at least one option even + // when nothing was found on disk (the user may have `code` on PATH). + if (!seen.vscode && !seen.custom) { + _editorList.push({ id: 'vscode', name: 'VS Code (PATH)', cmd: 'code' }); + } + return _editorList; + } + + // The editor currently selected in the dropdown (or the first available one). + function currentEditor() { + var list = detectEditors(); + if (!list.length) { return { id: 'vscode', name: 'VS Code (PATH)', cmd: 'code' }; } + for (var i = 0; i < list.length; i++) { + if (list[i].id === ui.editorId) { return list[i]; } + } + return list[0]; + } + + // True when at least one real external editor exe was located on disk (not just the + // bare 'code' PATH fallback). 'auto' mode uses this to pick external vs built-in. + function vscodeAvailable() { + var list = detectEditors(); + for (var i = 0; i < list.length; i++) { + if (list[i].cmd !== 'code') { return true; } + } + return false; + } + + // The header checkbox (ui.useBuiltin) is the live switch; CFG.editor is just the + // initial default it's seeded from at startup. + function shouldUseBuiltin() { + if (ui && ui.useBuiltin != null) { return ui.useBuiltin; } + return CFG.editor === 'builtin' || (CFG.editor !== 'vscode' && !vscodeAvailable()); + } + + function openInEditor(file, line, col) { + if (!nodeOk || !file) { toast('No file resolved for this entry'); return; } + // Route to the built-in in-game editor when the header switch (or config) selects + // it, so users without VSCode - or who prefer editing in-game - still get it. + if (shouldUseBuiltin()) { + openBuiltInEditor(file, line, col); + return; + } + var loc = file + (line ? ':' + line + (col ? ':' + col : '') : ''); + var ed = currentEditor(); + var cmd = ed.cmd; + // Pass the game folder so VSCode opens (or reuses) THAT workspace and reveals the + // file in it, instead of dropping the file into whatever window was last focused. + // Passing a folder makes VSCode route to the matching window itself, so we drop the + // -r "reuse last window" flag (which is what caused the wrong-workspace behavior). + var ws = (CFG.workspaceFolder && CFG.workspaceFolder !== 'auto') ? CFG.workspaceFolder : GAME_ROOT; + var done = function (err) { + if (err) { + log('editor', err); + toast(ed.name + ' launch failed - opening the built-in editor'); + openBuiltInEditor(file, line, col); + } + }; + try { + if (cmd === 'code') { + // PATH fallback (code.cmd) needs a shell. The command line does NOT + // start with a quote (program name has no spaces) and each path IS + // quoted, so spaces in the paths are preserved instead of being split + // into separate arguments. + var folder = ws ? '"' + ws + '" ' : ''; + cp.exec(cmd + ' ' + folder + '-g "' + loc + '"', { cwd: WWW_ROOT }, done); + } else { + // Resolved absolute editor exe: run with no shell. Node quotes each + // argument, so a path with spaces stays a single argument. + var args = []; + if (ws) { args.push(ws); } + args.push('-g', loc); + cp.execFile(cmd, args, { cwd: WWW_ROOT }, done); + } + } catch (e) { toast('Editor launch failed'); log(e); } + } + + function revealInExplorer(absPath) { + if (!nodeOk || !absPath) { return; } + try { + if (process.platform === 'win32') { + cp.execFile('explorer.exe', ['/select,', absPath]); + } else if (process.platform === 'darwin') { + cp.execFile('open', ['-R', absPath]); + } else { + cp.execFile('xdg-open', [path.dirname(absPath)]); + } + } catch (e) { log('reveal', e); } + } + + //========================================================================= + // Image decryption (RPGMaker MV .rpgmvp / MZ .png_) + encryption-aware reveal + //========================================================================= + var ENC = { + on: function () { + try { return typeof $dataSystem !== 'undefined' && $dataSystem && !!$dataSystem.hasEncryptedImages; } + catch (e) { return false; } + }, + keyBytes: function () { + try { return ($dataSystem.encryptionKey || '').match(/.{2}/g) || []; } + catch (e) { return []; } + }, + // Candidate on-disk encrypted siblings for a plain .png path. MV renames the + // extension (image.png -> image.rpgmvp); MZ keeps the name and appends "_" + // (image.png -> image.png_). The XOR algorithm is identical for both. + encPaths: function (absPng) { + return [absPng.replace(/\.png$/i, '.rpgmvp'), // MV + absPng + '_']; // MZ (image.png -> image.png_) + } + }; + + // Returns {path, created} for a real .png on disk, decrypting the encrypted + // sibling (.rpgmvp on MV, .png_ on MZ) if the plain .png does not exist. + // Replicates the engine Decrypter (16-byte fake header + XOR of the next 16 + // bytes with the encryption key). + function decryptToSibling(absPng) { + try { + if (fs.existsSync(absPng)) { return { path: absPng, created: false }; } + var cands = ENC.encPaths(absPng), enc = null; + for (var c = 0; c < cands.length; c++) { + if (fs.existsSync(cands[c])) { enc = cands[c]; break; } + } + if (!enc) { return null; } + var buf = fs.readFileSync(enc); + var body = buf.slice(16); // drop the fake PNG header + var key = ENC.keyBytes(); + for (var i = 0; i < 16 && i < key.length; i++) { + body[i] = body[i] ^ parseInt(key[i], 16); + } + fs.writeFileSync(absPng, body); + return { path: absPng, created: true }; + } catch (e) { log('decrypt', e); return null; } + } + + function revealImage(absPng) { + if (!nodeOk || !absPng) { return; } + var r = decryptToSibling(absPng); + if (!r) { toast('Not found on disk (.png / .rpgmvp / .png_)'); return; } + toast(r.created ? 'Decrypted -> revealing .png' : 'Revealing'); + revealInExplorer(r.path); + } + + //========================================================================= + // Thumbnails (from the already-decoded in-memory Bitmap, so encrypted + // images preview fine without touching disk) + a shared image-row builder. + //========================================================================= + var thumbCache = {}; // url -> dataURL + function bitmapThumb(bmp, url) { + if (url && thumbCache[url]) { return thumbCache[url]; } + try { + if (!bmp || (bmp.isReady && !bmp.isReady())) { return null; } + var src = (bmp._image && bmp._image.width) ? bmp._image + : (bmp.canvas || bmp._canvas || bmp.__canvas); + var sw = bmp.width, sh = bmp.height; + if (!src || !sw || !sh) { return null; } + var max = 60, scale = Math.min(max / sw, max / sh, 1); + var w = Math.max(1, Math.round(sw * scale)), h = Math.max(1, Math.round(sh * scale)); + var c = document.createElement('canvas'); + c.width = w; c.height = h; + c.getContext('2d').drawImage(src, 0, 0, sw, sh, 0, 0, w, h); + var data = c.toDataURL('image/png'); + if (url) { thumbCache[url] = data; } + return data; + } catch (e) { return null; } + } + + function buildImgRow(url, bitmap, opts) { + opts = opts || {}; + var abs = urlToAbsPath(url); + var row = document.createElement('div'); + row.className = 'tl-row'; + var thumb = bitmapThumb(bitmap, url); + row.innerHTML = + '' + + (thumb ? '' + : '?') + + '' + + '' + esc(url) + '' + + '' + + 'Reveal' + (ENC.on() ? ' (decrypt)' : '') + '' + + (opts.trigger ? 'trigger: ' + esc(opts.trigger.label) + '' : '') + + (opts.fromLabel ? 'from ' + esc(opts.fromLabel) + '' : '') + + '' + + '' + + ''; + row.querySelector('[data-act="reveal"]').addEventListener('click', function () { revealImage(abs); }); + if (opts.screen) { + row.addEventListener('mouseenter', function () { showHighlight(opts.screen); }); + row.addEventListener('mouseleave', function () { hideHighlight(); }); + } + if (opts.trigger && opts.trigger.file) { + var te = row.querySelector('[data-act="trig"]'); + te.style.cursor = 'pointer'; + te.addEventListener('click', function () { + var l = locateLine(opts.trigger.file, opts.trigger.path); + openInEditor(opts.trigger.file, l && l.line, l && l.col); + }); + } + return row; + } + + //========================================================================= + // Duplicate-line search: index every message/choice string across all data + // files so a translator can find identical lines and avoid mismatched edits. + //========================================================================= + var dupIndex = null; // [{file, path, text}] + + // Emit every message / choice string in an MZ command list, tagged with its JSON path. + function walkCommandList(list, prefix, emit) { + if (!Array.isArray(list)) { return; } + for (var i = 0; i < list.length; i++) { + var cmd = list[i]; + if (!cmd) { continue; } + if (cmd.code === 401 || cmd.code === 405) { + if (cmd.parameters && typeof cmd.parameters[0] === 'string') { + emit(prefix.concat([i, 'parameters', 0]), cmd.parameters[0]); + } + } else if (cmd.code === 102 && cmd.parameters && Array.isArray(cmd.parameters[0])) { + cmd.parameters[0].forEach(function (ch, n) { + if (typeof ch === 'string') { emit(prefix.concat([i, 'parameters', 0, n]), ch); } + }); + } + } + } + + function collectMessages(absFile, fname, obj, emit) { + if (/^Map\d+/.test(fname) && obj && obj.events) { + obj.events.forEach(function (ev, e) { + if (!ev || !ev.pages) { return; } + ev.pages.forEach(function (pg, p) { walkCommandList(pg.list, ['events', e, 'pages', p, 'list'], emit); }); + }); + } else if (fname === 'CommonEvents.json' && Array.isArray(obj)) { + obj.forEach(function (ce, c) { if (ce && ce.list) { walkCommandList(ce.list, [c, 'list'], emit); } }); + } else if (fname === 'Troops.json' && Array.isArray(obj)) { + obj.forEach(function (tr, t) { + if (tr && tr.pages) { tr.pages.forEach(function (pg, p) { walkCommandList(pg.list, [t, 'pages', p, 'list'], emit); }); } + }); + } + } + + // Scenario dictionary { "scene name": [ ...command list... ], ... } -> each value is + // a command list whose JSON path is [sceneName, index, 'parameters', 0]. + function collectScenarioMessages(dict, emit) { + if (!dict || typeof dict !== 'object') { return; } + Object.keys(dict).forEach(function (key) { + if (Array.isArray(dict[key])) { walkCommandList(dict[key], [key], emit); } + }); + } + + function buildDupIndex() { + if (dupIndex) { return dupIndex; } + dupIndex = []; + if (!nodeOk) { return dupIndex; } + try { + var files = fs.readdirSync(DATA_DIR).filter(function (f) { + return /^Map\d+\.json$/.test(f) || f === 'CommonEvents.json' || f === 'Troops.json'; + }); + files.forEach(function (fname) { + var abs = dataFile(fname); + var c = readFileCached(abs); + if (!c) { return; } + var obj; + try { obj = JSON.parse(c.text); } catch (e) { return; } + collectMessages(abs, fname, obj, function (pathArr, text) { + dupIndex.push({ file: abs, path: pathArr, text: text }); + }); + }); + // Scenario dictionaries: reuse the already-parsed global (Scenario.json can be + // tens of MB) and only fall back to parsing the file if the global is absent. + scenarioFiles().forEach(function (abs) { + var gname = scenarioGlobalForFile(abs); + var dict = gname ? window[gname] : null; + if (!dict) { + var sc = readFileCached(abs); + if (!sc) { return; } + try { dict = JSON.parse(sc.text); } catch (e) { return; } + } + collectScenarioMessages(dict, function (pathArr, text) { + dupIndex.push({ file: abs, path: pathArr, text: text }); + }); + }); + log('dup index built', dupIndex.length, 'messages'); + } catch (e) { log('dup index', e); } + return dupIndex; + } + + function normText(s, ignoreNl) { + return ignoreNl ? s.replace(/\n/g, ' ').replace(/\s+/g, ' ').trim() : s; + } + + function findOccurrences(text, ignoreNl) { + var idx = buildDupIndex(); + var key = normText(text, ignoreNl); + var out = []; + for (var i = 0; i < idx.length; i++) { + if (normText(idx[i].text, ignoreNl) === key) { out.push(idx[i]); } + } + return out; + } + + // Structural match: the running interpreter told us the event id + command index, + // so even if the list was a deep copy (reference match failed), we can find the + // ON-DISK command at that index whose text matches. With the event id this is + // almost always unique = confident, exact location. + function structuralCandidates(r) { + var out = []; + if (r.srcIndex == null) { return out; } + var idx = r.srcIndex, want = r.text; + function check(list, file, prefix) { + if (!Array.isArray(list) || idx < 0 || idx >= list.length) { return; } + var cmd = list[idx]; + if (!cmd || !cmd.parameters) { return; } + if ((cmd.code === 401 || cmd.code === 405) && cmd.parameters[0] === want) { + out.push({ file: file, path: prefix.concat([idx, 'parameters', 0]) }); + } else if (cmd.code === 102 && Array.isArray(cmd.parameters[0])) { + var n = cmd.parameters[0].indexOf(want); + if (n >= 0) { out.push({ file: file, path: prefix.concat([idx, 'parameters', 0, n]) }); } + } + } + try { + if (typeof $dataMap !== 'undefined' && $dataMap && $dataMap.events && + typeof $gameMap !== 'undefined' && $gameMap) { + var mf = mapFile($gameMap.mapId()); + if (r.srcEventId > 0 && $dataMap.events[r.srcEventId] && $dataMap.events[r.srcEventId].pages) { + $dataMap.events[r.srcEventId].pages.forEach(function (pg, p) { + check(pg.list, mf, ['events', r.srcEventId, 'pages', p, 'list']); + }); + } else { + $dataMap.events.forEach(function (ev, e) { + if (ev && ev.pages) { ev.pages.forEach(function (pg, p) { check(pg.list, mf, ['events', e, 'pages', p, 'list']); }); } + }); + } + } + if (!out.length && typeof $dataCommonEvents !== 'undefined' && $dataCommonEvents) { + $dataCommonEvents.forEach(function (ce, c) { if (ce && ce.list) { check(ce.list, dataFile('CommonEvents.json'), [c, 'list']); } }); + } + if (!out.length && typeof $dataTroops !== 'undefined' && $dataTroops && + typeof $gameTroop !== 'undefined' && $gameTroop && $gameTroop._troopId) { + var tr = $dataTroops[$gameTroop._troopId]; + if (tr && tr.pages) { tr.pages.forEach(function (pg, p) { check(pg.list, dataFile('Troops.json'), [$gameTroop._troopId, 'pages', p, 'list']); }); } + } + } catch (e) { log('structural', e); } + var uniq = [], seen = {}; + out.forEach(function (o) { var k = o.file + JSON.stringify(o.path); if (!seen[k]) { seen[k] = 1; uniq.push(o); } }); + return uniq; + } + + // Resolve an unresolved record: structural match (confident) first, then a global + // text-index search as a last resort. + function resolveRecord(r) { + if (r.file || r._tried || !nodeOk) { return; } + r._tried = true; + var cands = structuralCandidates(r); + if (cands.length === 1) { + r.file = cands[0].file; r.tail = cands[0].path; + r.label = '(located: event ' + (r.srcEventId || '?') + ')'; + return; + } + if (cands.length > 1) { r._candidates = cands; r._ambig = cands.length; return; } + var occ = findOccurrences(r.text, false); + if (occ.length === 0) { occ = findOccurrences(r.text, true); } // tolerate \n/wordwrap diffs + if (occ.length === 1) { + r.file = occ[0].file; r.tail = occ[0].path; r.label = '(located by text)'; + } else if (occ.length > 1) { + r._candidates = occ.map(function (o) { return { file: o.file, path: o.path }; }); + r._ambig = occ.length; + } + } + + //========================================================================= + // Literal search across data + plugin / system files (for UI text like + // "First kiss: None" that lives in plugins.js parameters, or event text that a + // plugin re-renders as UI — e.g. "Passed the preliminaries" inside a Map JSON). + //========================================================================= + var _scanFiles = null; + function pluginAndSystemFiles() { + if (_scanFiles) { return _scanFiles; } + _scanFiles = []; + if (!nodeOk) { return _scanFiles; } + try { + // Most reliable sources for UI labels first: database files (item/skill + // names + descriptions, terms), then the event data (Maps), then plugin + // parameters (plugins.js), then plugin code last (where a literal is most + // likely a false positive). + ['System', 'Items', 'Weapons', 'Armors', 'Skills', 'States', 'Actors', + 'Classes', 'Enemies', 'Troops', 'CommonEvents', 'MapInfos', 'Animations', 'Tilesets'] + .forEach(function (n) { _scanFiles.push(dataFile(n + '.json')); }); + // Map JSONs hold event message text that plugins may draw as UI (battle/ + // arena results, custom windows). Numeric-sorted so results read naturally. + try { + fs.readdirSync(DATA_DIR) + .filter(function (f) { return /^Map\d+\.json$/.test(f); }) + .sort(function (a, b) { + return parseInt(a.match(/\d+/)[0], 10) - parseInt(b.match(/\d+/)[0], 10); + }) + .forEach(function (f) { _scanFiles.push(dataFile(f)); }); + } catch (e) { /* ignore */ } + // Scenario dictionaries (plugin scenario systems) hold the bulk of dialogue in + // some games; without these "Locate in Files" can't find scenario-only text. + scenarioFiles().forEach(function (f) { _scanFiles.push(f); }); + var jsDir = path.join(WWW_ROOT, 'js'); + _scanFiles.push(path.join(jsDir, 'plugins.js')); + var pdir = path.join(jsDir, 'plugins'); + fs.readdirSync(pdir).forEach(function (f) { + if (/\.js$/.test(f) && f !== 'TLInspector.js') { _scanFiles.push(path.join(pdir, f)); } + }); + } catch (e) { log('scanFiles', e); } + return _scanFiles; + } + + function isWordChar(ch) { return !!ch && /[A-Za-z0-9_]/.test(ch); } + + // Build (and cache on the file entry) the character ranges of JS comments, so we + // can drop matches that live in comments (which never render). A small lexer that + // also tracks string literals so `//` inside a string isn't treated as a comment. + function commentRangesFor(c) { + if (c._comments) { return c._comments; } + var t = c.text, ranges = [], i = 0, n = t.length, state = 0, start = 0; + while (i < n) { + var ch = t[i], nx = t[i + 1]; + if (state === 0) { + if (ch === '/' && nx === '/') { state = 1; start = i; i += 2; continue; } + if (ch === '/' && nx === '*') { state = 2; start = i; i += 2; continue; } + if (ch === "'") { state = 3; } else if (ch === '"') { state = 4; } else if (ch === '`') { state = 5; } + i++; continue; + } + if (state === 1) { if (ch === '\n') { ranges.push([start, i]); state = 0; } i++; continue; } + if (state === 2) { if (ch === '*' && nx === '/') { ranges.push([start, i + 2]); state = 0; i += 2; continue; } i++; continue; } + if (ch === '\\') { i += 2; continue; } // escape inside a string + if ((state === 3 && ch === "'") || (state === 4 && ch === '"') || (state === 5 && ch === '`')) { state = 0; } + i++; + } + if (state === 1 || state === 2) { ranges.push([start, n]); } + c._comments = ranges; + return ranges; + } + function inComment(c, pos) { + var r = commentRangesFor(c), lo = 0, hi = r.length - 1; + while (lo <= hi) { + var mid = (lo + hi) >> 1; + if (pos < r[mid][0]) { hi = mid - 1; } + else if (pos >= r[mid][1]) { lo = mid + 1; } + else { return true; } + } + return false; + } + + function searchFiles(text) { + var results = [], seen = {}; + if (!nodeOk || !text) { return results; } + var escaped = JSON.stringify(text).slice(1, -1); // JSON-escaped form (\n etc.) + var variants = escaped === text ? [text] : [text, escaped]; // raw form + escaped, deduped + // As the text appears inside a single-quoted JS literal ('Let\'s go home'). + var jsq = escaped.replace(/\\"/g, '"').replace(/'/g, "\\'"); + if (variants.indexOf(jsq) < 0) { variants.push(jsq); } + pluginAndSystemFiles().forEach(function (file) { + var c = readFileCached(file); + if (!c) { return; } + var isJs = /\.js$/i.test(file); + variants.forEach(function (v) { + if (!v) { return; } + var checkL = isWordChar(v[0]), checkR = isWordChar(v[v.length - 1]); + var pos = c.text.indexOf(v); + while (pos >= 0) { + // Skip matches embedded inside a larger word/identifier, e.g. "Tools" + // inside "isDevToolsOpen", and matches inside JS comments (never render). + var embedded = (checkL && isWordChar(c.text[pos - 1])) || + (checkR && isWordChar(c.text[pos + v.length])); + if (!embedded && !(isJs && inComment(c, pos))) { + var lc = offsetToLineCol(c, pos); + var k = file + ':' + lc.line; + // A complete string value ("text" in JSON; '…' / "…" / `…` in + // JS) is a high-confidence match vs. text buried in a longer one. + var qb = c.text[pos - 1], qa = c.text[pos + v.length]; + var quoted = (qb === '"' && qa === '"') || + (isJs && qb === qa && (qb === "'" || qb === '`')); + if (!seen[k]) { seen[k] = 1; results.push({ file: file, line: lc.line, col: lc.col, quoted: quoted }); } + } + pos = c.text.indexOf(v, pos + v.length); + } + }); + }); + // Stable sort: exact quoted-value matches first, original (data-first) order otherwise. + results.forEach(function (r, i) { r._i = i; }); + results.sort(function (a, b) { return (b.quoted - a.quoted) || (a._i - b._i); }); + return results; + } + + // Exact literal first; if nothing, trim trailing words (handles "Label: " + // where the value isn't in the file) until something matches. + function searchFilesSmart(text) { + var r = searchFiles(text); + if (r.length) { return { results: r, query: text, partial: false }; } + // Numbers may be runtime-substituted into a %1/%2 template: "2 turn(s) left" + // never exists on disk while '%1 turn(s) left' does. + var n = 0; + var tpl = text.replace(/\d+(?:\.\d+)?/g, function () { return '%' + (++n); }); + if (n > 0 && tpl !== text) { + var rt = searchFiles(tpl); + if (rt.length) { return { results: rt, query: tpl, partial: true }; } + } + var words = text.replace(/\n/g, ' ').split(/\s+/).filter(Boolean); + for (var n = words.length - 1; n >= 1; n--) { + var sub = words.slice(0, n).join(' '); + if (sub.length < 3) { break; } + var rr = searchFiles(sub); + if (rr.length) { return { results: rr, query: sub, partial: true }; } + } + return { results: [], query: text, partial: false }; + } + + //========================================================================= + // Built-in editor (in-game): a small multi-tab code editor that views & edits + // the source files directly, jumping to the same line click-to-source would. + // Routed to from openInEditor() when CFG.editor / the header switch selects it, + // when VSCode isn't installed, or as the fallback when a VSCode launch fails. + // "Open all" stacks every result as a tab. Includes a find/replace widget with + // regex, match-case and whole-word, next/prev, and replace / replace-all. + //========================================================================= + var EDLH = 18; // editor line-height in px (kept in sync with the CSS below) + var editor = { + root: null, area: null, gutter: null, tabsEl: null, findEl: null, + fq: null, frin: null, fcount: null, statusEl: null, + docs: [], active: -1, _lines: -1, + find: { open: false, q: '', r: '', re: false, cs: false, ww: false, + matches: [], idx: -1, invalid: false } + }; + + function baseName(f) { return f ? String(f).replace(/^.*[\\\/]/, '') : ''; } + function activeDoc() { return editor.active >= 0 ? editor.docs[editor.active] : null; } + + // After a save, drop the cached text + located line numbers for the file so the + // panel (and the JSON locator) recompute against the new content. + function invalidateFile(file) { + delete fileCache[file]; + var pre = file + '::'; + for (var k in lineCache) { + if (lineCache.hasOwnProperty(k) && k.indexOf(pre) === 0) { delete lineCache[k]; } + } + dupIndex = null; // message text may have changed + } + + function buildEditor() { + if (editor.root) { return; } + var root = document.createElement('div'); + root.id = 'tl-editor'; + root.style.cssText = [ + 'position:fixed', 'top:3%', 'left:50%', 'transform:translateX(-50%)', + 'width:80%', 'max-width:1100px', 'height:92%', 'z-index:2147483646', + 'background:#15171d', 'color:#e6e6e6', 'border:1px solid #344', + 'border-radius:8px', 'box-shadow:0 8px 40px rgba(0,0,0,0.7)', + 'display:none', 'flex-direction:column', 'font:12px Consolas,Menlo,monospace' + ].join(';'); + + var head = document.createElement('div'); + head.style.cssText = 'padding:8px 12px;background:#11131a;border-bottom:1px solid #333;display:flex;align-items:center;gap:10px;flex:0 0 auto;border-radius:8px 8px 0 0'; + head.innerHTML = + 'Edit' + + '' + + 'Find' + + 'Save' + + '✕'; + root.appendChild(head); + + // tab strip (one tab per open file) + var tabs = document.createElement('div'); + tabs.className = 'tl-ed-tabs'; + root.appendChild(tabs); + + // find / replace widget (hidden until opened) + var find = document.createElement('div'); + find.className = 'tl-ed-find'; + find.style.display = 'none'; + find.innerHTML = + '' + + '' + + 'Aa' + + 'W' + + '.*' + + '' + + '↑' + + '↓' + + '✕' + + '' + + '' + + '' + + 'Replace' + + 'Replace All' + + ''; + root.appendChild(find); + + var main = document.createElement('div'); + main.style.cssText = 'flex:1 1 auto;display:flex;overflow:hidden;background:#1b1e26'; + + var gutter = document.createElement('div'); + gutter.className = 'tl-ed-gutter'; + gutter.style.cssText = 'flex:0 0 auto;min-width:42px;overflow:hidden;text-align:right;' + + 'padding:8px 6px 8px 10px;color:#566;background:#161922;white-space:pre;' + + 'user-select:none;-webkit-user-select:none;font:12px/18px Consolas,Menlo,monospace'; + + var area = document.createElement('textarea'); + area.className = 'tl-ed-area'; + area.setAttribute('wrap', 'off'); // one logical line == one visual row + area.setAttribute('spellcheck', 'false'); + area.style.cssText = 'flex:1 1 auto;resize:none;border:0;outline:0;padding:8px 10px;' + + 'color:#e6e6e6;background:#1b1e26;white-space:pre;overflow:auto;' + + 'font:12px/18px Consolas,Menlo,monospace;tab-size:4;-moz-tab-size:4'; + + main.appendChild(gutter); + main.appendChild(area); + root.appendChild(main); + + var foot = document.createElement('div'); + foot.style.cssText = 'padding:5px 12px;background:#11131a;border-top:1px solid #333;color:#8aa;flex:0 0 auto;display:flex;gap:14px;border-radius:0 0 8px 8px'; + foot.innerHTML = 'Ctrl+S save · Ctrl+F find · Ctrl+H replace · Esc close · Tab indent' + + ''; + root.appendChild(foot); + + var st = document.createElement('style'); + st.textContent = + '#tl-editor .tl-ed-btn{cursor:pointer;padding:3px 9px;border-radius:4px;background:#333;color:#ddd}' + + '#tl-editor .tl-ed-btn:hover{filter:brightness(1.35)}' + + '#tl-editor .tl-ed-tabs{display:flex;overflow-x:auto;background:#0e1016;border-bottom:1px solid #333;flex:0 0 auto}' + + '#tl-editor .tl-ed-tab{display:flex;align-items:center;gap:6px;padding:5px 8px;border-right:1px solid #222;color:#9ab;cursor:pointer;white-space:nowrap;max-width:220px;flex:0 0 auto}' + + '#tl-editor .tl-ed-tab.on{background:#1b1e26;color:#fff}' + + '#tl-editor .tl-ed-tab .nm{overflow:hidden;text-overflow:ellipsis}' + + '#tl-editor .tl-ed-tab .dot{color:#fd6}' + + '#tl-editor .tl-ed-tab .x{color:#889;border-radius:3px;padding:0 4px}' + + '#tl-editor .tl-ed-tab .x:hover{background:#555;color:#fff}' + + '#tl-editor .tl-ed-find{background:#12141b;border-bottom:1px solid #333;padding:5px 8px;flex:0 0 auto}' + + '#tl-editor .tl-fr{display:flex;align-items:center;gap:6px;margin:2px 0}' + + '#tl-editor .tl-fq,#tl-editor .tl-fr-in{flex:0 0 240px;width:240px;min-width:0;background:#1b1e26;border:1px solid #344;color:#eee;padding:3px 6px;font:12px Consolas,Menlo,monospace;outline:none}' + + '#tl-editor .tl-fopt{cursor:pointer;padding:2px 6px;border-radius:3px;background:#222;color:#9ab;font:11px monospace}' + + '#tl-editor .tl-fopt.on{background:#2a5db0;color:#fff}' + + '#tl-editor .tl-fcount{color:#9ab;min-width:62px;text-align:center;font-size:11px}' + + '#tl-editor .tl-fcount.err{color:#f88}' + + '#tl-editor .tl-fbtn{cursor:pointer;padding:2px 8px;border-radius:3px;background:#333;color:#ddd;white-space:nowrap}' + + '#tl-editor .tl-fbtn:hover{filter:brightness(1.3)}'; + root.appendChild(st); + + head.addEventListener('click', function (e) { + var a = e.target.getAttribute('data-act'); + if (a === 'save') { saveEditor(); } + else if (a === 'close') { closeEditor(); } + else if (a === 'find') { openFind(false); } + }); + + // tab strip: click selects, click the x closes + tabs.addEventListener('click', function (e) { + var t = e.target; + while (t && t !== tabs && !t.hasAttribute('data-ti')) { t = t.parentNode; } + if (!t || t === tabs) { return; } + var i = parseInt(t.getAttribute('data-ti'), 10); + if (e.target.classList.contains('x')) { closeTab(i); } else { selectTab(i); } + }); + + // find widget wiring + editor.fq = find.querySelector('.tl-fq'); + editor.frin = find.querySelector('.tl-fr-in'); + editor.fcount = find.querySelector('.tl-fcount'); + editor.fq.addEventListener('input', function () { + editor.find.q = this.value; recomputeMatches(); + showMatch(editor.find.idx < 0 ? 0 : editor.find.idx); + }); + editor.fq.addEventListener('keydown', function (e) { + if (e.key === 'Enter') { e.preventDefault(); showMatch(editor.find.idx + (e.shiftKey ? -1 : 1)); } + else if (e.key === 'Escape') { e.preventDefault(); closeFind(); } + }); + editor.frin.addEventListener('input', function () { editor.find.r = this.value; }); + editor.frin.addEventListener('keydown', function (e) { + if (e.key === 'Enter') { e.preventDefault(); replaceCurrent(); } + else if (e.key === 'Escape') { e.preventDefault(); closeFind(); } + }); + find.addEventListener('click', function (e) { + var opt = e.target.getAttribute('data-opt'); + var fa = e.target.getAttribute('data-fa'); + if (opt) { + var f = editor.find; f[opt] = !f[opt]; + e.target.classList.toggle('on', f[opt]); + recomputeMatches(); showMatch(f.idx < 0 ? 0 : f.idx); + } else if (fa === 'next') { showMatch(editor.find.idx + 1); } + else if (fa === 'prev') { showMatch(editor.find.idx - 1); } + else if (fa === 'close') { closeFind(); } + else if (fa === 'rep') { replaceCurrent(); } + else if (fa === 'repall') { replaceAll(); } + }); + + area.addEventListener('input', function () { + markDirty(); refreshGutter(); + if (editor.find.open) { recomputeMatches(); updateFindCount(); } + }); + area.addEventListener('scroll', syncGutter); + area.addEventListener('keydown', onEditorKey, false); + + // Keep the game from reacting to clicks/keys aimed at the editor (mirrors the + // inspector panel's isolation). With "freeze" off this is what protects typing. + ['mousedown', 'mouseup', 'click', 'dblclick', 'wheel', 'contextmenu', + 'touchstart', 'touchend', 'touchmove', 'pointerdown', 'pointerup', + 'keydown', 'keyup', 'keypress'].forEach(function (t) { + root.addEventListener(t, function (ev) { ev.stopPropagation(); }, false); + }); + + document.body.appendChild(root); + editor.root = root; + editor.area = area; + editor.gutter = gutter; + editor.tabsEl = tabs; + editor.findEl = find; + editor.statusEl = foot.querySelector('.tl-ed-status'); + applyOverlayScale(); + } + + //--- documents / tabs ---------------------------------------------------- + function docIndexByFile(file) { + for (var i = 0; i < editor.docs.length; i++) { if (editor.docs[i].file === file) { return i; } } + return -1; + } + + // Files above this size are NOT loaded whole into the : a 68MB scenario + // file would push ~3M lines into the DOM and build a gutter string with millions of + // numbers, freezing then crashing the game. Instead we load a WINDOW of lines around + // the target and splice edits back into the full text on save (see saveEditor). + var BIG_FILE_BYTES = 3 * 1024 * 1024; + var WINDOW_BEFORE = 300, WINDOW_AFTER = 300; + + // Slice a window of [WINDOW_BEFORE+WINDOW_AFTER] lines centred on targetLine out of the + // full text; fills winStart/winEnd/baseLine/text on the doc. + function windowDoc(doc, targetLine) { + var full = doc.fullText, tgt = (targetLine && targetLine > 0) ? targetLine : 1; + var startLine = Math.max(1, tgt - WINDOW_BEFORE); + var winStart = lineStartOffset(full, startLine); + var winEnd = winStart, n = 0, cap = WINDOW_BEFORE + WINDOW_AFTER; + while (n < cap) { var p = full.indexOf('\n', winEnd); if (p < 0) { winEnd = full.length; break; } winEnd = p + 1; n++; } + doc.baseLine = startLine; doc.winStart = winStart; doc.winEnd = winEnd; + doc.text = full.slice(winStart, winEnd); + } + function winLineCount(d) { + var c = 1, t = d.text; for (var i = 0; i < t.length; i++) { if (t.charCodeAt(i) === 10) { c++; } } + return c; + } + function lineInWindow(d, line) { + return d.windowed && line >= d.baseLine && line <= d.baseLine + winLineCount(d) - 1; + } + + function createDoc(file, targetLine) { + var raw; + try { raw = fs.readFileSync(file, 'utf8'); } + catch (e) { toast('Could not read file'); log('read', e); return null; } + var bom = raw.charCodeAt(0) === 0xFEFF; + if (bom) { raw = raw.slice(1); } + var nl = /\r\n/.test(raw) ? '\r\n' : '\n'; // preserve the file's line endings + var full = raw.replace(/\r\n/g, '\n'); + var doc = { file: file, name: baseName(file), nl: nl, bom: bom, dirty: false, + line: 0, scrollTop: 0, selStart: 0, selEnd: 0, windowed: false, baseLine: 1 }; + if (full.length > BIG_FILE_BYTES) { + doc.windowed = true; + doc.fullText = full; + windowDoc(doc, targetLine); + } else { + doc.text = full; + } + return doc; + } + + function stashActive() { + var d = activeDoc(); if (!d) { return; } + d.text = editor.area.value; + d.scrollTop = editor.area.scrollTop; + d.selStart = editor.area.selectionStart; + d.selEnd = editor.area.selectionEnd; + } + + function loadActive() { + var d = activeDoc(); + editor._lines = -1; + if (!d) { editor.area.value = ''; refreshGutter(); updateEditorTitle(); return; } + editor.area.value = d.text; + refreshGutter(); + editor.area.scrollTop = d.scrollTop || 0; + try { editor.area.setSelectionRange(d.selStart || 0, d.selEnd || 0); } catch (e) { /* ignore */ } + syncGutter(); + updateEditorTitle(); + if (editor.find.open) { recomputeMatches(); updateFindCount(); } + } + + function selectTab(i, line) { + if (i < 0 || i >= editor.docs.length) { return; } + if (i !== editor.active) { stashActive(); editor.active = i; loadActive(); } + renderTabs(); + if (line) { jumpToLine(line); } + editor.area.focus(); + } + + function closeTab(i) { + var d = editor.docs[i]; if (!d) { return; } + if (d.dirty && !window.confirm('Discard unsaved changes to ' + d.name + '?')) { return; } + if (i === editor.active) { + editor.docs.splice(i, 1); + if (!editor.docs.length) { editor.active = -1; renderTabs(); editor.root.style.display = 'none'; return; } + editor.active = Math.min(i, editor.docs.length - 1); + loadActive(); + } else { + if (i < editor.active) { editor.active--; } + editor.docs.splice(i, 1); + } + renderTabs(); + } + + function renderTabs() { + var el = editor.tabsEl; if (!el) { return; } + el.innerHTML = ''; + editor.docs.forEach(function (d, i) { + var t = document.createElement('div'); + t.className = 'tl-ed-tab' + (i === editor.active ? ' on' : ''); + t.setAttribute('data-ti', i); + t.title = d.file; + t.innerHTML = (d.dirty ? '●' : '') + + '' + esc(d.name) + '' + + '✕'; + el.appendChild(t); + }); + } + + function markDirty() { + var d = activeDoc(); if (!d) { return; } + if (!d.dirty) { d.dirty = true; renderTabs(); } + updateEditorTitle(); + } + + //--- view helpers -------------------------------------------------------- + function insertAtCursor(area, str) { + var s = area.selectionStart, e = area.selectionEnd, v = area.value; + area.value = v.slice(0, s) + str + v.slice(e); + area.selectionStart = area.selectionEnd = s + str.length; + } + + function onEditorKey(e) { + if ((e.ctrlKey || e.metaKey) && (e.key === 's' || e.key === 'S')) { e.preventDefault(); saveEditor(); return; } + if ((e.ctrlKey || e.metaKey) && (e.key === 'f' || e.key === 'F')) { e.preventDefault(); openFind(false); return; } + if ((e.ctrlKey || e.metaKey) && (e.key === 'h' || e.key === 'H')) { e.preventDefault(); openFind(true); return; } + if (e.key === 'Escape') { e.preventDefault(); if (editor.find.open) { closeFind(); } else { closeEditor(); } return; } + if (e.key === 'Tab') { e.preventDefault(); insertAtCursor(editor.area, '\t'); markDirty(); } + } + + function syncGutter() { + if (editor.gutter && editor.area) { editor.gutter.scrollTop = editor.area.scrollTop; } + } + + function refreshGutter() { + var v = editor.area.value, count = 1; + for (var i = 0; i < v.length; i++) { if (v.charCodeAt(i) === 10) { count++; } } + var d = activeDoc(), base = (d && d.windowed) ? d.baseLine : 1; + if (count === editor._lines && base === editor._gutterBase) { return; } + editor._lines = count; editor._gutterBase = base; + var s = ''; + for (var k = 0; k < count; k++) { s += (base + k) + '\n'; } + editor.gutter.textContent = s; + syncGutter(); + } + + function updateEditorTitle(line) { + var d = activeDoc(); + if (!d) { setEditorStatus(''); return; } + if (line != null) { d.line = line; } + setEditorStatus(d.name + (d.line ? ':' + d.line : '') + (d.dirty ? ' (unsaved)' : '')); + } + + function setEditorStatus(msg) { + if (editor.statusEl) { editor.statusEl.textContent = msg || ''; } + } + + function lineStartOffset(text, line) { + var off = 0, cur = 1; + while (cur < line) { + var nl = text.indexOf('\n', off); + if (nl < 0) { break; } + off = nl + 1; cur++; + } + return off; + } + + // Actual rendered line height of the textarea. Under a CSS zoom the browser + // rounds every rendered line box to whole device pixels, so the nominal 18px is + // off by up to ~1% — across a 70k-line file that puts the viewport hundreds of + // lines away from the (correctly placed) cursor. Measure instead of trusting EDLH. + function editorLineHeight() { + var area = editor.area; + if (!area) { return EDLH; } + var v = area.value, lines = 1; + for (var i = 0; i < v.length; i++) { if (v.charCodeAt(i) === 10) { lines++; } } + var h = (area.scrollHeight - 16) / lines; // 16 = 8px top + bottom padding (CSS above) + return (h > EDLH / 2 && h < EDLH * 2) ? h : EDLH; + } + + function jumpToLine(line) { + var d = activeDoc(); + // In windowed mode `line` is a FILE line; translate to the textarea's local line. + var local = (d && d.windowed) ? (line - d.baseLine + 1) : line; + if (local < 1) { local = 1; } + var area = editor.area, text = area.value; + var so = lineStartOffset(text, local); + var eo = text.indexOf('\n', so); if (eo < 0) { eo = text.length; } + try { area.setSelectionRange(so, eo); } catch (e) { /* ignore */ } + area.scrollTop = Math.max(0, (local - 4) * editorLineHeight()); + syncGutter(); + updateEditorTitle(line); // status shows the real FILE line + } + + // Entry point from openInEditor(): open (or focus) a tab for `file` and jump to line. + function openBuiltInEditor(file, line, col) { + if (!nodeOk || !file) { toast('No file to open'); return; } + buildEditor(); + editor.root.style.display = 'flex'; + var i = docIndexByFile(file); + if (i < 0) { + var d = createDoc(file, line); if (!d) { return; } + stashActive(); + editor.docs.push(d); + i = editor.docs.length - 1; + editor.active = i; + loadActive(); + renderTabs(); + jumpToLine(line || 1); + editor.area.focus(); + if (d.windowed) { + toast('Large file — showing lines ' + d.baseLine + '–' + + (d.baseLine + winLineCount(d) - 1) + ' of ' + d.name + ' (partial view)'); + } + } else { + var d2 = editor.docs[i]; + // Re-open of a windowed file whose target is outside the loaded window: recut + // the window around the new line (unless there are unsaved edits to preserve). + if (d2.windowed && line && !lineInWindow(d2, line) && !d2.dirty) { + stashActive(); editor.active = i; + windowDoc(d2, line); + loadActive(); renderTabs(); jumpToLine(line); editor.area.focus(); + } else { + selectTab(i, line || 1); + } + } + } + + function saveEditor() { + var d = activeDoc(); if (!d) { return; } + d.text = editor.area.value; + // Windowed docs hold only a slice in the textarea: splice it back into the full + // text (and re-anchor the window to the edited slice's new extent) before writing. + var full; + if (d.windowed) { + full = d.fullText.slice(0, d.winStart) + d.text + d.fullText.slice(d.winEnd); + d.fullText = full; + d.winEnd = d.winStart + d.text.length; + } else { + full = d.text; + } + var out = (d.nl === '\r\n') ? full.replace(/\n/g, '\r\n') : full; + if (d.bom) { out = String.fromCharCode(0xFEFF) + out; } + try { + fs.writeFileSync(d.file, out, 'utf8'); + d.dirty = false; + renderTabs(); updateEditorTitle(); + invalidateFile(d.file); + // Push the just-saved edit straight onto the live game: reload data files, + // re-fetch on-screen images and redraw the scene so the change is visible + // immediately without leaving the editor or restarting. + refreshGameElements(); + toast('Saved ' + d.name + (d.windowed ? ' (partial view)' : '') + ' — reloaded in-game'); + } catch (e) { setEditorStatus('save failed'); toast('Save failed: ' + e.message); log('save', e); } + } + + // Closes the editor window but KEEPS the open tabs in memory (like minimizing), + // so unsaved edits aren't lost; reopening any result shows them again. + function closeEditor() { + if (!editor.root) { return; } + editor.root.style.display = 'none'; + } + + //--- find / replace ------------------------------------------------------ + function openFind(replaceFocus) { + buildEditor(); + var f = editor.find; f.open = true; + editor.findEl.style.display = 'block'; + // seed the query from a short single-line selection (VSCode behaviour) + var sel = editor.area.value.slice(editor.area.selectionStart, editor.area.selectionEnd); + if (sel && sel.indexOf('\n') < 0 && sel.length <= 200) { f.q = sel; editor.fq.value = sel; } + recomputeMatches(); + var inp = replaceFocus ? editor.frin : editor.fq; + inp.focus(); inp.select(); + showMatch(f.idx < 0 ? 0 : f.idx); + } + + function closeFind() { + editor.find.open = false; + if (editor.findEl) { editor.findEl.style.display = 'none'; } + editor.area.focus(); + } + + function buildFindRegex(global) { + var f = editor.find; + if (!f.q) { return null; } + var src = f.re ? f.q : f.q.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + if (f.ww) { src = '\\b' + src + '\\b'; } + try { return new RegExp(src, (global ? 'g' : '') + (f.cs ? '' : 'i') + 'm'); } + catch (e) { return null; } + } + + function recomputeMatches(caret) { + var f = editor.find, text = editor.area.value; + f.matches = []; f.invalid = false; + if (!f.q) { f.idx = -1; updateFindCount(); return; } + var re = buildFindRegex(true); + if (!re) { f.invalid = !!f.re; f.idx = -1; updateFindCount(); return; } + var m, guard = 0; + while ((m = re.exec(text)) !== null) { + f.matches.push({ start: m.index, end: m.index + m[0].length }); + if (m[0].length === 0) { re.lastIndex++; } // never loop on empty match + if (++guard > 200000) { break; } + } + var c = (caret == null) ? (editor.area.selectionStart || 0) : caret; + f.idx = -1; + for (var i = 0; i < f.matches.length; i++) { if (f.matches[i].start >= c) { f.idx = i; break; } } + if (f.idx === -1 && f.matches.length) { f.idx = 0; } + updateFindCount(); + } + + // Select + scroll to match i (wraps). Does NOT move focus, so the user keeps + // typing in the find box while matches highlight live in the textarea. + function showMatch(i) { + var f = editor.find; + if (!f.matches.length) { updateFindCount(); return; } + f.idx = ((i % f.matches.length) + f.matches.length) % f.matches.length; + var mt = f.matches[f.idx], area = editor.area; + try { area.setSelectionRange(mt.start, mt.end); } catch (e) { /* ignore */ } + var line = area.value.slice(0, mt.start).split('\n').length; + area.scrollTop = Math.max(0, (line - 4) * editorLineHeight()); + syncGutter(); updateFindCount(); + } + + function updateFindCount() { + var f = editor.find, el = editor.fcount; + if (!el) { return; } + if (f.invalid) { el.textContent = 'bad regex'; el.className = 'tl-fcount err'; return; } + el.className = 'tl-fcount'; + if (!f.q) { el.textContent = ''; } + else if (!f.matches.length) { el.textContent = 'No results'; } + else { el.textContent = (f.idx + 1) + ' of ' + f.matches.length; } + } + + function computeReplacement(matched) { + var f = editor.find; + if (!f.re) { return f.r; } // literal: insert as-is + var re = buildFindRegex(false); + try { return matched.replace(re, f.r); } // regex: honour $1, $& etc. + catch (e) { return matched; } + } + + function replaceCurrent() { + var f = editor.find; + if (!f.matches.length) { return; } + if (f.idx < 0) { f.idx = 0; } + var mt = f.matches[f.idx], area = editor.area, val = area.value; + var rep = computeReplacement(val.slice(mt.start, mt.end)); + area.value = val.slice(0, mt.start) + rep + val.slice(mt.end); + markDirty(); refreshGutter(); + recomputeMatches(mt.start + rep.length); // positions shifted; reanchor + showMatch(f.idx); + } + + function replaceAll() { + var f = editor.find, area = editor.area; + var reg = buildFindRegex(true); + if (!reg) { return; } + var arr = area.value.match(reg); + var count = arr ? arr.length : 0; + if (!count) { toast('No matches'); return; } + // literal mode: function replacer so $ in the replacement stays literal. + area.value = f.re ? area.value.replace(reg, f.r) + : area.value.replace(reg, function () { return f.r; }); + markDirty(); refreshGutter(); + recomputeMatches(); showMatch(0); + toast('Replaced ' + count + ' occurrence' + (count === 1 ? '' : 's')); + } + + //========================================================================= + // Live refresh: reload the data files + images a translator just edited and + // redraw the current scene, so saved changes show up in-game without a restart. + // Bound to the panel's "Reload" button. + //========================================================================= + var DATA_GLOBALS = { + 'System': '$dataSystem', 'Actors': '$dataActors', 'Classes': '$dataClasses', + 'Skills': '$dataSkills', 'Items': '$dataItems', 'Weapons': '$dataWeapons', + 'Armors': '$dataArmors', 'Enemies': '$dataEnemies', 'Troops': '$dataTroops', + 'States': '$dataStates', 'Animations': '$dataAnimations', 'Tilesets': '$dataTilesets', + 'CommonEvents': '$dataCommonEvents', 'MapInfos': '$dataMapInfos' + }; + + // Run the engine's post-load step on a freshly parsed data object. This is what + // rebuilds each entry's `.meta`/notetag fields (via DataManager.extractMetadata) + // AND re-fires any plugin that aliased DataManager.onLoad to process notetags. + // Skipping it is what crashed plugins like character-lighting (event.meta was + // undefined -> "Cannot read property 'CharLight' of undefined"). + function runOnLoad(obj) { + try { + if (typeof DataManager !== 'undefined' && typeof DataManager.onLoad === 'function') { + DataManager.onLoad(obj); + } + } catch (e) { /* a plugin's onLoad hook may itself throw; don't abort the reload */ } + } + + // Reload scenario dictionaries only when the file actually changed on disk. These can + // be tens of MB, so re-parsing on every reload (when nothing scenario-side changed) + // would stall F9. On first sight we adopt the current mtime WITHOUT re-parsing an + // already-loaded global, so an unchanged scenario never costs a big parse. + var _scenarioMtime = {}; + function scenarioMtime(file) { + try { var st = fs.statSync(file); return st.mtimeMs || (st.mtime && st.mtime.getTime()) || 0; } + catch (e) { return -1; } + } + function reloadScenarioData() { + var n = 0; + SCENARIO_SETS.forEach(function (sg) { + if (typeof window[sg.global] === 'undefined') { return; } // game doesn't use it + var file = scenarioPath(sg.file), m = scenarioMtime(file); + if (m < 0) { return; } + var known = _scenarioMtime.hasOwnProperty(file); + if (!known) { _scenarioMtime[file] = m; if (window[sg.global]) { return; } } + if (known && _scenarioMtime[file] === m && window[sg.global]) { return; } // unchanged + try { window[sg.global] = JSON.parse(fs.readFileSync(file, 'utf8')); _scenarioMtime[file] = m; n++; } + catch (e) { /* mid-write or gone; keep the in-memory copy */ } + }); + return n; + } + + function reloadDataFiles() { + var n = 0; + for (var name in DATA_GLOBALS) { + if (!DATA_GLOBALS.hasOwnProperty(name)) { continue; } + var gname = DATA_GLOBALS[name]; + if (typeof window[gname] === 'undefined') { continue; } + try { + window[gname] = JSON.parse(fs.readFileSync(dataFile(name + '.json'), 'utf8')); + runOnLoad(window[gname]); + n++; + } catch (e) { /* file may be absent for this game; skip */ } + } + n += reloadScenarioData(); + try { + if (typeof $gameMap !== 'undefined' && $gameMap && $gameMap.mapId()) { + // $dataMap must be assigned BEFORE onLoad: it keys off (object === $dataMap) + // to know it should extract event metadata. + window.$dataMap = JSON.parse(fs.readFileSync(mapFile($gameMap.mapId()), 'utf8')); + runOnLoad(window.$dataMap); + n++; + } + } catch (e) { /* ignore */ } + return n; + } + + // Redraw every window in the current scene (item names, descriptions, terms, + // status text, etc. are re-read from the freshly reloaded data). + function refreshSceneWindows() { + var scene = (typeof SceneManager !== 'undefined') && SceneManager._scene; + if (!scene || typeof Window_Base === 'undefined') { return 0; } + var n = 0; + (function walk(obj) { + if (!obj) { return; } + if (obj instanceof Window_Base && typeof obj.refresh === 'function') { + try { obj.refresh(); n++; } catch (e) { /* some windows refresh only with state */ } + } + var kids = obj.children; + if (kids) { for (var i = 0; i < kids.length; i++) { walk(kids[i]); } } + })(scene); + return n; + } + + function clearImageCaches() { + try { + if (typeof ImageManager !== 'undefined') { + if (typeof ImageManager.clear === 'function') { ImageManager.clear(); } + if (ImageManager._cache) { ImageManager._cache = {}; } + if (ImageManager._system) { ImageManager._system = {}; } + if (typeof ImageCache !== 'undefined' && ImageManager._imageCache) { ImageManager._imageCache = new ImageCache(); } + } + } catch (e) { /* ignore */ } + thumbCache = {}; + } + + // Force on-screen sprites to re-fetch their bitmap from disk. Routing through + // ImageManager.loadBitmap (cache already cleared) keeps decryption working. + function reloadOnScreenImages() { + var scene = (typeof SceneManager !== 'undefined') && SceneManager._scene; + if (!scene || typeof ImageManager === 'undefined') { return 0; } + var n = 0; + (function walk(obj) { + if (!obj) { return; } + var bmp = obj.bitmap; + if (bmp && bmp._url) { + var url = decodeUrl(bmp._url); + var slash = url.lastIndexOf('/'); + var folder = url.slice(0, slash + 1); + var fname = url.slice(slash + 1).replace(/\.png$/i, ''); + try { obj.bitmap = ImageManager.loadBitmap(folder, fname); n++; } + catch (e) { /* ignore */ } + } + var kids = obj.children; + if (kids) { for (var i = 0; i < kids.length; i++) { walk(kids[i]); } } + })(scene); + return n; + } + + function refreshGameElements() { + if (!nodeOk) { toast('Reload needs Node (NW.js)'); return; } + // Drop our own caches so the panel relocates against the new file contents. + fileCache = {}; lineCache = {}; dupIndex = null; _scanFiles = null; + uiValueIndex = null; tmAssignCache = {}; jsLitIndex = null; // notetags / vocab / plugin edits + + var parts = []; + var d = reloadDataFiles(); if (d) { parts.push(d + ' data file' + (d === 1 ? '' : 's')); } + clearImageCaches(); + var im = reloadOnScreenImages(); if (im) { parts.push(im + ' image' + (im === 1 ? '' : 's')); } + var w = refreshSceneWindows(); if (w) { parts.push(w + ' window' + (w === 1 ? '' : 's')); } + + // Nudge the map to rebuild event sprites/state if we're on it. + try { if (typeof $gameMap !== 'undefined' && $gameMap && $gameMap.requestRefresh) { $gameMap.requestRefresh(); } } catch (e) { /* ignore */ } + + render(); // refresh our own panel too + toast(parts.length ? ('Reloaded ' + parts.join(', ')) : 'Nothing on screen to reload'); + } + + //========================================================================= + // Overlay UI + //========================================================================= + var ui = { root: null, body: null, tab: 'text', highlight: null, hlLayer: null, + open: false, refreshTimer: 0, side: 'right', pick: false, catcher: null, + pickLabel: null, _pickHits: null, selection: null, ignoreNl: false, freeze: false }; + try { ui.side = window.localStorage.getItem('tlins.side') || 'right'; } catch (e) { /* ignore */ } + try { ui.ignoreNl = window.localStorage.getItem('tlins.ignl') === '1'; } catch (e) { /* ignore */ } + try { ui.freeze = window.localStorage.getItem('tlins.freeze') === '1'; } catch (e) { /* ignore */ } + // Editor switch: remembered choice if set, else seeded from CFG.editor (with 'auto' + // resolving to built-in only when VSCode isn't actually installed). + try { + var _sb = window.localStorage.getItem('tlins.builtin'); + ui.useBuiltin = _sb === '1' ? true : _sb === '0' ? false : + (CFG.editor === 'builtin' || (CFG.editor !== 'vscode' && !vscodeAvailable())); + } catch (e) { ui.useBuiltin = (CFG.editor === 'builtin'); } + // Which external editor the dropdown opens results in (null => first detected). + try { ui.editorId = window.localStorage.getItem('tlins.editor') || null; } catch (e) { ui.editorId = null; } + + function applySide() { + if (!ui.root) { return; } + var left = ui.side === 'left'; + ui.root.style.left = left ? '0' : 'auto'; + ui.root.style.right = left ? 'auto' : '0'; + ui.root.style.boxShadow = (left ? '2px' : '-2px') + ' 0 12px rgba(0,0,0,0.6)'; + applyOverlayScale(); + } + + function flipSide() { + ui.side = ui.side === 'left' ? 'right' : 'left'; + try { window.localStorage.setItem('tlins.side', ui.side); } catch (e) { /* ignore */ } + applySide(); + } + + function buildUI() { + if (ui.root) { return; } + var root = document.createElement('div'); + root.id = 'tl-inspector'; + root.style.cssText = [ + 'position:fixed', 'top:0', 'right:0', 'width:460px', 'height:100%', + 'background:rgba(20,22,28,0.96)', 'color:#e6e6e6', 'z-index:2147483646', + 'font:12px/1.45 Consolas,Menlo,monospace', 'box-shadow:-2px 0 12px rgba(0,0,0,0.6)', + 'display:none', 'flex-direction:column' + ].join(';'); + + var head = document.createElement('div'); + head.style.cssText = 'background:#11131a;border-bottom:1px solid #333;flex:0 0 auto'; + head.innerHTML = + '' + + 'TL Inspector' + + '' + + 'Text' + + 'Images' + + '' + + '⇄' + + '✕' + + '' + + '' + + '⌖ Inspect' + + '' + + ' Built-in Editor' + + '' + + '' + + ' Freeze' + + '↻ Reload' + + ''; + root.appendChild(head); + + var body = document.createElement('div'); + body.style.cssText = 'flex:1 1 auto;overflow:auto;padding:6px 8px'; + root.appendChild(body); + + var style = document.createElement('style'); + style.textContent = + '#tl-inspector .tl-hrow{display:flex;align-items:center;gap:6px;flex-wrap:wrap}' + + '#tl-inspector .tl-tab{cursor:pointer;padding:3px 11px;border-radius:4px;background:#222;color:#bbb;display:inline-flex;align-items:center;line-height:1.3}' + + '#tl-inspector .tl-tab.on{background:#2a5db0;color:#fff}' + + '#tl-inspector .tl-btn{cursor:pointer;padding:3px 10px;border-radius:4px;background:#333;color:#ddd;display:inline-flex;align-items:center;gap:5px;line-height:1.3}' + + '#tl-inspector .tl-btn.on{background:#3a7;color:#022}' + + '#tl-inspector .tl-ic{min-width:30px;justify-content:center;padding:3px 6px}' + + '#tl-inspector .tl-edsel{background:#333;color:#ddd;border:1px solid #475;border-radius:4px;padding:3px 4px;font:inherit;cursor:pointer;max-width:140px;line-height:1.3}' + + '#tl-inspector .tl-frz input{margin:0 1px 0 0}' + + '#tl-inspector .tl-btn:hover,#tl-inspector .tl-tab:hover{filter:brightness(1.3)}' + + '#tl-inspector .tl-row{border:1px solid #2b2f3a;border-radius:6px;padding:6px 8px;margin:0 0 6px;background:#1b1e26}' + + '#tl-inspector .tl-row.live{border-color:#3a7;background:#1b2620}' + + '#tl-inspector .tl-txt{color:#fff;white-space:pre-wrap;word-break:break-word;margin-bottom:4px;' + + '-webkit-user-select:text;user-select:text;cursor:text}' + + '#tl-inspector .tl-meta{color:#8aa;font-size:11px;display:flex;gap:10px;flex-wrap:wrap;align-items:center}' + + '#tl-inspector .tl-loc{color:#9cd;cursor:pointer;text-decoration:underline}' + + '#tl-inspector .tl-badge{font-size:10px;padding:0 5px;border-radius:8px;background:#345}' + + '#tl-inspector .tl-badge.choice{background:#534}' + + '#tl-inspector .tl-badge.ui{background:#553}' + + '#tl-inspector .tl-badge.live{background:#3a7;color:#022}' + + '#tl-inspector .tl-mini{cursor:pointer;color:#cda;background:#2a2f3a;padding:1px 7px;border-radius:4px;white-space:nowrap}' + + '#tl-inspector .tl-mini:hover{background:#363c4a;color:#eda}' + + '#tl-inspector .tl-imgwrap{display:flex;gap:8px;align-items:flex-start}' + + '#tl-inspector .tl-thumb{width:60px;height:60px;object-fit:contain;border:1px solid #333;border-radius:4px;flex:0 0 auto;' + + 'background-image:linear-gradient(45deg,#2a2a2a 25%,transparent 25%),linear-gradient(-45deg,#2a2a2a 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#2a2a2a 75%),linear-gradient(-45deg,transparent 75%,#2a2a2a 75%);background-size:12px 12px;background-position:0 0,0 6px,6px -6px,-6px 0;background-color:#15171d;image-rendering:pixelated}' + + '#tl-inspector .tl-noimg{display:flex;align-items:center;justify-content:center;color:#556;font-size:18px}' + + '#tl-inspector .tl-imginfo{flex:1;min-width:0}' + + '#tl-inspector .tl-dups{margin-top:6px;padding:4px 0 2px 8px;border-left:2px solid #46506a}' + + '#tl-inspector .tl-dup{color:#9cd;cursor:pointer;text-decoration:underline;display:block;margin:2px 0}' + + '#tl-inspector .tl-bar{margin:0 0 8px;color:#9ab}' + + '#tl-inspector .tl-bar input{vertical-align:middle}' + + '#tl-inspector .tl-empty{color:#778;padding:20px;text-align:center}'; + root.appendChild(style); + + document.body.appendChild(root); + ui.root = root; ui.body = body; + applySide(); + + // Stop panel mouse/wheel/touch events from reaching the game's document-level + // input handlers. Fixes: clicking the scrollbar/buttons driving the character, + // and the mouse wheel not scrolling (the game preventDefault()s wheel events). + ['mousedown', 'mouseup', 'click', 'dblclick', 'wheel', 'contextmenu', + 'touchstart', 'touchend', 'touchmove', 'pointerdown', 'pointerup'].forEach(function (t) { + root.addEventListener(t, function (ev) { ev.stopPropagation(); }, false); + }); + + var frz = root.querySelector('[data-act="freeze"]'); + if (frz) { + frz.addEventListener('change', function () { + ui.freeze = this.checked; + try { window.localStorage.setItem('tlins.freeze', ui.freeze ? '1' : ''); } catch (e) { /* ignore */ } + toast(ui.freeze ? 'Game controls frozen while editor is open' : 'Game controls unfrozen'); + }); + } + + // Editor dropdown: list every detected external editor; only shown when the + // built-in editor is NOT selected (since then clicks open externally). + var edsel = root.querySelector('[data-act="edsel"]'); + function syncEdsel() { + if (!edsel) { return; } + edsel.style.display = ui.useBuiltin ? 'none' : ''; + } + if (edsel) { + var list = detectEditors(); + list.forEach(function (e) { + var o = document.createElement('option'); + o.value = e.id; o.textContent = e.name; + edsel.appendChild(o); + }); + edsel.value = currentEditor().id; + syncEdsel(); + edsel.addEventListener('change', function () { + ui.editorId = this.value; + try { window.localStorage.setItem('tlins.editor', ui.editorId); } catch (e) { /* ignore */ } + toast('Results open in ' + currentEditor().name); + }); + } + + var bld = root.querySelector('[data-act="builtin"]'); + if (bld) { + bld.addEventListener('change', function () { + ui.useBuiltin = this.checked; + try { window.localStorage.setItem('tlins.builtin', ui.useBuiltin ? '1' : '0'); } catch (e) { /* ignore */ } + syncEdsel(); + toast(ui.useBuiltin ? 'Results open in the built-in editor' + : 'Results open in ' + currentEditor().name); + }); + } + + head.addEventListener('click', function (ev) { + var t = ev.target.getAttribute('data-tab'); + var a = ev.target.getAttribute('data-act'); + if (t) { ui.tab = t; if (t !== 'images' && ui.pick) { setPick(false); } render(); } + else if (a === 'refresh') { refreshGameElements(); } + else if (a === 'pick') { setPick(!ui.pick); } + else if (a === 'flip') { flipSide(); } + else if (a === 'close') { toggle(false); } + }); + + var hl = document.createElement('div'); + hl.style.cssText = 'position:fixed;border:2px solid #ff5;background:rgba(255,255,0,0.12);z-index:2147483645;pointer-events:none;display:none'; + document.body.appendChild(hl); + ui.highlight = hl; + + var pl = document.createElement('div'); + pl.style.cssText = 'position:fixed;background:#000d;color:#9f9;padding:3px 7px;border-radius:4px;font:11px monospace;z-index:2147483647;pointer-events:none;display:none;max-width:60vw;white-space:nowrap;overflow:hidden;text-overflow:ellipsis'; + document.body.appendChild(pl); + ui.pickLabel = pl; + + var hlz = document.createElement('div'); // container for multiple pick rects + hlz.style.cssText = 'position:fixed;left:0;top:0;z-index:2147483645;pointer-events:none;display:none'; + document.body.appendChild(hlz); + ui.hlLayer = hlz; + applyOverlayScale(); + } + + function setTabStyles() { + var tabs = ui.root.querySelectorAll('.tl-tab'); + for (var i = 0; i < tabs.length; i++) { + tabs[i].classList.toggle('on', tabs[i].getAttribute('data-tab') === ui.tab); + } + // Inspect only works on images, so only surface it on the Images tab. + var insp = ui.root.querySelector('.tl-inspect'); + if (insp) { insp.style.display = (ui.tab === 'images') ? '' : 'none'; } + } + + function esc(s) { + return String(s).replace(/[&<>]/g, function (c) { + return c === '&' ? '&' : c === '<' ? '<' : '>'; + }); + } + + function render() { + if (!ui.root || !ui.open) { return; } + setTabStyles(); + var st = ui.body.scrollTop; // preserve scroll across rebuilds + ui.body.innerHTML = ''; + if (ui.tab === 'text') { renderText(); } else { renderImages(); } + ui.body.scrollTop = st; + } + + // Signature of what's currently on screen + how many thumbs are ready, so the + // auto-refresh only rebuilds the Images tab when something actually changed + // (otherwise the scrollbar would keep snapping back to the top). + function onScreenSignature() { + var urls = collectOnScreenImages().map(function (i) { return i.url; }); + var ready = urls.filter(function (u) { return thumbCache[u]; }).length; + return urls.join('|') + '#' + ready + '#' + (ui.selection ? ui.selection.length : 0); + } + + function renderText() { + var bar = htmlEl('' + + ' ignore line breaks (\\n) when matching' + + '' + + 'Clear History (' + textRecords.length + ')'); + bar.querySelector('input').addEventListener('change', function () { + ui.ignoreNl = this.checked; + try { window.localStorage.setItem('tlins.ignl', ui.ignoreNl ? '1' : ''); } catch (e) { /* ignore */ } + }); + bar.querySelector('[data-act="clearhist"]').addEventListener('click', function () { + textRecords.length = 0; + currentGroup = -1; + render(); + }); + ui.body.appendChild(bar); + + if (!textRecords.length) { + ui.body.appendChild(htmlEl('No text captured yet.Trigger a message in-game.')); + return; + } + var msgBusy = (typeof $gameMessage !== 'undefined') && $gameMessage && $gameMessage.isBusy && $gameMessage.isBusy(); + for (var i = textRecords.length - 1; i >= 0; i--) { + var r = textRecords[i]; + if (!r.file) { resolveRecord(r); } // text-search fallback for identity misses + var expText = (r.expText != null) ? r.expText : r.text; // format(): locate the template, not the output + var loc = null; + if (r.file && r.tail) { + loc = (r.srcKind === 'meta') ? locateMetaValue(r.file, r.tail, expText) + : locateLine(r.file, r.tail, expText); + } + var line = loc ? loc.line : (r.uiLine || null); + var col = loc ? loc.col : (r.uiCol || null); + var live = msgBusy && r.group === currentGroup && currentGroup !== -1; + + var row = document.createElement('div'); + row.className = 'tl-row' + (live ? ' live' : ''); + + var fileShort = r.file ? r.file.replace(/^.*[\\\/]/, '') : null; + var locText = fileShort ? (fileShort + (line ? ':' + line : '')) + : (r._ambig ? r._ambig + ' candidates — click "locate"' : r.label); + + row.innerHTML = + '' + esc(r.text) + '' + + '' + + '' + r.kind + '' + + (live ? 'LIVE' : '') + + '' + esc(locText) + '' + + (r.srcKind && r.file ? '' + esc(r.label) + '' : '') + + (r.siteFile ? 'drawn at ' + + esc((r.siteLabel || '').replace(/^.*\//, '')) + '' : '') + + '' + + (r.kind === 'ui' ? 'Locate In Files' : (r.file ? 'Find Duplicates' : 'Locate In Files')) + '' + + '' + + ''; + + (function (rec, ln, cl, rowEl) { + var locEl = rowEl.querySelector('.tl-loc'); + if (locEl) { + locEl.addEventListener('click', function () { + if (rec.file) { openInEditor(rec.file, ln, cl); } + else { toast('Unresolved: ' + rec.label); } + }); + } + var siteBtn = rowEl.querySelector('[data-act="site"]'); + if (siteBtn) { + siteBtn.addEventListener('click', function () { + openInEditor(rec.siteFile, rec.siteLine, null); + }); + } + var dupBtn = rowEl.querySelector('[data-act="dups"]'); + var dupsEl = rowEl.querySelector('.tl-dups'); + if (dupBtn) { + dupBtn.addEventListener('click', function () { + if (dupsEl.style.display === 'none') { + dupsEl.style.display = 'block'; + dupsEl.innerHTML = 'searching…'; + setTimeout(function () { populateDups(dupsEl, rec); }, 0); + } else { dupsEl.style.display = 'none'; } + }); + } + })(r, line, col, row); + + ui.body.appendChild(row); + } + } + + function populateDups(container, rec) { + container.innerHTML = ''; + var MAXSHOW = 150; + var note = '', total = 0, shown = []; + + if (rec.kind === 'ui') { + // UI/plugin text: literal search across data + plugin files. + var s = searchFilesSmart(rec.text); + total = s.results.length; + note = total + ' match' + (total === 1 ? '' : 'es') + + (s.partial ? ' for "' + s.query + '" (value part omitted)' : ''); + shown = s.results.slice(0, MAXSHOW).map(function (o) { return { file: o.file, line: o.line, col: o.col, quoted: o.quoted }; }); + } else { + // Dialogue/choice text: list every identical line in the data files. + // IMPORTANT: slice BEFORE resolving line numbers — a frequent speaker name + // ("Yui") has thousands of hits and locating every one would freeze the game. + var occ = findOccurrences(rec.text, ui.ignoreNl); + total = occ.length; + note = total + ' occurrence' + (total === 1 ? '' : 's') + (ui.ignoreNl ? ' (ignoring \\n)' : ''); + shown = occ.slice(0, MAXSHOW).map(function (o) { + var l = locateLine(o.file, o.path, o.text); + return { file: o.file, line: l && l.line, col: l && l.col, + isSelf: rec.file === o.file && JSON.stringify(rec.tail) === JSON.stringify(o.path) }; + }); + } + + if (!total) { + container.innerHTML = 'no matches found' + + (rec.kind === 'ui' ? ' (text may be built at runtime)' : '') + ''; + return; + } + var head = htmlEl('' + note + + (total > MAXSHOW ? ' — showing first ' + MAXSHOW : '') + + ' Open All (' + shown.length + ')'); + container.appendChild(head); + shown.forEach(function (x) { + var fn = x.file.replace(/^.*[\\\/]/, ''); + // For UI/file searches, flag whether the match is the WHOLE string value + // ("exact") or just contained inside a longer one ("within longer text"). + var tag = (x.quoted === true) ? ' exact' + : (x.quoted === false) ? ' within longer text' : ''; + var el = htmlEl('' + esc(fn) + (x.line ? ':' + x.line : '') + tag + + (x.isSelf ? ' (this line)' : '') + ''); + el.addEventListener('click', function () { openInEditor(x.file, x.line, x.col); }); + container.appendChild(el); + }); + head.querySelector('[data-act="openall"]').addEventListener('click', function () { + if (shown.length > 8 && !window.confirm('Open ' + shown.length + ' files in the editor?')) { return; } + shown.forEach(function (x) { openInEditor(x.file, x.line, x.col); }); + }); + } + + function renderImages() { + // Objects captured from an Inspect click (the full stack under the cursor) + if (ui.selection && ui.selection.length) { + var selHead = htmlEl('' + + 'Under cursor (' + ui.selection.length + ')' + + 'Clear'); + selHead.querySelector('[data-act="clearsel"]').addEventListener('click', function () { ui.selection = null; render(); }); + ui.body.appendChild(selHead); + ui.selection.forEach(function (sel) { + ui.body.appendChild(buildImgRow(sel.url, sel.bitmap, { screen: sel.screen })); + }); + ui.body.appendChild(htmlEl('')); + } + + var live = collectOnScreenImages(); + ui.body.appendChild(htmlEl('On screen now (' + live.length + ')')); + if (!live.length) { + ui.body.appendChild(htmlEl('No image sprites on screen.')); + } + live.forEach(function (img) { + ui.body.appendChild(buildImgRow(img.url, img.bitmap, { screen: img.screen, trigger: imageTriggers[img.url] })); + }); + + // recent loads (history) + ui.body.appendChild(htmlEl('Recently loaded')); + for (var i = imageLog.length - 1; i >= 0 && i > imageLog.length - 25; i--) { + var it = imageLog[i]; + ui.body.appendChild(buildImgRow(it.url, it.bitmap, { fromLabel: it.label })); + } + } + + function htmlEl(html) { + var d = document.createElement('div'); + d.innerHTML = html; + return d.firstChild; + } + + function showHighlight(s) { + if (!s || !ui.highlight) { return; } + var h = ui.highlight; + h.style.left = s.x + 'px'; h.style.top = s.y + 'px'; + h.style.width = s.w + 'px'; h.style.height = s.h + 'px'; + h.style.display = 'block'; + } + function hideHighlight() { if (ui.highlight) { ui.highlight.style.display = 'none'; } } + + //========================================================================= + // Inspect / pick mode: hover the game canvas to highlight the image object + // under the cursor (topmost), click to reveal its source file. + //========================================================================= + function canvasScale(rect) { + return (rect && typeof Graphics !== 'undefined' && Graphics.width) ? rect.width / Graphics.width : 1; + } + + function boundsToScreen(b, rect, scale) { + return { x: rect.left + b.x * scale, y: rect.top + b.y * scale, + w: b.width * scale, h: b.height * scale }; + } + + // ALL bitmap objects whose bounds contain the point, bottom-to-top draw order. + function hitTestAll(stageX, stageY) { + var scene = (typeof SceneManager !== 'undefined') && SceneManager._scene; + var hits = []; + if (!scene) { return hits; } + (function walk(obj) { + if (!obj || obj.visible === false) { return; } + var bmp = obj.bitmap; + if (bmp && bmp._url) { + var vis = ('worldVisible' in obj) ? obj.worldVisible : true; + if (vis) { + var b = null; + try { b = obj.getBounds && obj.getBounds(); } catch (e) { b = null; } + if (b && b.width > 0 && b.height > 0 && + stageX >= b.x && stageX <= b.x + b.width && + stageY >= b.y && stageY <= b.y + b.height) { + hits.push({ url: decodeUrl(bmp._url), bounds: b, bitmap: bmp }); + } + } + } + var kids = obj.children; + if (kids) { for (var i = 0; i < kids.length; i++) { walk(kids[i]); } } + })(scene); + return hits; // index 0 = bottom-most, last = top-most + } + + function showHighlights(rects) { // multiple rects; last (top-most) is brighter + var layer = ui.hlLayer; + if (!layer) { return; } + layer.innerHTML = ''; + rects.forEach(function (r, i) { + var top = i === rects.length - 1; + var d = document.createElement('div'); + d.style.cssText = 'position:fixed;pointer-events:none;left:' + r.x + 'px;top:' + r.y + + 'px;width:' + r.w + 'px;height:' + r.h + 'px;border:2px ' + + (top ? 'solid #ff5' : 'dashed #6cf') + ';background:' + + (top ? 'rgba(255,255,0,0.12)' : 'rgba(80,170,255,0.06)'); + layer.appendChild(d); + }); + layer.style.display = 'block'; + } + function hideHighlights() { if (ui.hlLayer) { ui.hlLayer.innerHTML = ''; ui.hlLayer.style.display = 'none'; } } + + function onPickMove(ev) { + var canvas = getGameCanvas(); + if (!canvas) { return; } + var rect = canvas.getBoundingClientRect(); + var scale = canvasScale(rect); + var sx = (ev.clientX - rect.left) / scale, sy = (ev.clientY - rect.top) / scale; + var hits = hitTestAll(sx, sy); + if (hits.length) { + showHighlights(hits.map(function (h) { return boundsToScreen(h.bounds, rect, scale); })); + var topName = hits[hits.length - 1].url.replace(/^.*\//, ''); + ui.pickLabel.innerHTML = + (hits.length > 1 ? '' + hits.length + ' objects here — click to list' : '') + + 'top: ' + esc(topName); + ui.pickLabel.style.left = Math.min(ev.clientX + 12, window.innerWidth - 260) + 'px'; + ui.pickLabel.style.top = (ev.clientY + 14) + 'px'; + ui.pickLabel.style.display = 'block'; + ui._pickHits = hits.map(function (h) { + return { url: h.url, bitmap: h.bitmap, screen: boundsToScreen(h.bounds, rect, scale) }; + }); + } else { + hideHighlights(); + ui.pickLabel.style.display = 'none'; + ui._pickHits = null; + } + } + + // Click does NOT open anything: it lists every object under the cursor in the + // panel, where the user can highlight/reveal each one deliberately. + function onPickClick(ev) { + ev.preventDefault(); ev.stopPropagation(); + var hits = ui._pickHits; + setPick(false); + if (hits && hits.length) { + ui.selection = hits; + ui.tab = 'images'; + render(); + } + } + + function setPick(on) { + buildUI(); + ui.pick = !!on; + var btn = ui.root.querySelector('[data-act="pick"]'); + if (btn) { btn.classList.toggle('on', ui.pick); } + if (ui.pick) { + var canvas = getGameCanvas(); + var rect = canvas ? canvas.getBoundingClientRect() : { left: 0, top: 0, width: window.innerWidth, height: window.innerHeight }; + if (!ui.catcher) { + ui.catcher = document.createElement('div'); + ui.catcher.style.cssText = 'position:fixed;z-index:2147483644;cursor:crosshair;background:transparent'; + document.body.appendChild(ui.catcher); + ui.catcher.addEventListener('mousemove', onPickMove); + ui.catcher.addEventListener('click', onPickClick, true); + // Swallow all pointer input over the canvas while inspecting, so the + // game never reacts (this also keeps "freeze" effective during Inspect). + ['mousedown', 'mouseup', 'dblclick', 'wheel', 'contextmenu', 'mousemove', + 'touchstart', 'touchmove', 'touchend', 'pointerdown', 'pointerup', 'pointermove'].forEach(function (t) { + ui.catcher.addEventListener(t, function (e) { e.stopPropagation(); }, false); + }); + } + ui.catcher.style.left = rect.left + 'px'; + ui.catcher.style.top = rect.top + 'px'; + ui.catcher.style.width = rect.width + 'px'; + ui.catcher.style.height = rect.height + 'px'; + ui.catcher.style.display = 'block'; + toast('Inspect: hover an object, click to reveal. Esc/Inspect to exit.'); + } else { + if (ui.catcher) { ui.catcher.style.display = 'none'; } + hideHighlight(); + hideHighlights(); + if (ui.pickLabel) { ui.pickLabel.style.display = 'none'; } + } + } + + var refreshPending = false; + function scheduleRefresh() { + if (refreshPending || !ui.open) { return; } + refreshPending = true; + setTimeout(function () { refreshPending = false; render(); }, 60); + } + + function toggle(force) { + buildUI(); + ui.open = (typeof force === 'boolean') ? force : !ui.open; + ui.root.style.display = ui.open ? 'flex' : 'none'; + if (!ui.open && ui.pick) { setPick(false); } + hideHighlight(); + if (ui.open) { + render(); + if (!ui.refreshTimer) { + ui.refreshTimer = setInterval(function () { + if (ui.open && ui.tab === 'images') { + var sig = onScreenSignature(); + if (sig !== ui._imgSig) { ui._imgSig = sig; render(); } + } + }, 700); + } + } + } + + //========================================================================= + // Toast + //========================================================================= + var toastEl = null, toastTimer = 0; + function toast(msg) { + if (!toastEl) { + toastEl = document.createElement('div'); + toastEl.style.cssText = 'position:fixed;bottom:18px;left:50%;transform:translateX(-50%);background:#222;color:#fff;padding:8px 14px;border-radius:6px;z-index:2147483647;font:12px monospace;box-shadow:0 2px 8px rgba(0,0,0,.5)'; + document.body.appendChild(toastEl); + } + toastEl.textContent = msg; + toastEl.style.display = 'block'; + clearTimeout(toastTimer); + toastTimer = setTimeout(function () { toastEl.style.display = 'none'; }, 2600); + } + + //========================================================================= + // Hotkey + //========================================================================= + document.addEventListener('keydown', function (e) { + if (e.key === CFG.hotkey) { + e.preventDefault(); + e.stopPropagation(); + toggle(); + } else if (e.key === 'Escape' && ui.pick) { + e.preventDefault(); + e.stopPropagation(); + setPick(false); + } + }, true); + + // "Freeze game controls" guard: when enabled and the editor is open, block input + // events from reaching the game's document/window listeners. Events targeting the + // panel (or the Inspect catcher) and our own hotkeys are always allowed through. + function inPanel(node) { + return !!(node && ( + (ui.root && ui.root.contains(node)) || + (ui.catcher && ui.catcher === node) || + (editor.root && editor.root.contains(node)) // built-in editor needs raw input + )); + } + function freezeGuard(e) { + if (!ui.open || !ui.freeze) { return; } + if (inPanel(e.target)) { return; } // our panel / built-in editor get input untouched + var isKey = (e.type === 'keydown' || e.type === 'keyup' || e.type === 'keypress'); + if (isKey) { + if (e.key === CFG.hotkey || e.key === 'Escape') { return; } // hotkeys always work + // Always block the game from seeing the key (stopPropagation), but do NOT + // cancel the browser default for copy/select shortcuts (Ctrl+C / Ctrl+A) so + // the user can still copy selected text from the panel. + e.stopPropagation(); + if (e.stopImmediatePropagation) { e.stopImmediatePropagation(); } + if (e.cancelable && !(e.ctrlKey || e.metaKey)) { e.preventDefault(); } + return; + } + if (inPanel(e.target)) { return; } // let the panel receive mouse/wheel/touch + e.stopPropagation(); + if (e.stopImmediatePropagation) { e.stopImmediatePropagation(); } + if (e.cancelable) { e.preventDefault(); } + } + ['mousedown', 'mouseup', 'click', 'dblclick', 'wheel', 'mousemove', 'contextmenu', + 'touchstart', 'touchmove', 'touchend', 'keydown', 'keyup', 'keypress', + 'pointerdown', 'pointerup', 'pointermove'].forEach(function (t) { + window.addEventListener(t, freezeGuard, true); // capture: runs before game handlers + }); + + window.TLInspector = { + open: function () { toggle(true); }, + close: function () { toggle(false); }, + records: textRecords, + images: imageLog, + // debug/testing helpers + resolveUiSource: resolveUiSource, // drawn string -> value-source descriptor + locateMetaValue: locateMetaValue, + searchFilesSmart: searchFilesSmart, + cfg: CFG + }; + + log('ready - press ' + CFG.hotkey + ' to open'); +})();