aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--static/app.js210
-rw-r--r--static/dashboard.js284
-rw-r--r--static/deck.css247
-rw-r--r--static/index.html2
-rw-r--r--static/modules/k1c.js31
-rw-r--r--static/modules/llm.js125
-rw-r--r--static/modules/obs.js20
-rw-r--r--static/modules/sbbuilder.js95
-rw-r--r--static/modules/stats.js79
-rw-r--r--static/modules/tablet.js77
-rw-r--r--static/vendor/gridstack/gridstack-all.js3
-rw-r--r--static/vendor/gridstack/gridstack.min.css1
-rw-r--r--tests/test_dashboard.mjs55
-rw-r--r--tests/test_frontend.py34
14 files changed, 571 insertions, 692 deletions
diff --git a/static/app.js b/static/app.js
index 8c6d4e2..c296b90 100644
--- a/static/app.js
+++ b/static/app.js
@@ -1,4 +1,4 @@
-// deck-it - the page shell: tabs, cards and polling
+// deck-it - the page shell: tabs and polling
// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
//
// This program is free software; you can redistribute it and/or modify
@@ -15,42 +15,17 @@
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
// The shell: discover modules, sort them into tabs, mount each panel and poll
-// its state. A module is static/modules/<name>.js exporting default {title,
-// tab, interval, mount(el), update(state, el)}. Modules without a tab go into
-// the Dashboard. Card order and size are kept in this browser's localStorage.
+// its state. A module with a tab is static/modules/<name>.js exporting default
+// {title, tab, interval, mount(el), update(state, el)}. The Dashboard tab is
+// static/dashboard.js, which draws the modules without a tab.
const tabBar = document.getElementById("tabs");
document.getElementById("reload").onclick = () => location.reload();
const tabBody = document.getElementById("tab-body");
const refreshers = [];
-const LAYOUT_KEY = "deckit.layout";
const TAB_KEY = "deckit.tab";
-// Folded cards: id -> the height to restore when unfolded.
-const FOLD_KEY = "deckit.folded";
-const DEFAULT_W = 6;
-const DEFAULT_H = 4;
const tabs = {};
-let ready = false;
-
-function loadLayout() {
- try {
- const saved = JSON.parse(localStorage.getItem(LAYOUT_KEY));
- return Array.isArray(saved) ? saved : [];
- } catch {
- return [];
- }
-}
-
-function saveLayout() {
- if (!ready) return; // don't clobber the stored layout while the cards mount
- try {
- localStorage.setItem(LAYOUT_KEY, JSON.stringify(grid.save(false)));
- } catch {
- // private mode or storage full: the layout just won't persist
- }
-}
-
// Tab icons, Font Awesome glyphs in the Nerd Font the server serves; a tab
// not listed shows its name. The name also shows next to the active one.
const TAB_ICONS = { Dashboard: "\uf0e4", Windows: "\uf2d2", OBS: "\uf03d", Assistant: "\uf086", K1C: "\uf02f" };
@@ -97,163 +72,29 @@ function showTab(name) {
try {
localStorage.setItem(TAB_KEY, name);
} catch {}
- if (name === "Dashboard") window.dispatchEvent(new Event("resize"));
}
-// Dashboard is the grid; it exists before the modules so Gridstack measures a
-// visible container.
const dashboard = ensureTab("Dashboard");
dashboard.section.hidden = false;
dashboard.button.classList.add("active");
-const gridEl = document.createElement("div");
-gridEl.id = "grid";
-gridEl.className = "grid-stack";
-dashboard.section.append(gridEl);
-
-const grid = GridStack.init({
- column: 12,
- cellHeight: 80,
- margin: 8,
- float: true,
- handle: ".panel-drag",
- resizable: { handles: "se" },
-}, gridEl);
-grid.on("change", saveLayout);
-
-const savedById = {};
-for (const node of loadLayout()) {
- if (node.id) savedById[node.id] = node;
-}
-
-function loadFolded() {
- try {
- const saved = JSON.parse(localStorage.getItem(FOLD_KEY));
- return saved && typeof saved === "object" ? saved : {};
- } catch {
- return {};
- }
-}
-const folded = loadFolded();
-
-// Folding shrinks the card to one grid row and hides its body; the row it
-// keeps is only the title bar (the content stops at the header). Its height
-// before folding is kept so unfolding restores it, and it cannot be resized
-// while folded.
-function setFolded(item, fold) {
- const id = item.getAttribute("gs-id");
- const content = item.querySelector(".panel");
- const button = item.querySelector(".panel-fold");
- if (fold) {
- const node = item.gridstackNode;
- if (!(id in folded)) folded[id] = node?.h ?? DEFAULT_H;
- grid.update(item, { h: 1, noResize: true });
- closeGaps();
- } else if (id in folded) {
- grid.update(item, { h: folded[id], noResize: false });
- delete folded[id];
- }
- content.classList.toggle("folded", fold);
- button.textContent = fold ? "▸" : "▾";
- button.setAttribute("aria-label", fold ? "Unfold panel" : "Fold panel");
- button.setAttribute("aria-expanded", String(!fold));
- try {
- localStorage.setItem(FOLD_KEY, JSON.stringify(folded));
- } catch {}
-}
-
-// The grid floats, so nothing moves into rows a folded card gave back. Pull
-// each card below a folded one, in its columns, up as far as the space is
-// free (never above the folded card's title bar). Unfolding needs no mirror:
-// the grid pushes down whatever the regrown card hits.
-function closeGaps() {
- const nodes = grid.engine.nodes;
- const clash = (n, y) => nodes.some((o) => o !== n && o.x < n.x + n.w && o.x + o.w > n.x
- && o.y < y + n.h && o.y + o.h > y);
- const folds = nodes.filter((n) => n.el.querySelector(".panel.folded"));
- const below = nodes
- .filter((n) => folds.some((f) => n.y > f.y && n.x < f.x + f.w && n.x + n.w > f.x))
- .sort((a, b) => a.y - b.y);
- for (const n of below) {
- const floor = Math.max(...folds.filter((f) => n.y > f.y && n.x < f.x + f.w && n.x + n.w > f.x)
- .map((f) => f.y + f.h));
- let y = n.y;
- while (y - 1 >= floor && !clash(n, y - 1)) y--;
- if (y !== n.y) {
- grid.update(n.el, { y });
- }
- }
-}
-
-function header(title) {
- const head = document.createElement("div");
- head.className = "panel-head";
- const dot = document.createElement("span");
- dot.className = "panel-dot";
- const h = document.createElement("h2");
- h.textContent = title;
- const fold = document.createElement("button");
- fold.className = "panel-fold";
- fold.textContent = "▾";
- fold.setAttribute("aria-label", "Fold panel");
- fold.setAttribute("aria-expanded", "true");
- fold.onclick = () => {
- const item = fold.closest(".grid-stack-item");
- setFolded(item, !item.querySelector(".panel").classList.contains("folded"));
- };
- const drag = document.createElement("button");
- drag.className = "panel-drag";
- drag.textContent = "⠿";
- drag.setAttribute("aria-label", "Move panel");
- head.append(dot, h, fold, drag);
- return head;
-}
-
-function makeCard(name, title) {
- const item = document.createElement("div");
- item.className = "grid-stack-item";
- item.setAttribute("gs-id", name);
- const s = savedById[name];
- item.setAttribute("gs-w", String(s?.w ?? DEFAULT_W));
- item.setAttribute("gs-h", String(s?.h ?? DEFAULT_H));
- if (s) {
- item.setAttribute("gs-x", String(s.x));
- item.setAttribute("gs-y", String(s.y));
- }
- const content = document.createElement("div");
- content.className = "grid-stack-item-content panel";
- const body = document.createElement("div");
- body.className = "panel-body";
- content.append(header(title), body);
- item.append(content);
- gridEl.append(item);
- grid.makeWidget(item);
- if (name in folded) setFolded(item, true);
- return body;
-}
-
-// The first poll is not awaited: a slow source (the build VM over ssh, a
-// printer that is off) must not hold back the other panels.
-function startPoll(name, panel, el) {
- const poll = async () => {
+// Polls /api/<name> every `seconds` and hands the state to update. The first
+// poll is not awaited: a slow source (the build VM over ssh, a printer that
+// is off) must not hold back the others.
+function poll(name, seconds, update) {
+ const tick = async () => {
try {
const r = await fetch(`/api/${name}`);
if (r.headers.get("X-Deckit-Sleep")) return goodnight("The PC is asleep");
awake();
- if (r.ok) panel.update?.(await r.json(), el);
+ if (r.ok) update(await r.json());
} catch {
// keep the last state; the next tick retries
}
};
- refreshers.push(poll);
- poll();
- setInterval(poll, (panel.interval ?? 1) * 1000);
-}
-
-function mountDashboard(name, panel) {
- const body = makeCard(name, panel.title ?? name);
- panel.mount?.(body);
- startPoll(name, panel, body);
+ refreshers.push(tick);
+ tick();
+ setInterval(tick, seconds * 1000);
}
function mountTab(name, panel, section) {
@@ -261,31 +102,32 @@ function mountTab(name, panel, section) {
wrap.className = "tab-content";
section.append(wrap);
panel.mount?.(wrap);
- startPoll(name, panel, wrap);
+ poll(name, panel.interval ?? 1, (st) => panel.update?.(st, wrap));
}
async function boot() {
const r = await fetch("/api/modules");
if (!r.ok) return;
// Every panel's code at once; then mount in the server's order, so the
- // cards and tabs do not shuffle with whichever import lands first.
+ // tabs do not shuffle with whichever import lands first.
const names = (await r.json()).map(({ name }) => name);
const loaded = await Promise.all(names.map((name) =>
import(`./modules/${name}.js`).then((m) => m.default, () => null)));
names.forEach((name, i) => {
const panel = loaded[i];
- if (!panel) return;
- const tabName = panel.tab ?? "Dashboard";
+ if (!panel?.tab) return; // no tab: drawn by the Dashboard, if at all
try {
- if (tabName === "Dashboard") mountDashboard(name, panel);
- else mountTab(name, panel, ensureTab(tabName).section);
+ mountTab(name, panel, ensureTab(panel.tab).section);
} catch {
- // a broken panel must not take down the rest of the dashboard
+ // a broken panel must not take down the rest of the page
}
});
- closeGaps();
- ready = true;
- saveLayout();
+ try {
+ const { default: dash } = await import("./dashboard.js");
+ dash.mount(dashboard.section, names, { poll, open: showTab });
+ } catch {
+ // the other tabs still work
+ }
sortTabs();
const saved = localStorage.getItem(TAB_KEY);
showTab(tabs[saved] ? saved : "Dashboard");
@@ -299,7 +141,7 @@ function stepTab(dir) {
}
// Swipe the content sideways to change tab, from anywhere but sliders and
-// the dashboard's drag and resize handles, whose sideways drags are theirs.
+// text fields, whose sideways drags are theirs.
// #tab-body is `touch-action: pan-y`: otherwise the browser claims the moving
// finger as a pan and sends pointercancel, which is why swipes never worked.
// A swipe that started on a button must not also click it.
@@ -307,7 +149,7 @@ let swipe = null;
let swallowClick = false;
tabBody.addEventListener("pointerdown", (e) => {
if (e.pointerType === "mouse" && e.buttons !== 1) return;
- if (e.target.closest("input, select, textarea, .panel-drag, .ui-resizable-handle")) {
+ if (e.target.closest("input, select, textarea")) {
swipe = null;
return;
}
diff --git a/static/dashboard.js b/static/dashboard.js
new file mode 100644
index 0000000..5479312
--- /dev/null
+++ b/static/dashboard.js
@@ -0,0 +1,284 @@
+// deck-it - the Dashboard: one fixed screen
+// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+// The Dashboard tab: a top band of chips, music and spending always on, a
+// row of one to three busy modules, and the action icons. The page keeps the
+// trend history; the modules' APIs are the existing ones.
+
+import { offline } from "./offline.js";
+
+export const HISTORY = 120; // trend samples: two minutes at 1 s
+const RUNNING = ["k1c", "sbbuilder", "obs"]; // the running row's order
+
+const G = { cpu: "", mem: "\u{f035b}", gpu: "\u{f08ae}", net: "\u{f04e1}",
+ wifi: "", charging: "\u{f0084}", tux: "" };
+const BATTERY = ["", "", "", "", ""];
+// Nerd Font distro logos by os-release ID.
+const DISTRO = {
+ slackware: "", arch: "", debian: "", fedora: "",
+ ubuntu: "", gentoo: "", opensuse: "", void: "",
+};
+const SPEND = ["var(--udt-accent)", "var(--udt-blue, #89b4fa)", "var(--udt-green, #a6e3a1)"];
+const OTHER = "var(--udt-surface2)";
+
+const esc = (s) => String(s ?? "").replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
+const rate = (b) => (b >= 1048576 ? `${(b / 1048576).toFixed(1)}M` : `${Math.round((b ?? 0) / 1024)}k`);
+const gib = (b) => (b / 2 ** 30).toFixed(1);
+const money = (v) => (v == null ? "—" : `$${Number(v).toFixed(2)}`);
+const tok = (n) => (n >= 1e9 ? `${(n / 1e9).toFixed(1)}B` : n >= 1e6 ? `${(n / 1e6).toFixed(1)}M`
+ : n >= 1e3 ? `${(n / 1e3).toFixed(1)}k` : String(n ?? 0));
+const pct = (v) => (v == null ? "—" : `${Math.round(v)}%`);
+const short = (m) => String(m ?? "").split("/").pop();
+const uptime = (s) => {
+ const d = Math.floor(s / 86400), h = Math.floor((s % 86400) / 3600);
+ return d ? `${d}d ${h}h` : `${h}h`;
+};
+
+export function push(list, v, n = HISTORY) {
+ list.push(v);
+ if (list.length > n) list.shift();
+ return list;
+}
+
+// A filled area over a 120x100 viewBox, the newest sample at the right edge;
+// the largest value reaches 12% from the top.
+export function area(samples, max, n = HISTORY) {
+ if (!samples.length) return "";
+ const x = (i) => ((n - samples.length + i) * 120) / (n - 1);
+ const y = (v) => 100 - Math.min(1, v / (max || 1)) * 88;
+ return `M${x(0)},100 ` + samples.map((v, i) => `L${x(i)},${y(v)}`).join(" ") + " L120,100 Z";
+}
+
+// The top 3 paid models (llm.py sorts them by cost), then the rest as "other".
+export function spendParts(models) {
+ const paid = (models ?? []).filter((m) => m.cost > 0);
+ const rest = paid.slice(3).reduce((a, m) => a + m.cost, 0);
+ return rest > 0 ? [...paid.slice(0, 3), { model: "other", cost: rest }] : paid.slice(0, 3);
+}
+
+export function batteryGlyph(b) {
+ if (b?.status === "charging" || b?.status === "full") return G.charging;
+ return BATTERY[Math.min(4, Math.max(0, Math.round((b?.level ?? 0) / 25)))];
+}
+
+// A line too long for its slot slides to its end and back (deck.css .marq);
+// one that fits stays still. Only changed values are written, so the
+// animation is not restarted by every poll.
+function marquee(el) {
+ for (const line of el.querySelectorAll(".what, .meta")) {
+ const over = line.firstElementChild.offsetWidth - line.clientWidth;
+ line.classList.toggle("marq", over > 0);
+ const d = `${-Math.max(0, over)}px`;
+ if (line.style.getPropertyValue("--d") !== d) {
+ line.style.setProperty("--d", d);
+ line.style.setProperty("--t", `${2 + Math.max(0, over) / 30}s`); // ~30 px/s plus the pauses
+ }
+ }
+}
+
+const SKELETON = `
+ <svg class="dash-defs" width="0" height="0" aria-hidden="true"><defs>
+ <linearGradient id="hyline"><stop offset="0" style="stop-color:var(--udt-border-1)"/>
+ <stop offset=".5" style="stop-color:var(--udt-border-2)"/><stop offset="1" style="stop-color:var(--udt-border-3)"/></linearGradient>
+ <linearGradient id="hyfill" x1="0" y1="0" x2="0" y2="1">
+ <stop offset="0" style="stop-color:var(--udt-border-2);stop-opacity:.45"/>
+ <stop offset="1" style="stop-color:var(--udt-border-1);stop-opacity:.05"/></linearGradient>
+ </defs></svg>
+ <section class="dash-top">
+ <div class="dash-id"><i class="nf logo"></i><b class="os"></b><span class="kernel"></span>
+ <span class="sep">·</span><span class="up"></span></div>
+ <div class="chips sys">
+ <div class="chip c-cpu"><svg viewBox="0 0 120 100" preserveAspectRatio="none"><path class="hy"/></svg>
+ <i class="nf ic">${G.cpu}</i><span class="col"><span class="n"></span><span class="v num"></span></span><span class="s"></span></div>
+ <div class="chip c-mem"><i class="fill"></i><i class="nf ic">${G.mem}</i><span class="v num"></span><span class="s"></span></div>
+ <div class="chip c-gpu"><i class="fill"></i>
+ <i class="nf ic">${G.gpu}</i><span class="col"><span class="n"></span><span class="v num"></span></span><span class="s"></span></div>
+ <div class="chip c-net"><svg viewBox="0 0 120 100" preserveAspectRatio="none"><path class="hy"/><path class="up"/></svg>
+ <i class="nf ic">${G.net}</i><span class="v num"></span></div>
+ </div>
+ <div class="chips aux">
+ <div class="chip c-ctx"><i class="fill"></i><span class="brand claude ic"></span><span class="v num"></span><span class="k">context</span></div>
+ <div class="chip c-5h"><i class="fill"></i><span class="brand claude ic"></span><span class="v num"></span><span class="k">5h</span></div>
+ <div class="chip c-7d"><i class="fill"></i><span class="brand claude ic"></span><span class="v num"></span><span class="k">7d</span></div>
+ <div class="chip c-bat"><i class="fill"></i><i class="nf ic"></i><span class="v num"></span></div>
+ <div class="chip c-wifi"><i class="fill"></i><i class="nf ic">${G.wifi}</i><span class="v num"></span><span class="s"></span></div>
+ </div>
+ </section>
+ <section class="dash-mid">
+ <div class="dash-always"><div class="card dash-music"></div><div class="card dash-spend"></div></div>
+ <div class="dash-running" hidden></div>
+ </section>
+ <section class="dash-acts"></section>`;
+
+export default {
+ // names: the enabled modules; poll(name, seconds, update) and open(tab)
+ // come from app.js.
+ mount(section, names, { poll, open }) {
+ const on = new Set(names);
+ const root = document.createElement("div");
+ root.className = "dash";
+ root.innerHTML = SKELETON;
+ section.append(root);
+ const $ = (s) => root.querySelector(s);
+ const chip = (sel, v, s, fill, warn) => {
+ const c = $(sel);
+ c.querySelector(".v").textContent = v;
+ if (s != null) c.querySelector(".s").textContent = s;
+ if (fill != null) c.querySelector(".fill").style.width = `${Math.max(0, Math.min(100, fill))}%`;
+ c.classList.toggle("warn", Boolean(warn));
+ };
+
+ // A disabled module's parts are left out.
+ $(".dash-id").hidden = !on.has("stats");
+ $(".chips.sys").hidden = !on.has("stats");
+ for (const c of [".c-ctx", ".c-5h", ".c-7d"]) $(c).hidden = !on.has("llm");
+ $(".dash-spend").hidden = !on.has("llm");
+ $(".c-bat").hidden = $(".c-wifi").hidden = !on.has("tablet");
+ $(".dash-music").hidden = !on.has("music");
+
+ const hist = { cpu: [], down: [], up: [] };
+ if (on.has("stats")) poll("stats", 1, (st) => {
+ $(".logo").textContent = DISTRO[st.os?.id] ?? G.tux;
+ $(".os").textContent = st.os?.name ?? "";
+ $(".kernel").textContent = [st.os?.codename, `Linux ${st.os?.kernel ?? ""}`].filter(Boolean).join(" · ");
+ $(".up").textContent = `up ${uptime(st.uptime)}`;
+ push(hist.cpu, st.cpu); push(hist.down, st.net.down); push(hist.up, st.net.up);
+ $(".c-cpu .n").textContent = st.cpuName ?? "";
+ $(".c-cpu path").setAttribute("d", area(hist.cpu, Math.max(25, ...hist.cpu)));
+ chip(".c-cpu", `${st.cpu}%`, st.cpuTemp != null ? `${st.cpuTemp}°C` : "", null, st.cpuTemp >= 85);
+ chip(".c-mem", gib(st.memUsed * 1024), `/ ${Math.round(st.memTotal / 1048576)} GiB`,
+ (100 * st.memUsed) / st.memTotal);
+ const g = st.gpu;
+ $(".c-gpu").hidden = !g;
+ if (g) {
+ $(".c-gpu .n").textContent = g.name ?? "";
+ chip(".c-gpu", g.temp != null ? `${g.temp}°C` : "—",
+ g.memTotal ? `${gib(g.memUsed)} / ${Math.round(g.memTotal / 2 ** 30)} GiB` : `${gib(g.memUsed)} GiB`,
+ g.memTotal ? (100 * g.memUsed) / g.memTotal : 0, g.temp >= 85);
+ }
+ const max = Math.max(1, ...hist.down, ...hist.up);
+ const [down, up] = $(".c-net").querySelectorAll("path");
+ down.setAttribute("d", area(hist.down, max));
+ up.setAttribute("d", area(hist.up, max));
+ chip(".c-net", `↓${rate(st.net.down)} ↑${rate(st.net.up)}`);
+ });
+
+ const program = (title, p) => {
+ const model = `<span class="model">${esc(p.model ? short(p.model) : "—")}</span>`;
+ if (!(p.cost > 0)) { // local or free models: tokens, not dollars
+ return `<div class="prog row"><h3>${esc(title)}</h3>${model}
+ <span class="tok"><span class="lbl">session</span><b class="num">${tok(p.session_tokens)}</b></span>
+ <span class="tok"><span class="lbl">total</span><b class="num">${tok(p.tokens)}</b></span></div>`;
+ }
+ const parts = spendParts(p.models);
+ const total = parts.reduce((a, m) => a + m.cost, 0);
+ const color = (m, i) => (m.model === "other" ? OTHER : SPEND[i]);
+ return `<div class="prog"><header><h3>${esc(title)}</h3>${model}</header>
+ <div class="nums">
+ <div><div class="lbl">session</div><div class="big num">${money(p.session_cost)}</div>
+ <div class="sub">${tok(p.session_tokens)} · ${p.session_calls ?? 0} calls</div></div>
+ <div><div class="lbl">total</div><div class="big num">${money(p.cost)}</div>
+ <div class="sub">${tok(p.tokens)} · ${p.calls ?? 0} calls</div></div>
+ </div>
+ <div class="stack">${parts.map((m, i) =>
+ `<i style="width:${(100 * m.cost) / total}%;background:${color(m, i)}"></i>`).join("")}</div>
+ <div class="legend">${parts.map((m, i) =>
+ `<span style="--c:${color(m, i)}">${esc(short(m.model))} ${money(m.cost)}</span>`).join("")}</div>
+ </div>`;
+ };
+ if (on.has("llm")) poll("llm", 5, (st) => {
+ const spend = $(".dash-spend");
+ if (st.offline) {
+ offline(spend, { icon: "/logos/claude.svg", title: "Usage dashboard is off",
+ detail: "Start llm-cost-dashboard and the spending appears here." });
+ for (const c of [".c-ctx", ".c-5h", ".c-7d"]) chip(c, "—", null, 0);
+ return;
+ }
+ const c = st.claude ?? {};
+ chip(".c-ctx", pct(c.context_pct), null, c.context_pct, c.context_pct >= 80);
+ chip(".c-5h", pct(c.five_hour_pct), null, c.five_hour_pct, c.five_hour_pct >= 80);
+ chip(".c-7d", pct(c.seven_day_pct), null, c.seven_day_pct, c.seven_day_pct >= 80);
+ spend._offline = null;
+ spend.innerHTML = program("opencode", st.opencode ?? {}) + program("Local Agent", st.assistant ?? {});
+ });
+
+ if (on.has("tablet")) poll("tablet", 10, (t) => {
+ const b = t.battery ?? {}, w = t.wifi ?? {};
+ const charging = b.status === "charging" || b.status === "full";
+ $(".c-bat .ic").textContent = batteryGlyph(b);
+ chip(".c-bat", b.level != null ? `${b.level}%` : "—", null, b.level, b.level < 20 && !charging);
+ chip(".c-wifi", w.rssi != null ? `${w.rssi} dBm` : "—", w.band ?? "",
+ w.rssi == null ? 0 : 2 * (w.rssi + 100)); // -100 dBm empty, -50 full
+ });
+
+ if (on.has("music")) import("./modules/music.js").then(({ default: music }) => {
+ const el = $(".dash-music");
+ music.mount(el);
+ poll("music", music.interval ?? 2, (st) => music.update(st, el));
+ });
+
+ // The running row: slots are created now, in RUNNING order, and shown
+ // while their module is busy.
+ const row = $(".dash-running");
+ for (const name of RUNNING.filter((n) => on.has(n))) {
+ const el = document.createElement("div");
+ el.className = `card slot slot-${name}`;
+ el.hidden = true;
+ row.append(el);
+ import(`./modules/${name}.js`).then((mod) => {
+ if (!mod.busy || !mod.slot) return;
+ const tab = mod.default?.tab;
+ el.addEventListener("click", (e) => { if (tab && !e.target.closest("button")) open(tab); });
+ // ponytail: the K1C and OBS tabs poll the same API; two polls a second, one cache if it matters.
+ poll(name, mod.interval ?? mod.default?.interval ?? 2, (st) => {
+ el.hidden = !mod.busy(st);
+ if (!el.hidden) {
+ mod.slot(st, el);
+ marquee(el);
+ }
+ row.hidden = !row.querySelector(".slot:not([hidden])");
+ });
+ });
+ }
+
+ if (on.has("actions")) poll("actions", 30, (st) => {
+ const acts = $(".dash-acts");
+ const key = (st.actions ?? []).map((a) => a.id).join(",");
+ if (acts._key === key) return;
+ acts._key = key;
+ acts.textContent = "";
+ for (const a of st.actions ?? []) {
+ const b = document.createElement("button");
+ b.className = "nf";
+ b.textContent = a.icon;
+ b.title = a.label;
+ b.setAttribute("aria-label", a.label);
+ b.onclick = async () => {
+ let ok = false;
+ try {
+ ok = (await fetch(`/api/actions/${a.id}`, {
+ method: "POST", headers: { "Content-Type": "application/json" }, body: "{}" })).ok;
+ } catch {}
+ if (!ok) {
+ b.classList.add("fail");
+ setTimeout(() => b.classList.remove("fail"), 1500);
+ }
+ };
+ acts.append(b);
+ }
+ });
+ },
+};
diff --git a/static/deck.css b/static/deck.css
index 1aedc6f..ef10de6 100644
--- a/static/deck.css
+++ b/static/deck.css
@@ -86,101 +86,16 @@ body {
.tab-panel[hidden] { display: none; }
.tab-content { min-height: 100%; }
-.panel { min-height: 0; min-width: 0; }
-
@property --border-angle {
syntax: "<angle>";
initial-value: 0deg;
inherits: false;
}
-.grid-stack-item-content.panel {
- position: absolute;
- display: flex;
- flex-direction: column;
- padding: 0;
- overflow: hidden;
- border-radius: 16px;
- background: var(--udt-surface0);
- border: 0;
- box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
-}
-
-/* The same rotating three-hue gradient Hyprland draws on window borders,
- read from ~/.cache/udt/udt-border.lua via /theme.css. */
-.grid-stack-item-content.panel::before {
- content: "";
- position: absolute;
- inset: 0;
- border-radius: inherit;
- padding: 2px;
- background: linear-gradient(var(--border-angle),
- var(--udt-border-1), var(--udt-border-2), var(--udt-border-3), var(--udt-border-1));
- -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
- -webkit-mask-composite: xor;
- mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
- mask-composite: exclude;
- pointer-events: none;
- /* Hyprland: speed 30 * 100 ms, flatlinetwo = linear, style = loop */
- animation: border-rotate 3s linear infinite;
-}
-
@keyframes border-rotate {
to { --border-angle: 360deg; }
}
-.panel-head {
- flex: none;
- display: flex;
- align-items: center;
- gap: 10px;
- padding: 10px 14px;
- background: var(--udt-mantle);
- border-bottom: 1px solid var(--udt-surface1);
-}
-.panel-dot {
- width: 8px;
- height: 8px;
- border-radius: 50%;
- background: var(--udt-accent);
- flex: none;
-}
-.panel .panel-head h2 {
- flex: 1;
- margin: 0;
- font-size: 0.929rem;
- font-weight: 600;
- letter-spacing: .02em;
- color: var(--udt-text);
-}
-.panel-drag {
- font: inherit;
- color: var(--udt-overlay0);
- background: transparent;
- border: 0;
- padding: 2px 6px;
- border-radius: 6px;
- cursor: grab;
- touch-action: none;
-}
-.panel-drag:hover { color: var(--udt-subtext0); background: var(--udt-surface1); }
-.panel-fold {
- font: inherit;
- min-width: 36px;
- min-height: 32px;
- color: var(--udt-overlay0);
- background: transparent;
- border: 0;
- border-radius: 6px;
- cursor: pointer;
-}
-.panel-fold:hover { color: var(--udt-subtext0); background: var(--udt-surface1); }
-/* Folded: the card ends at its title bar instead of filling its grid row. */
-.grid-stack > .grid-stack-item > .grid-stack-item-content.panel.folded { bottom: auto; }
-.panel.folded .panel-body { display: none; }
-.panel.folded .panel-head { border-bottom: 0; }
-.panel-body { flex: 1; min-height: 0; overflow: auto; padding: 14px; }
-
.section-label {
font-size: 0.786rem;
text-transform: uppercase;
@@ -226,11 +141,6 @@ body {
.music .time { font-size: 0.857rem; color: var(--udt-subtext0); white-space: nowrap; }
.music .controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
-.sbb .sbb-now { margin-bottom: 8px; font-size: 0.857rem; font-weight: 600; }
-
-.grid-stack-item .ui-resizable-se { width: 22px; height: 22px; right: 2px; bottom: 2px; opacity: .45; }
-.grid-stack-item:hover .ui-resizable-se { opacity: 1; }
-
.num {
font-family: "Inconsolata Nerd Font Mono", ui-monospace, monospace;
font-variant-numeric: tabular-nums;
@@ -266,8 +176,6 @@ select {
padding: 8px;
}
-.sbb .id { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mtile {
display: flex;
@@ -288,13 +196,6 @@ select {
text-overflow: ellipsis;
}
.msub { font-size: 0.857rem; color: var(--udt-subtext0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
-.tablet .bars { height: 0.8em; margin-left: 6px; vertical-align: baseline; fill: var(--udt-surface2); }
-.tablet .bars .lit { fill: var(--udt-accent); }
-.msys { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 14px; }
-.msys > i { flex: none; width: 3rem; font-size: 2.6rem; line-height: 1; color: var(--udt-accent); }
-.msys > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
-.msys .mup { margin-left: auto; align-items: flex-end; flex: none; }
-.mfoot { margin-top: 10px; font-size: 0.857rem; color: var(--udt-overlay0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.windows { display: flex; flex-direction: column; gap: 14px; }
.windows .ws { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
@@ -361,14 +262,6 @@ select {
.wpop-ws { display: flex; flex-wrap: wrap; gap: 6px; }
.wpop-ws button { min-width: 44px; min-height: 44px; padding: 0; font-size: 1.143rem; font-weight: 600; }
-.llm { display: flex; flex-direction: column; gap: 10px; }
-.llm-sec {
- padding: 10px 12px;
- border-radius: 12px;
- background: var(--udt-mantle);
- border: 1px solid var(--udt-surface1);
-}
-.llm-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.brand {
width: 18px;
height: 18px;
@@ -383,32 +276,8 @@ select {
}
.brand.claude { -webkit-mask-image: url(/logos/claude.svg); mask-image: url(/logos/claude.svg); }
.brand.opencode { -webkit-mask-image: url(/logos/opencode.svg); mask-image: url(/logos/opencode.svg); }
-.brand-nf { width: 18px; flex: none; font-size: 18px; line-height: 1; text-align: center; color: var(--udt-accent); }
-.llm-head h3 {
- font-size: 0.857rem;
- text-transform: uppercase;
- letter-spacing: .08em;
- color: var(--udt-subtext0);
- flex: none;
-}
-.llm-head .model {
- margin-left: auto;
- max-width: 60%;
- font-size: 0.857rem;
- color: var(--udt-overlay0);
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.gauges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
-.gauge { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 12px; background: var(--udt-surface1); }
-.glabel { font-size: 0.714rem; text-transform: uppercase; letter-spacing: .08em; color: var(--udt-overlay0); }
-.gvalue { font-size: 1.714rem; font-weight: 600; line-height: 1.1; }
.gbar { height: 6px; background: var(--udt-surface2); border-radius: 3px; overflow: hidden; }
.gbar > i { display: block; height: 100%; background: var(--udt-accent); }
-.lbig { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--udt-surface1); }
-.lpair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.good { color: var(--udt-green); }
.bad { color: var(--udt-red); }
@@ -760,3 +629,119 @@ select {
.windows .ws .wtile img { width: 32px; height: 32px; object-fit: contain; }
.wws img { width: 22px; height: 22px; object-fit: contain; }
.wpop-ws button img { width: 24px; height: 24px; object-fit: contain; }
+
+/* The Dashboard: one fixed screen (static/dashboard.js). */
+.tab-panel[data-tab="Dashboard"] { height: 100%; box-sizing: border-box; padding-top: 18px; }
+.dash { height: 100%; display: grid; grid-template-rows: 25% 1fr 10%; gap: 10px; }
+.dash [hidden] { display: none !important; }
+.dash-defs { position: absolute; }
+
+.dash-top { display: grid; grid-template-rows: auto 1fr 1fr; gap: 8px; min-height: 0; }
+.dash-id { display: flex; align-items: center; gap: 14px; font-size: 0.857rem; color: var(--udt-subtext0); white-space: nowrap; overflow: hidden; }
+.dash-id .logo { font-size: 1.15rem; color: var(--udt-accent); }
+.dash-id b { color: var(--udt-text); font-weight: 600; }
+.dash-id .sep { color: var(--udt-surface2); }
+.dash .chips { display: grid; gap: 8px; min-height: 0; }
+.dash .chips.sys { grid-template-columns: 1fr 1fr 1fr 1.3fr; }
+.dash .chips.aux { grid-template-columns: 1fr 1fr 1fr 1fr 1.3fr; }
+.dash .chip { position: relative; overflow: hidden; border-radius: 10px; background: var(--udt-surface0);
+ border: 1px solid var(--udt-surface1); display: flex; align-items: center; gap: 10px; padding: 0 14px; min-width: 0; }
+.dash .chip.warn { border-color: var(--udt-accent); }
+.dash .chip svg, .dash .chip .fill { position: absolute; inset: 0; pointer-events: none; }
+.dash .chip svg { width: 100%; height: 100%; }
+.dash .chip svg path { stroke-width: 1.5; vector-effect: non-scaling-stroke; }
+.dash .chip svg path.hy { fill: url(#hyfill); stroke: url(#hyline); }
+.dash .chip svg path.up { fill: color-mix(in srgb, var(--udt-text) 8%, transparent); stroke: color-mix(in srgb, var(--udt-text) 30%, transparent); }
+.dash .chip .fill { right: auto; width: 0; background: color-mix(in srgb, var(--udt-accent) 20%, transparent); transition: width .4s; }
+.dash .chip .ic { position: relative; flex: none; width: 1.4rem; font-size: 1.25rem; line-height: 1; color: var(--udt-overlay1); }
+.dash .chip .brand.ic { width: 20px; height: 20px; }
+.dash .chip .col { position: relative; display: flex; flex-direction: column; min-width: 0; }
+.dash .chip .n { font-size: 0.714rem; color: var(--udt-overlay1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
+.dash .chip .v { position: relative; font-size: 1.35rem; font-weight: 600; white-space: nowrap; line-height: 1.1; }
+.dash .chip .k { position: relative; font-size: 0.714rem; text-transform: uppercase; letter-spacing: .08em; color: var(--udt-overlay1); }
+.dash .chip .s { position: relative; font-size: 0.786rem; color: var(--udt-subtext0); white-space: nowrap; margin-left: auto; }
+
+.dash-mid { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
+.dash-always { display: flex; gap: 12px; flex: 1; min-height: 0; }
+.dash .card { min-height: 0; min-width: 0; overflow: hidden; padding: 14px 16px; border-radius: 14px;
+ background: var(--udt-mantle); border: 1px solid var(--udt-surface1); }
+.dash-music { flex: 1; }
+.dash-spend { flex: 1.4; display: flex; flex-direction: column; gap: 10px; }
+.dash-music .music .top { margin-bottom: 6px; }
+.dash-music .music .art { width: 52px; height: 52px; border-radius: 10px; }
+.dash-music .music .title { font-size: 1rem; }
+.dash-music .music .album { display: none; }
+.dash-music .music .seek { margin: 4px 0 8px; }
+.dash-music .music .controls { flex-wrap: nowrap; }
+.dash-music .music .controls button { min-height: 38px; min-width: 40px; font-size: 1rem; padding: 0; }
+.dash-music .music .vol { min-width: 0; }
+
+.dash .prog { display: flex; flex-direction: column; gap: 6px; }
+.dash .prog header { display: flex; align-items: baseline; gap: 10px; }
+.dash .prog h3 { margin: 0; font-size: 0.857rem; text-transform: uppercase; letter-spacing: .08em; color: var(--udt-subtext0); }
+.dash .prog .model { margin-left: auto; font-size: 0.786rem; color: var(--udt-overlay0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
+.dash .prog .nums { display: flex; gap: 22px; align-items: baseline; }
+.dash .prog .big { font-size: 1.25rem; font-weight: 600; }
+.dash .prog .lbl { font-size: 0.714rem; text-transform: uppercase; letter-spacing: .08em; color: var(--udt-overlay0); }
+.dash .prog .sub { font-size: 0.786rem; color: var(--udt-subtext0); }
+.dash .prog.row { flex-direction: row; align-items: baseline; gap: 12px; padding-top: 10px; border-top: 1px solid var(--udt-surface1); }
+.dash .prog.row .model { margin-left: 0; flex: 1; }
+.dash .prog.row .tok b { font-size: 1.1rem; font-weight: 600; margin-left: 4px; }
+.dash .stack { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--udt-surface0); }
+.dash .stack i { display: block; height: 100%; }
+.dash .legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.75rem; color: var(--udt-subtext0); }
+.dash .legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; background: var(--c); }
+
+/* The running row: one to three slots in equal columns. A line too long for
+ its slot slides to its end and back (dashboard.js sets --d and --t). */
+.dash-running { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 12px; flex: none; height: 118px; }
+.dash .slot { container: slot / inline-size; display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto 1fr;
+ column-gap: 14px; row-gap: 4px; align-items: center; padding: 10px 16px 12px; cursor: pointer; }
+.dash .slot .sic { grid-column: 1; grid-row: 1 / 3; font-size: 1.9rem; width: 2.4rem; color: var(--udt-accent); }
+.dash .slot .rec { color: var(--udt-red); }
+.dash .slot .what { grid-column: 2; font-weight: 600; white-space: nowrap; overflow: hidden; }
+.dash .slot .pct { grid-column: 3; justify-self: end; font-size: 1.25rem; font-weight: 600; white-space: nowrap; }
+.dash .slot .meta { grid-column: 2; font-size: 0.786rem; color: var(--udt-subtext0); white-space: nowrap; overflow: hidden; }
+.dash .slot .what > span, .dash .slot .meta > span { display: inline-block; }
+.dash .slot .marq { -webkit-mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 12px), transparent);
+ mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 12px), transparent); }
+.dash .slot .marq > span { animation: marq var(--t) ease-in-out infinite alternate; }
+@keyframes marq { 0%, 15% { transform: translateX(0); } 85%, 100% { transform: translateX(var(--d)); } }
+.dash .slot .act { grid-column: 3; grid-row: 2; justify-self: end; min-height: 0; height: 26px; padding: 0 10px; border-radius: 10px;
+ font-size: 0.786rem; background: transparent; border: 1px solid var(--udt-red); color: var(--udt-red); }
+.dash .slot .estop.act { width: auto; flex-direction: row; gap: 6px; }
+.dash .slot .estop.act .estop-label { font-size: 0.714rem; }
+.dash .slot .bar { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--udt-surface0); overflow: hidden; align-self: end; }
+.dash .slot .bar i { display: block; height: 100%; width: 0;
+ background: linear-gradient(90deg, var(--udt-border-1), var(--udt-border-2), var(--udt-border-3)); }
+.dash .slot .bar.busy i { width: 30%; animation: slot-busy 1.6s ease-in-out infinite alternate; }
+@keyframes slot-busy { from { margin-left: 0; } to { margin-left: 70%; } }
+.dash .slot .sthumb { display: none; }
+@container slot (min-width: 700px) {
+ .dash .slot .sthumb:not([hidden]) { display: block; grid-column: 1; grid-row: 1 / 3; width: 56px; height: 56px; object-fit: contain; }
+ .dash .slot:has(.sthumb:not([hidden])) .sic { display: none; }
+}
+
+/* Action icons, each in Hyprland's rotating border. */
+.dash-acts { display: flex; justify-content: center; align-items: center; gap: 28px; min-height: 0; }
+.dash-acts button { position: relative; height: 100%; max-height: 64px; aspect-ratio: 1; border-radius: 16px; font-size: 1.7rem; line-height: 1;
+ background: var(--udt-surface0); border: 0; color: var(--udt-text); }
+.dash-acts button.fail { color: var(--udt-red); }
+/* The same rotating three-hue gradient Hyprland draws on window borders,
+ read from ~/.cache/udt/udt-border.lua via /theme.css. */
+.dash-acts button::before {
+ content: "";
+ position: absolute;
+ inset: 0;
+ border-radius: inherit;
+ padding: 2px;
+ background: linear-gradient(var(--border-angle),
+ var(--udt-border-1), var(--udt-border-2), var(--udt-border-3), var(--udt-border-1));
+ -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
+ -webkit-mask-composite: xor;
+ mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
+ mask-composite: exclude;
+ pointer-events: none;
+ /* Hyprland: speed 30 * 100 ms, flatlinetwo = linear, style = loop */
+ animation: border-rotate 3s linear infinite;
+}
diff --git a/static/index.html b/static/index.html
index fe5a8c6..bb27c19 100644
--- a/static/index.html
+++ b/static/index.html
@@ -29,7 +29,6 @@
<link rel="manifest" href="manifest.json">
<link rel="icon" href="icon-192.png">
<link rel="apple-touch-icon" href="icon-192.png">
-<link rel="stylesheet" href="vendor/gridstack/gridstack.min.css">
<link rel="stylesheet" href="theme.css">
<link rel="stylesheet" href="deck.css">
<title>deck-it</title>
@@ -45,7 +44,6 @@
<div class="off-title" id="asleep-title"></div>
<div class="off-detail">The dashboard comes back when it answers again. Until then the tablet can sleep too.</div>
</div>
-<script src="vendor/gridstack/gridstack-all.js"></script>
<script type="module" src="app.js"></script>
</body>
</html>
diff --git a/static/modules/k1c.js b/static/modules/k1c.js
index d8211fa..261ef4d 100644
--- a/static/modules/k1c.js
+++ b/static/modules/k1c.js
@@ -86,6 +86,37 @@ function armHold(btn) {
btn.style.setProperty("--hold", `${HOLD_MS}ms`);
}
+// The dashboard's running slot: file, percent, time left, layer and
+// temperatures, the press-and-hold stop and a progress bar. Wide slots show
+// the slicer thumbnail in place of the icon (deck.css container query).
+export const busy = (st) => !st.offline && (st.state === "printing" || st.state === "paused");
+
+export function slot(st, el) {
+ if (!el.firstChild) {
+ el.innerHTML = `<i class="nf sic"></i><img class="sthumb" alt="" hidden>
+ <span class="what"><span></span></span><span class="pct num"></span>
+ <span class="meta"><span></span></span>
+ <button class="estop act" aria-label="Emergency stop: press and hold">
+ <span class="estop-label">Emergency stop</span><span class="estop-hint">hold</span>
+ </button>
+ <div class="bar"><i></i></div>`;
+ armHold(el.querySelector(".estop"));
+ }
+ const p = st.progress ?? 0;
+ const name = (st.file ?? "").split("/").pop();
+ el.querySelector(".what > span").textContent = st.state === "paused" ? `Paused · ${name}` : name;
+ el.querySelector(".pct").textContent = `${Math.round(p * 100)}%`;
+ el.querySelector(".meta > span").textContent = [
+ `${dur(st.remaining)} left`,
+ st.layers ? `layer ${st.layer ?? "?"}/${st.layers}` : null,
+ `${temp(st.extruder)} / ${temp(st.bed)}`,
+ ].filter(Boolean).join(" · ");
+ el.querySelector(".bar i").style.width = `${p * 100}%`;
+ const thumb = el.querySelector(".sthumb");
+ thumb.hidden = !st.thumbnail;
+ if (st.thumbnail && thumb.getAttribute("src") !== st.thumbnail) thumb.src = st.thumbnail;
+}
+
export default {
title: "K1C",
tab: "K1C",
diff --git a/static/modules/llm.js b/static/modules/llm.js
deleted file mode 100644
index 1bbbcce..0000000
--- a/static/modules/llm.js
+++ /dev/null
@@ -1,125 +0,0 @@
-// deck-it - llm panel
-// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License version 2 as
-// published by the Free Software Foundation.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-import { offline } from "../offline.js";
-
-const num = (v) => (v == null ? null : Number(v));
-const money = (v) => (num(v) == null ? "—" : `$${num(v).toFixed(2)}`);
-const tokens = (n) => {
- if (n == null) return "—";
- if (n >= 1e9) return `${(n / 1e9).toFixed(1)}B`;
- if (n >= 1e6) return `${(n / 1e6).toFixed(1)}M`;
- if (n >= 1e3) return `${(n / 1e3).toFixed(1)}k`;
- return String(n);
-};
-
-const CLAUDE_ICON = '<span class="brand claude"></span>';
-const OPENCODE_ICON = '<span class="brand opencode"></span>';
-const AGENT_ICON = '<i class="nf brand-nf">\uf086</i>';
-
-function section(icon, title, model) {
- const sec = document.createElement("section");
- sec.className = "llm-sec";
- const head = document.createElement("header");
- head.className = "llm-head";
- head.innerHTML = `${icon}<h3></h3><span class="model"></span>`;
- head.querySelector("h3").textContent = title;
- head.querySelector(".model").textContent = model || "—";
- sec.append(head);
- return sec;
-}
-
-function gauge(label, value) {
- const d = document.createElement("div");
- d.className = "gauge";
- const l = document.createElement("span");
- l.className = "glabel";
- l.textContent = label;
- const v = document.createElement("span");
- v.className = "gvalue num";
- v.textContent = value == null ? "—" : `${Math.round(value)}%`;
- const bar = document.createElement("div");
- bar.className = "gbar";
- const fill = document.createElement("i");
- fill.style.width = `${Math.max(0, Math.min(100, value || 0))}%`;
- bar.append(fill);
- d.append(l, v, bar);
- return d;
-}
-
-function stat(label, value, sub) {
- const d = document.createElement("div");
- d.className = "lbig";
- const l = document.createElement("span");
- l.className = "mlabel";
- l.textContent = label;
- const v = document.createElement("span");
- v.className = "mvalue num";
- v.textContent = value;
- const s = document.createElement("span");
- s.className = "msub";
- s.textContent = sub || "";
- d.append(l, v, s);
- return d;
-}
-
-export default {
- title: "LLM usage",
- interval: 5,
-
- mount(el) {
- el.innerHTML = `<div class="llm"></div>`;
- },
-
- update(state, el) {
- const box = el.querySelector(".llm");
- if (state.offline) {
- offline(box, {
- icon: "/logos/claude.svg",
- title: "Usage dashboard is off",
- detail: "Start llm-cost-dashboard and Claude, opencode and assistant usage appear here.",
- });
- return;
- }
- box.textContent = "";
- const c = state.claude ?? {};
- const o = state.opencode ?? {};
-
- const claude = section(CLAUDE_ICON, "Claude Code", c.model);
- const gauges = document.createElement("div");
- gauges.className = "gauges";
- gauges.append(
- gauge("Context", c.context_pct),
- gauge("5h", c.five_hour_pct),
- gauge("7d", c.seven_day_pct),
- );
- claude.append(gauges);
- box.append(claude);
-
- for (const [icon, title, p] of [[OPENCODE_ICON, "opencode", o],
- [AGENT_ICON, "Local Agent", state.assistant ?? {}]]) {
- const sec = section(icon, title, p.model);
- const pair = document.createElement("div");
- pair.className = "lpair";
- pair.append(
- stat("session", money(p.session_cost), `${tokens(p.session_tokens)} · ${p.session_calls ?? 0} calls`),
- stat("total", money(p.cost), `${tokens(p.tokens)} · ${p.calls ?? 0} calls`),
- );
- sec.append(pair);
- box.append(sec);
- }
- },
-};
diff --git a/static/modules/obs.js b/static/modules/obs.js
index 6842522..bcf237b 100644
--- a/static/modules/obs.js
+++ b/static/modules/obs.js
@@ -54,6 +54,26 @@ async function post(action, body = {}) {
}
}
+// The dashboard's running slot: what is live, the scene and the elapsed
+// time, and a stop for it.
+export const busy = (st) => Boolean(st.connected && (st.recording || st.streaming));
+
+export function slot(st, el) {
+ if (!el.firstChild) {
+ el.innerHTML = `<i class="nf sic rec"></i>
+ <span class="what"><span></span></span><span class="pct num"></span>
+ <span class="meta"><span></span></span>
+ <button class="act">Stop</button>`;
+ }
+ const what = st.recording ? (st.paused ? "Recording paused" : "Recording") : "Streaming";
+ el.querySelector(".what > span").textContent = `${what} · ${st.currentScene ?? ""}`;
+ el.querySelector(".pct").textContent = st.recording ? clock(st.recordingTime) : "live";
+ el.querySelector(".meta > span").textContent =
+ [st.recording ? "recording" : null, st.streaming ? "streaming" : null].filter(Boolean).join(" + ");
+ el.querySelector(".act").onclick = () =>
+ post(st.recording ? "record" : "stream", { on: false });
+}
+
function bigButton(kind, name, label, on, times) {
const b = document.createElement("button");
b.className = `deck-btn ${kind}${on ? " on" : ""}`;
diff --git a/static/modules/sbbuilder.js b/static/modules/sbbuilder.js
index 6285dd5..357133f 100644
--- a/static/modules/sbbuilder.js
+++ b/static/modules/sbbuilder.js
@@ -1,4 +1,4 @@
-// deck-it - sbbuilder panel
+// deck-it - the build VM's running slot
// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
//
// This program is free software; you can redistribute it and/or modify
@@ -14,80 +14,27 @@
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-import { offline } from "../offline.js";
+// The build VM has no tab: on the Dashboard it is a running slot while a job
+// is active, and nothing otherwise.
-const gib = (b) => (b == null ? "?" : (b / 1073741824).toFixed(1));
-const pct = (n) => (n == null ? "?" : `${Math.round(n)}%`);
-const ago = (ts) => {
- if (!ts) return "—";
- const d = Math.max(0, Math.floor(Date.now() / 1000 - ts));
- if (d < 3600) return `${Math.floor(d / 60)}m`;
- if (d < 86400) return `${Math.floor(d / 3600)}h`;
- return `${Math.floor(d / 86400)}d`;
-};
+export const interval = 10; // each poll is an ssh round trip
const ACTIVE = ["running", "busy", "starting"];
-
-function tile(label, value, sub) {
- const d = document.createElement("div");
- d.className = "mtile";
- const l = document.createElement("span");
- l.className = "mlabel";
- l.textContent = label;
- const v = document.createElement("span");
- v.className = "mvalue num";
- v.textContent = value;
- const s = document.createElement("span");
- s.className = "msub";
- s.textContent = sub || "";
- d.append(l, v, s);
- return d;
+const active = (st) => (st.jobs ?? []).filter((j) => ACTIVE.includes(j.status));
+
+export const busy = (st) => !st.offline && active(st).length > 0;
+
+export function slot(st, el) {
+ if (!el.firstChild) {
+ el.innerHTML = `<i class="nf sic"></i>
+ <span class="what"><span></span></span><span class="pct num"></span>
+ <span class="meta"><span></span></span>
+ <div class="bar busy"><i></i></div>`;
+ }
+ const jobs = active(st);
+ const load = st.stats?.load;
+ el.querySelector(".what > span").textContent = `Build VM · ${jobs[0]?.kind || "job"}`;
+ el.querySelector(".pct").textContent = jobs.length > 1 ? `${jobs.length} jobs` : "";
+ el.querySelector(".meta > span").textContent =
+ [jobs[0]?.status, load ? `load ${load[0].toFixed(2)}` : null].filter(Boolean).join(" · ");
}
-
-export default {
- title: "Build VM",
- interval: 10,
-
- mount(el) {
- el.innerHTML = `<div class="sbb"></div>`;
- },
-
- update(state, el) {
- const box = el.querySelector(".sbb");
- if (state.offline) {
- offline(box, {
- icon: "/icons/virt-manager.svg",
- title: "Build VM is off",
- detail: "Start the VM and its jobs and package counts appear here.",
- });
- return;
- }
- box.textContent = "";
- const s = state.stats ?? {};
- const p = s.packages ?? {};
- const sr = s.slackrepo ?? {};
- const results = sr.results ?? {};
- const jobs = state.jobs ?? [];
- const running = jobs.find((j) => ACTIVE.includes(j.status));
-
- const now = document.createElement("div");
- now.className = "sbb-now";
- now.textContent = running ? `● ${running.kind || "job"}` : "idle";
- now.classList.toggle("warn", Boolean(running));
- box.append(now);
-
- const overlays = Object.entries(p).filter(([k]) => k !== "total" && k !== "shadowed");
- box.append(
- tile("Packages", String(p.total ?? "?"), overlays.map(([k, v]) => `${k} ${v}`).join(" · ")),
- tile("Failed", String(results.failed ?? 0), `${sr.built ?? "?"} built`),
- tile("Disk free", `${gib(s.disk?.free)}`, `of ${gib(s.disk?.total)} GiB`),
- tile("CPU", pct(s.cpu), `load ${s.load ? s.load[0].toFixed(2) : "?"}`),
- );
-
- const foot = document.createElement("div");
- foot.className = "mfoot";
- foot.textContent = `orphans ${s.orphans ?? "?"} · ${
- Object.entries(s.sync ?? {}).map(([k, v]) => `${k} ${ago(v)}`).join(" · ") || "no pulls"}`;
- box.append(foot);
- },
-};
diff --git a/static/modules/stats.js b/static/modules/stats.js
deleted file mode 100644
index 0e35a91..0000000
--- a/static/modules/stats.js
+++ /dev/null
@@ -1,79 +0,0 @@
-// deck-it - stats panel
-// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License version 2 as
-// published by the Free Software Foundation.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-const gib = (kb) => (kb / 1048576).toFixed(1);
-const bytes = (b) => (b == null ? "?" : (b / 1073741824).toFixed(1));
-const rate = (b) => (b >= 1048576 ? `${(b / 1048576).toFixed(1)}M` : `${Math.round(b / 1024)}k`);
-const uptime = (s) => {
- const d = Math.floor(s / 86400);
- const h = Math.floor((s % 86400) / 3600);
- return d ? `${d}d ${h}h` : `${h}h`;
-};
-
-// Nerd Font distro logos; anything else gets Tux.
-const DISTRO = {
- slackware: "\uf318", arch: "\uf303", debian: "\uf306", fedora: "\uf30a",
- ubuntu: "\uf31b", gentoo: "\uf30d", opensuse: "\uf314", void: "\uf32e",
-};
-
-function tile(label, value, sub) {
- const d = document.createElement("div");
- d.className = "mtile";
- const l = document.createElement("span");
- l.className = "mlabel";
- l.textContent = label;
- const v = document.createElement("span");
- v.className = "mvalue num";
- v.textContent = value;
- const s = document.createElement("span");
- s.className = "msub";
- s.textContent = sub || "";
- d.append(l, v, s);
- return d;
-}
-
-export default {
- title: "System",
- interval: 1,
-
- mount(el) {
- el.innerHTML = `<div class="stats"></div>`;
- },
-
- update(st, el) {
- const box = el.querySelector(".stats");
- box.textContent = "";
- const g = st.gpu;
- box.append(
- tile(st.cpuName ?? "CPU", `${st.cpu}%`, st.cpuTemp != null ? `${st.cpuTemp}°C` : "—"),
- tile("Memory", gib(st.memUsed), `/ ${gib(st.memTotal)} GiB`),
- tile(g?.name ?? "GPU", g?.temp != null ? `${g.temp}°` : "—",
- g ? `${bytes(g.memUsed)} / ${bytes(g.memTotal)} GiB` : "no GPU"),
- tile("Network", `↓${rate(st.net.down)} ↑${rate(st.net.up)}`),
- );
- const os = st.os ?? {};
- const sys = document.createElement("div");
- sys.className = "mtile msys";
- sys.innerHTML = `<i class="nf"></i><div><span class="mvalue"></span><span class="msub"></span></div>
- <div class="mup"><span class="mlabel">uptime</span><span class="mvalue num"></span></div>`;
- sys.querySelector("i").textContent = DISTRO[os.id] ?? "\uf17c";
- sys.querySelector("div .mvalue").textContent = os.name ?? "Linux";
- sys.querySelector(".msub").textContent =
- [os.codename, `Linux ${os.kernel ?? ""}`].filter(Boolean).join(" · ");
- sys.querySelector(".mup .mvalue").textContent = uptime(st.uptime);
- box.append(sys);
- },
-};
diff --git a/static/modules/tablet.js b/static/modules/tablet.js
deleted file mode 100644
index cb38416..0000000
--- a/static/modules/tablet.js
+++ /dev/null
@@ -1,77 +0,0 @@
-// deck-it - tablet panel
-// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License version 2 as
-// published by the Free Software Foundation.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-// The tablet's battery and Wi-Fi, in the System card's tile style.
-
-import { offline } from "../offline.js";
-
-function tile(label, value, sub, cls = "", badge = "") {
- const d = document.createElement("div");
- d.className = "mtile";
- d.innerHTML = `<span class="mlabel"></span><span class="mvalue num ${cls}"></span><span class="msub"></span>`;
- d.children[0].textContent = label;
- d.children[0].insertAdjacentHTML("beforeend", badge);
- d.children[1].textContent = value;
- d.children[2].textContent = sub || "";
- return d;
-}
-
-// Four bars in the label, lit by Android's thresholds: -55 dBm and up is full.
-function bars(rssi) {
- const n = rssi == null ? 0 : rssi >= -55 ? 4 : rssi >= -66 ? 3 : rssi >= -77 ? 2 : 1;
- const rects = [0, 1, 2, 3].map((i) =>
- `<rect x="${i * 4}" y="${9 - i * 3}" width="3" height="${3 + i * 3}" rx="1"${i < n ? ' class="lit"' : ""}/>`);
- return `<svg class="bars" viewBox="0 0 15 12" aria-hidden="true">${rects.join("")}</svg>`;
-}
-
-export default {
- title: "Tablet",
- interval: 10,
-
- mount(el) {
- el.innerHTML = `<div class="tablet"><div class="stats"></div></div>`;
- },
-
- update(st, el) {
- const box = el.querySelector(".stats");
- if (!st.connected) {
- offline(box, {
- icon: "/icons/smartphone.svg",
- title: "Tablet not reachable over adb",
- detail: "Its battery and Wi-Fi show here once deck-it's tunnel is up.",
- reason: st.error,
- });
- return;
- }
- box.textContent = "";
- const b = st.battery;
- const w = st.wifi;
- const low = b.level <= 20 && b.status !== "charging";
- box.append(
- tile("Battery", `${b.level}%`,
- [b.status, b.plug, b.temp != null ? `${b.temp}°C` : ""].filter(Boolean).join(" · "),
- low ? "bad" : b.status === "charging" ? "good" : ""),
- w.connected
- ? tile("Wi-Fi", `${w.rssi ?? "?"} dBm`,
- [w.ssid, w.band, w.speed ? `${w.speed} Mbps` : ""].filter(Boolean).join(" · "), "", bars(w.rssi))
- : tile("Wi-Fi", "off", "not connected", "warn"),
- );
- const foot = document.createElement("div");
- foot.className = "mfoot";
- foot.textContent = `linked over ${st.link}`;
- box.append(foot);
- },
-};
diff --git a/static/vendor/gridstack/gridstack-all.js b/static/vendor/gridstack/gridstack-all.js
deleted file mode 100644
index 496dc55..0000000
--- a/static/vendor/gridstack/gridstack-all.js
+++ /dev/null
@@ -1,3 +0,0 @@
-/*! For license information please see gridstack-all.js.LICENSE.txt */
-!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.GridStack=e():t.GridStack=e()}(self,()=>(()=>{"use strict";var t={d:(e,i)=>{for(var s in i)t.o(i,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:i[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{GridStack:()=>x});class i{static getElements(t,e=document){if("string"==typeof t){const i="getElementById"in e?e:void 0;if(i&&!isNaN(+t[0])){const e=i.getElementById(t);return e?[e]:[]}let s=e.querySelectorAll(t);if(!s.length&&"."!==t[0]&&"#"!==t[0]&&(s=e.querySelectorAll("."+t),s.length||(s=e.querySelectorAll("#"+t)),!s.length)){const i=e.querySelector(`[gs-id="${t}"]`);return i?[i]:[]}return Array.from(s)}return[t]}static getElement(t,e=document){if("string"==typeof t){const i="getElementById"in e?e:void 0;if(!t.length)return null;if(i&&"#"===t[0])return i.getElementById(t.substring(1));if("#"===t[0]||"."===t[0]||"["===t[0])return e.querySelector(t);if(i&&!isNaN(+t[0]))return i.getElementById(t);let s=e.querySelector(t);return i&&!s&&(s=i.getElementById(t)),s||(s=e.querySelector("."+t)),s}return t}static lazyLoad(t){return!!(t.lazyLoad||t.grid?.opts?.lazyLoad&&!1!==t.lazyLoad)}static createDiv(t,e){const i=document.createElement("div");return t.forEach(t=>{t&&i.classList.add(t)}),e?.appendChild(i),i}static shouldSizeToContent(t,e=!1){return!(!t?.grid||!(e?!0===t.sizeToContent||!0===t.grid.opts.sizeToContent&&void 0===t.sizeToContent:t.sizeToContent||t.grid.opts.sizeToContent&&!1!==t.sizeToContent))}static isIntercepted(t,e){return!(t.y>=e.y+e.h||t.y+t.h<=e.y||t.x+t.w<=e.x||t.x>=e.x+e.w)}static isTouching(t,e){return i.isIntercepted(t,{x:e.x-.5,y:e.y-.5,w:e.w+1,h:e.h+1})}static areaIntercept(t,e){const i=t.x>e.x?t.x:e.x,s=t.x+t.w<e.x+e.w?t.x+t.w:e.x+e.w;if(s<=i)return 0;const o=t.y>e.y?t.y:e.y,n=t.y+t.h<e.y+e.h?t.y+t.h:e.y+e.h;return n<=o?0:(s-i)*(n-o)}static area(t){return t.w*t.h}static sort(t,e=1){const i=Number.MAX_SAFE_INTEGER;return t.sort((t,s)=>{const o=e*((t.y??i)-(s.y??i));return 0===o?e*((t.x??i)-(s.x??i)):o})}static find(t,e){return e?t.find(t=>t.id===e):void 0}static findInGrid(t,e,s){const o=t.engine.nodes.find(t=>String(t.id)===e);if(o||!s)return o;for(const s of t.engine.nodes)if(s.subGrid){const t=i.findInGrid(s.subGrid,e);if(t)return t}}static toBool(t){return"boolean"==typeof t?t:"string"==typeof t?!(""===(t=t.toLowerCase())||"no"===t||"false"===t||"0"===t):Boolean(t)}static toNumber(t){return null===t||0===t.length?void 0:Number(t)}static parseHeight(t){let e,i="px";if("string"==typeof t)if("auto"===t||""===t)e=0;else{const s=t.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%|cm|mm)?$/);if(!s)throw new Error(`Invalid height val = ${t}`);i=s[2]||"px",e=parseFloat(s[1])}else e=t;return{h:e,unit:i}}static defaults(t,...e){return e.forEach(e=>{for(const s in e){if(!Object.prototype.hasOwnProperty.call(e,s))return;null===t[s]||void 0===t[s]?t[s]=e[s]:"object"==typeof e[s]&&"object"==typeof t[s]&&i.defaults(t[s],e[s])}}),t}static same(t,e){if("object"!=typeof t)return t==e;if(typeof t!=typeof e)return!1;const i=t,s=e;if(Object.keys(i).length!==Object.keys(s).length)return!1;for(const t in i)if(i[t]!==s[t])return!1;return!0}static copyPos(t,e,i=!1){return void 0!==e.x&&(t.x=e.x),void 0!==e.y&&(t.y=e.y),void 0!==e.w&&(t.w=e.w),void 0!==e.h&&(t.h=e.h),i&&(e.minW&&(t.minW=e.minW),e.minH&&(t.minH=e.minH),e.maxW&&(t.maxW=e.maxW),e.maxH&&(t.maxH=e.maxH)),t}static samePos(t,e){return t&&e&&t.x===e.x&&t.y===e.y&&(t.w||1)===(e.w||1)&&(t.h||1)===(e.h||1)}static sanitizeMinMax(t){t.minW||delete t.minW,t.minH||delete t.minH,t.maxW||delete t.maxW,t.maxH||delete t.maxH}static removeInternalAndSame(t,e){if("object"!=typeof t||"object"!=typeof e)return;if(!t||!e)return;if(Array.isArray(t)||Array.isArray(e))return;const s=t,o=e;for(const t in s){const e=s[t],n=o[t];"_"===t[0]||e===n?delete s[t]:e&&"object"==typeof e&&void 0!==n&&(i.removeInternalAndSame(e,n),Object.keys(e).length||delete s[t])}}static removeInternalForSave(t,e=!0){const i=t;for(const t in i)"_"!==t[0]&&null!==i[t]&&void 0!==i[t]||delete i[t];delete t.grid,e&&delete t.el,t.autoPosition||delete t.autoPosition,t.noResize||delete t.noResize,t.noMove||delete t.noMove,t.locked||delete t.locked,1!==t.w&&t.w!==t.minW||delete t.w,1!==t.h&&t.h!==t.minH||delete t.h}static throttle(t,e){let i=!1;return(...s)=>{i||(i=!0,setTimeout(()=>{t(...s),i=!1},e))}}static removePositioningStyles(t){const e=t.style;e.position&&e.removeProperty("position"),e.left&&e.removeProperty("left"),e.top&&e.removeProperty("top"),e.width&&e.removeProperty("width"),e.height&&e.removeProperty("height")}static getVisibleViewport(){const t="undefined"!=typeof window?window.visualViewport:void 0;return t?{top:t.offsetTop,bottom:t.offsetTop+t.height}:{top:0,bottom:window.innerHeight||document.documentElement.clientHeight}}static getScrollElement(t){if(!t)return document.scrollingElement||document.documentElement;const e=getComputedStyle(t).overflowY;return("auto"===e||"scroll"===e)&&t.scrollHeight>t.clientHeight?t:i.getScrollElement(t.parentElement??void 0)}static updateScrollResize(t,e,s){const o=i.getScrollElement(e),n=o.clientHeight,r=o===i.getScrollElement()?0:o.getBoundingClientRect().top,l=t.clientY-r,a=l>n-s;l<s?o.scrollBy({behavior:"smooth",top:l-s}):a&&o.scrollBy({behavior:"smooth",top:s-(n-l)})}static pauseIframePointerEvents(t){document.querySelectorAll("iframe").forEach(e=>{e.style.pointerEvents=t?"none":""})}static clone(t){return null==t||"object"!=typeof t?t:t instanceof Array?[...t]:{...t}}static cloneDeep(t){const e=["parentGrid","el","grid","subGrid","engine"],s=i.clone(t);for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&"object"==typeof s[o]&&"__"!==o.substring(0,2)&&!e.find(t=>t===o)&&(s[o]=i.cloneDeep(t[o]));return s}static cloneNode(t){const e=t.cloneNode(!0);return e.removeAttribute("id"),e}static appendTo(t,e){let s;s="string"==typeof e?i.getElement(e):e,s&&s.appendChild(t)}static addElStyles(t,e){if(e instanceof Object){const i=t.style;for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(Array.isArray(e[t])?e[t].forEach(e=>{i[t]=e}):i[t]=e[t])}}static initEvent(t,e){const i={type:e.type},s={button:0,which:0,buttons:1,bubbles:!0,cancelable:!0,target:e.target?e.target:t.target},o=t;return["altKey","ctrlKey","metaKey","shiftKey"].forEach(t=>i[t]=o[t]),["pageX","pageY","clientX","clientY","screenX","screenY"].forEach(t=>i[t]=o[t]),{...i,...s}}static simulateMouseEvent(t,e,i){const s=t,o=new MouseEvent(e,{bubbles:!0,composed:!0,cancelable:!0,view:window,detail:1,screenX:t.screenX,screenY:t.screenY,clientX:t.clientX,clientY:t.clientY,ctrlKey:s.ctrlKey??!1,altKey:s.altKey??!1,shiftKey:s.shiftKey??!1,metaKey:s.metaKey??!1,button:0,relatedTarget:t.target});(i||t.target).dispatchEvent(o)}static getValuesFromTransformedElement(t){const e=1e3,s=document.createElement("div");i.addElStyles(s,{opacity:"0",position:"fixed",top:"0px",left:"0px",width:e+"px",height:e+"px",zIndex:"-999999"}),t.appendChild(s);const o=s.getBoundingClientRect();return t.removeChild(s),s.remove(),{xScale:e/o.width,yScale:e/o.height,xOffset:o.left,yOffset:o.top}}static swap(t,e,i){if(!t)return;const s=t,o=s[e];s[e]=s[i],s[i]=o}static canBeRotated(t){return!(!t||t.w===t.h||t.locked||t.noResize||t.grid?.opts.disableResize||t.minW&&t.minW===t.maxW||t.minH&&t.minH===t.maxH)}}class s{constructor(t={}){this.addedNodes=[],this.removedNodes=[],this.defaultColumn=12,this.column=t.column||this.defaultColumn,this.column>this.defaultColumn&&(this.defaultColumn=this.column),this.maxRow=t.maxRow??0,this._mode=t.mode||"top",this.nodes=t.nodes||[],this.onChange=t.onChange??(()=>{})}batchUpdate(t=!0,e=!0){return!!this.batchMode===t||(this.batchMode=t,t?(this._prevMode=this._mode,this._mode="float",this.cleanNodes(),this.nodes.some(t=>t._updating)||this.saveInitial()):(this._mode=this._prevMode||"top",delete this._prevMode,e&&this._packNodes(),this._notify())),this}get _realMode(){return this.batchMode?this._prevMode||"top":this.mode}_useEntireRowArea(t,e){return("float"!==this.mode||this.batchMode&&"float"!==this._prevMode)&&!this._hasLocked&&(!t._moving||t._skipDown||e.y<=t.y)}_fixCollisions(t,e=t,s,o={}){if(this.sortNodes(-1),!(s=s||this.collide(t,e)))return!1;if(t._moving&&!t._isExternal&&!o.nested&&"float"!==this.mode&&this.swap(t,s))return!0;let n=e;!this._loading&&this._useEntireRowArea(t,e)&&(n={x:0,w:this.column,y:e.y,h:e.h},s=this.collide(t,n,o.skip));let r=!1;const l={nested:!0,pack:!1};let a=0;for(;s=s||this.collide(t,n,o.skip);){if(a++>2*this.nodes.length)throw new Error("Infinite collide check");let n;if(s.locked||this._loading||t._moving&&!t._skipDown&&e.y>t.y&&"float"!==this.mode&&(!this.collide(s,{...s,y:t.y},t)||!this.collide(s,{...s,y:e.y-s.h},t))){t._skipDown=t._skipDown||e.y>t.y;const a={...e,y:s.y+s.h,...l};n=!(!this._loading||!i.samePos(t,a))||this.moveNode(t,a),(s.locked||this._loading)&&n?i.copyPos(e,t):!s.locked&&n&&o.pack&&(this._packNodes(),e.y=s.y+s.h,i.copyPos(t,e)),r=r||n}else n=this.moveNode(s,{...s,y:e.y+e.h,skip:t,...l});if(!n)return r;s=void 0}return r}collide(t,e=t,s){const o=t._id,n=s?._id;return this.nodes.find(t=>t._id!==o&&t._id!==n&&i.isIntercepted(t,e))}collideAll(t,e=t,s){const o=t._id,n=s?._id;return this.nodes.filter(t=>t._id!==o&&t._id!==n&&i.isIntercepted(t,e))}directionCollideCoverage(t,e,i){if(!e.rect||!t._rect)return;const s=t._rect,o={...e.rect};let n;o.y>s.y?(o.h=o.h+o.y-s.y,o.y=s.y):o.h=o.h+s.y-o.y,o.x>s.x?(o.w=o.w+o.x-s.x,o.x=s.x):o.w=o.w+s.x-o.x;let r=.5;for(const t of i){if(t.locked||!t._rect)continue;const e=t._rect;let i=Number.MAX_VALUE,l=Number.MAX_VALUE;s.y<e.y?i=(o.y+o.h-e.y)/e.h:s.y+s.h>e.y+e.h&&(i=(e.y+e.h-o.y)/e.h),s.x<e.x?l=(o.x+o.w-e.x)/e.w:s.x+s.w>e.x+e.w&&(l=(e.x+e.w-o.x)/e.w);const a=Math.min(l,i);a>r&&(r=a,n=t)}return e.collide=n,n}cacheRects(t,e,i,s,o,n){return this.nodes.forEach(r=>r._rect={y:r.y*e+i,x:r.x*t+n,w:r.w*t-n-s,h:r.h*e-i-o}),this}swap(t,e){if(!e||e.locked||!t||t.locked)return!1;function s(){const i=e.x,s=e.y;return e.x=t.x,e.y=t.y,t.h!=e.h?(t.x=i,t.y=e.y+e.h):t.w!=e.w?(t.x=e.x+e.w,t.y=s):(t.x=i,t.y=s),t._dirty=e._dirty=!0,!0}let o;if(t.w===e.w&&t.h===e.h&&(t.x===e.x||t.y===e.y)&&(o=i.isTouching(t,e)))return s();if(!1!==o){if(t.w===e.w&&t.x===e.x&&(o||(o=i.isTouching(t,e)))){if(e.y<t.y){const i=t;t=e,e=i}return s()}if(!1!==o){if(t.h===e.h&&t.y===e.y&&(o||(o=i.isTouching(t,e)))){if(e.x<t.x){const i=t;t=e,e=i}return s()}return!1}}}isAreaEmpty(t,e,i,s){const o={x:t||0,y:e||0,w:i||1,h:s||1};return!this.collide(o)}compact(t="compact",e=!0){if(0===this.nodes.length)return this;const i=this.batchMode;return i||this.batchUpdate(),this._relayout(t,e),i||this.batchUpdate(!1),this}_relayout(t,e=!0){if(0===this.nodes.length)return this;e&&this.sortNodes();const i=this._inColumnResize;i||(this._inColumnResize=!0);const s=this.nodes;this.nodes=s.filter(t=>t.locked);const o=new Set;let n=0;const r=t=>{for(let e=t.y;e<t.y+t.h;e++)for(let i=t.x;i<t.x+t.w;i++)o.add(e*this.column+i);for(;o.has(n);)++n};return this.nodes.forEach(r),s.forEach((e,i,s)=>{if(e.locked)return;e.autoPosition=!0;const o="list"===t?i?s[i-1]:0:n;this.addNode(e,!1,o),r(e)}),i||delete this._inColumnResize,this}set mode(t){this._mode!==t&&(this._mode=t||"top","float"!==this._mode&&this._packNodes()._notify())}get mode(){return this._mode||"top"}sortNodes(t=1){return this.nodes=i.sort(this.nodes,t),this}_packNodes(){if(this.batchMode)return this;if(this.sortNodes(),"float"===this.mode)this.nodes.forEach(t=>{if(t._updating||void 0===t._orig||t.y===t._orig.y)return;let e=t.y;for(;e>t._orig.y;)--e,this.collide(t,{x:t.x,y:e,w:t.w,h:t.h})||(t._dirty=!0,t.y=e)});else if("list"===this.mode||"compact"===this.mode){const t="compact"===this.mode&&this.nodes.some(t=>t._updating)?"list":this.mode,e=this.batchMode;this.batchMode=!0,this._relayout(t,!1),this.batchMode=e}else this.nodes.forEach((t,e)=>{if(!t.locked)for(;t.y>0;){const i=0===e?0:t.y-1;if(0!==e&&this.collide(t,{x:t.x,y:i,w:t.w,h:t.h}))break;t._dirty=t.y!==i,t.y=i}});return this}prepareNode(t,e){t._id=t._id??s._idSeq++;const o=t.id;if(o){let e=1;for(;this.nodes.find(e=>e.id===t.id&&e!==t);)t.id=o+"_"+e++}void 0!==t.x&&void 0!==t.y&&null!==t.x&&null!==t.y||(t.autoPosition=!0);const n={x:0,y:0,w:1,h:1};return i.defaults(t,n),t.autoPosition||delete t.autoPosition,t.noResize||delete t.noResize,t.noMove||delete t.noMove,i.sanitizeMinMax(t),"string"==typeof t.x&&(t.x=Number(t.x)),"string"==typeof t.y&&(t.y=Number(t.y)),"string"==typeof t.w&&(t.w=Number(t.w)),"string"==typeof t.h&&(t.h=Number(t.h)),isNaN(t.x)&&(t.x=n.x,t.autoPosition=!0),isNaN(t.y)&&(t.y=n.y,t.autoPosition=!0),isNaN(t.w)&&(t.w=n.w),isNaN(t.h)&&(t.h=n.h),this.nodeBoundFix(t,e),t}nodeBoundFix(t,e){const s=t._orig||i.copyPos({},t);if(void 0===t.x||Number.isFinite(t.x)||(t.x=0),void 0===t.y||Number.isFinite(t.y)||(t.y=0),void 0===t.w||Number.isFinite(t.w)||(t.w=1),void 0===t.h||Number.isFinite(t.h)||(t.h=1),t.maxW&&(t.w=Math.min(t.w||1,t.maxW)),t.maxH&&(t.h=Math.min(t.h||1,t.maxH)),t.minW&&(t.w=Math.max(t.w||1,t.minW)),t.minH&&(t.h=Math.max(t.h||1,t.minH)),(t.x||0)+(t.w||1)>this.column&&this.column<this.defaultColumn&&!this._inColumnResize&&!this.skipCacheUpdate&&null!=t._id&&-1===this.findCacheLayout(t,this.defaultColumn)){const e={...t};e.autoPosition||void 0===e.x?(delete e.x,delete e.y):e.x=Math.min(this.defaultColumn-1,e.x),e.w=Math.min(this.defaultColumn,e.w||1),this.cacheOneLayout(e,this.defaultColumn)}return t.w>this.column?t.w=this.column:t.w<1&&(t.w=1),this.maxRow&&t.h>this.maxRow?t.h=this.maxRow:t.h<1&&(t.h=1),t.x<0&&(t.x=0),t.y<0&&(t.y=0),t.x+t.w>this.column&&(e?t.w=this.column-t.x:t.x=this.column-t.w),this.maxRow&&t.y+t.h>this.maxRow&&(e?t.h=this.maxRow-t.y:t.y=this.maxRow-t.h),i.samePos(t,s)||(t._dirty=!0),this}getDirtyNodes(t){return t?this.nodes.filter(t=>t._dirty&&t._orig&&!i.samePos(t,t._orig)):this.nodes.filter(t=>t._dirty)}_notify(t){if(this.batchMode||!this.onChange)return this;const e=(t||[]).concat(this.getDirtyNodes());return this.onChange(e),this}cleanNodes(){return this.batchMode||this.nodes.forEach(t=>{delete t._dirty,delete t._lastTried}),this}saveInitial(){return this.nodes.forEach(t=>{t._orig=i.copyPos({},t),delete t._dirty}),this._hasLocked=this.nodes.some(t=>t.locked),this}restoreInitial(){return this.nodes.forEach(t=>{t._orig&&!i.samePos(t,t._orig)&&(i.copyPos(t,t._orig),t._dirty=!0)}),this._notify(),this}findEmptyPosition(t,e=this.nodes,s=this.column,o){let n=!1;for(let r="number"==typeof o?o:o?o.y*s+(o.x+o.w):0;!n;++r){const o=r%s,l=Math.floor(r/s);if(o+t.w>s)continue;const a={x:o,y:l,w:t.w,h:t.h};e.find(t=>i.isIntercepted(a,t))||(t.x===o&&t.y===l||(t._dirty=!0),t.x=o,t.y=l,delete t.autoPosition,n=!0)}return n}addNode(t,e=!1,i){const s=this.nodes.find(e=>e._id===t._id);if(s)return s;this._inColumnResize?this.nodeBoundFix(t):this.prepareNode(t),delete t._temporaryRemoved,delete t._removeDOM;let o=!1;return t.autoPosition&&(void 0===i&&"list"===this._realMode&&(i=this.nodes[this.nodes.length-1]),this.findEmptyPosition(t,this.nodes,this.column,i)&&(delete t.autoPosition,o=!0)),o||"list"!==this.mode&&"compact"!==this.mode?this.nodes.push(t):(this.nodes.unshift(t),o=!0),e&&this.addedNodes.push(t),o||this._fixCollisions(t),this.batchMode||this._packNodes()._notify(),t}removeNode(t,e=!0,i=!1){return this.nodes.find(e=>e._id===t._id)?(i&&this.removedNodes.push(t),e&&(t._removeDOM=!0),this.nodes=this.nodes.filter(e=>e._id!==t._id),t._isAboutToRemove||this._packNodes(),this._notify([t]),this):this}removeAll(t=!0,e=!0){if(delete this._layouts,!this.nodes.length)return this;t&&this.nodes.forEach(t=>t._removeDOM=!0);const i=this.nodes;return this.removedNodes=e?i:[],this.nodes=[],this._notify(i)}moveNodeCheck(t,e){if(!this.changedPosConstrain(t,e)&&!e.forceCollide)return!1;if(void 0!==e.pack||this.batchMode||(e.pack=!0),!this.maxRow)return this.moveNode(t,e);let o;const n=new s({column:this.column,mode:this.mode,nodes:this.nodes.map(e=>e._id===t._id?(o={...e},o):{...e})});if(!o)return!1;const r=n.moveNode(o,e)&&n.getRow()<=Math.max(this.getRow(),this.maxRow);if(!r&&!e.resizing&&e.collide&&!t._isExternal){const i=e.collide.el?.gridstackNode;if(i&&this.swap(t,i))return this._notify(),!0}return!!r&&(n.nodes.filter(t=>t._dirty).forEach(t=>{const e=this.nodes.find(e=>e._id===t._id);e&&(i.copyPos(e,t),e._dirty=!0)}),this._notify(),!0)}willItFit(t){if(delete t._willFitPos,!this.maxRow)return!0;const e=new s({column:this.column,mode:this.mode,nodes:this.nodes.map(t=>({...t}))}),o={...t};return this.cleanupNode(o),delete o.el,delete o._id,delete o.content,delete o.grid,e.addNode(o),e.getRow()<=this.maxRow&&(t._willFitPos=i.copyPos({},o),!0)}_makeDynamicSubGrid(t,e,s){if(!s||!t.grid?.opts?.subGridDynamic||t.grid._isTemp||!e.rect||!s._rect)return!1;const o=i.areaIntercept(e.rect,s._rect),n=i.area(e.rect),r=i.area(s._rect);return!(o/(n<r?n:r)<=.8||(s.grid.makeSubGrid(s.el,void 0,t),0))}changedPosConstrain(t,e){return e.w=e.w||t.w,e.h=e.h||t.h,t.x!==e.x||t.y!==e.y||(t.maxW&&(e.w=Math.min(e.w,t.maxW)),t.maxH&&(e.h=Math.min(e.h,t.maxH)),t.minW&&(e.w=Math.max(e.w,t.minW)),t.minH&&(e.h=Math.max(e.h,t.minH)),t.w!==e.w||t.h!==e.h)}moveNode(t,e){if(!t||!e)return!1;let s=!1;void 0!==e.pack||this.batchMode||(s=e.pack=!0),"number"!=typeof e.x&&(e.x=t.x),"number"!=typeof e.y&&(e.y=t.y),"number"!=typeof e.w&&(e.w=t.w),"number"!=typeof e.h&&(e.h=t.h);const o=t.w!==e.w||t.h!==e.h,n=i.copyPos({},t,!0);if(i.copyPos(n,e),this.nodeBoundFix(n,o),i.copyPos(e,n),!e.forceCollide&&i.samePos(t,e))return!1;const r=i.copyPos({},t);if("list"===this.mode||"compact"===this.mode){let o=!1;if(t._moving&&!e.nested&&t.grid?.opts?.subGridDynamic){const i=this.directionCollideCoverage(t,e,this.collideAll(t,n,e.skip));this._makeDynamicSubGrid(t,e,i)&&(o=!0,s&&delete e.pack)}let l=!1;if(!o&&t._moving&&!e.nested&&e.rect&&t._rect){const i=this.collideAll(t,n,e.skip);if(i.length){const s=this.directionCollideCoverage(t,e,i);s?(n.x=s.x,n.y=s.y):l=!0}}if(l)s&&delete e.pack;else if(!o){t._dirty=!0;const e=r.y*this.column+r.x;i.copyPos(t,n);const s=this.nodes.indexOf(t);-1!==s&&(this.nodes.splice(s,1),t.y*this.column+t.x<e?this.nodes.unshift(t):this.nodes.push(t))}}else{const o=this.collideAll(t,n,e.skip);let r=!0;if(o.length){const l=t._moving&&!e.nested;let a=l?this.directionCollideCoverage(t,e,o):o[0];const h=l&&this._makeDynamicSubGrid(t,e,a);if(h&&(a=void 0),a)r=!this._fixCollisions(t,n,a,e);else if(r=!1,s&&delete e.pack,!h&&l&&n.x!==t.x&&n.y!==t.y){const s=Math.abs(n.x-t.x)>=Math.abs(n.y-t.y)?{...n,y:t.y}:{...n,x:t.x},o=this.collideAll(t,s,e.skip),l=o.length?this.directionCollideCoverage(t,e,o):void 0;o.length&&!l||(r=!o.length||!this._fixCollisions(t,s,l,e),r&&i.copyPos(n,s))}}r&&this.collideAll(t,n,e.skip).some(t=>t.locked)&&(r=!1,s&&delete e.pack),r&&!i.samePos(t,n)&&(t._dirty=!0,i.copyPos(t,n))}return e.pack&&this._packNodes()._notify(),!i.samePos(t,r)}getRow(){return this.nodes.reduce((t,e)=>Math.max(t,e.y+e.h),0)}beginUpdate(t){return t._updating||(t._updating=!0,delete t._skipDown,this.batchMode||this.saveInitial()),this}endUpdate(){const t=this.nodes.find(t=>t._updating);return t&&(delete t._updating,delete t._skipDown,"compact"===this.mode&&this._packNodes()._notify()),this}save(t=!0,e,s){const o=this._layouts?.length||0;let n;o&&(s?s!==this.column&&(n=this._layouts[s]):this.column!==o-1&&(n=this._layouts[o-1]));const r=[];return this.sortNodes(),this.nodes.forEach(s=>{const o=n?.find(t=>t._id===s._id),l={...s,...o||{}};i.removeInternalForSave(l,!t),e&&e(s,l),r.push(l)}),r}layoutsNodesChange(t){return!this._layouts||this._inColumnResize||this._layouts.forEach((e,i)=>{if(e&&i!==this.column)if(i<this.column)this._layouts[i]=void 0;else{const s=i/this.column;t.forEach(t=>{if(!t._orig)return;const i=e.find(e=>e._id===t._id);i&&(i.y>=0&&t.y!==t._orig.y&&(i.y=i.y+(t.y-t._orig.y),i.y<0&&(i.y=0)),t.x!==t._orig.x&&(i.x=Math.round(t.x*s),i.x<0&&(i.x=0)),t.w!==t._orig.w&&(i.w=Math.round(t.w*s),i.w<1&&(i.w=1)))})}}),this}columnChanged(t,e,s){if(!this.nodes.length||!e||t===e)return this;const o="compact"===(s=s??("list"===this.mode||"compact"===this.mode?this.mode:"moveScale"))||"list"===s?s:void 0;o&&this.sortNodes(1),e<t&&this.cacheLayout(this.nodes,t),this.batchUpdate();let n=[],r=o?this.nodes:i.sort(this.nodes,-1);if(e>t&&this._layouts){const i=this._layouts[e]||[],s=this._layouts.length-1;!i.length&&t!==s&&this._layouts[s]?.length&&(t=s,this._layouts[s].forEach(t=>{const e=r.find(e=>e._id===t._id);e&&(o||t.autoPosition||(e.x=t.x??e.x,e.y=t.y??e.y),e.w=t.w??e.w,null!=t.x&&void 0!==t.y||(e.autoPosition=!0))})),i.forEach(t=>{const e=r.findIndex(e=>e._id===t._id);if(-1!==e){const i=r[e];if(o)return void(i.w=t.w);(t.autoPosition||isNaN(t.x)||isNaN(t.y))&&this.findEmptyPosition(t,n),t.autoPosition||(i.x=t.x??i.x,i.y=t.y??i.y,i.w=t.w??i.w,n.push(i)),r.splice(e,1)}})}if(o)this.compact(o,!1);else{if(r.length)if("function"==typeof s)s(e,t,n,r);else{const i=o||"none"===s?1:e/t,l="move"===s||"moveScale"===s,a="scale"===s||"moveScale"===s;r.forEach(s=>{s.x=1===e?0:l?Math.round(s.x*i):Math.min(s.x,e-1),s.w=1===e||1===t?1:a?Math.round(s.w*i)||1:Math.min(s.w,e),n.push(s)}),r=[]}n=i.sort(n,-1),this._inColumnResize=!0,this.nodes=[],n.forEach(t=>{this.addNode(t,!1),delete t._orig})}return this.nodes.forEach(t=>delete t._orig),this.batchUpdate(!1,!o),delete this._inColumnResize,this}cacheLayout(t,e,i=!1){const o=[];return t.forEach((t,e)=>{if(void 0===t._id){const e=t.id?this.nodes.find(e=>e.id===t.id):void 0;t._id=e?._id??s._idSeq++}o[e]={x:t.x,y:t.y,w:t.w,_id:t._id}}),this._layouts=i?[]:this._layouts||[],this._layouts[e]=o,this}cacheOneLayout(t,e){t._id=t._id??s._idSeq++;const i={x:t.x,y:t.y,w:t.w,_id:t._id};(t.autoPosition||void 0===t.x)&&(delete i.x,delete i.y,t.autoPosition&&(i.autoPosition=!0)),this._layouts=this._layouts||[],this._layouts[e]=this._layouts[e]||[];const o=this.findCacheLayout(t,e);return-1===o?this._layouts[e].push(i):this._layouts[e][o]=i,this}findCacheLayout(t,e){return this._layouts?.[e]?.findIndex(e=>e._id===t._id)??-1}removeNodeFromLayoutCache(t){if(this._layouts)for(let e=0;e<this._layouts.length;e++){const i=this.findCacheLayout(t,e);-1!==i&&this._layouts[e].splice(i,1)}}cleanupNode(t){const e=t;for(const t in e)"_"===t[0]&&"_id"!==t&&delete e[t];return this}}s._idSeq=0;const o={alwaysShowResizeHandle:"mobile",animate:!0,auto:!0,cellHeight:"auto",cellHeightThrottle:100,cellHeightUnit:"px",column:12,draggable:{handle:".grid-stack-item-content",appendTo:"body",scroll:!0},handle:".grid-stack-item-content",itemClass:"grid-stack-item",margin:10,marginUnit:"px",maxRow:0,minRow:0,placeholderClass:"grid-stack-placeholder",placeholderText:"",removableOptions:{accept:"grid-stack-item",decline:"grid-stack-non-removable"},resizable:{handles:"se"},rtl:"auto"};class n{}const r="undefined"!=typeof window&&"undefined"!=typeof document&&("ontouchstart"in document||"ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch||navigator.maxTouchPoints>0&&window.matchMedia("(any-pointer: coarse)").matches||navigator.msMaxTouchPoints>0);class l{}function a(t){t.preventDefault()}function h(){document.removeEventListener("contextmenu",a,!0),document.removeEventListener("selectstart",a,!0)}function d(t,e,i){t.removeEventListener("touchmove",e),t.removeEventListener("touchend",i),t.removeEventListener("touchcancel",i),c()}function c(){l.touchDelayTimer&&(window.clearTimeout(l.touchDelayTimer),delete l.touchDelayTimer),h()}function g(t,e){t.touches.length>1||(t.cancelable&&t.preventDefault(),i.simulateMouseEvent(t.changedTouches[0],e))}function u(t){if(l.touchHandled)return;const e=t.currentTarget,i=t.touches[0].clientX,s=t.touches[0].clientY,o=()=>d(e,n,o),n=t=>{const e=t.touches[0];Math.abs(e.clientX-i)+Math.abs(e.clientY-s)>10&&o()};e.addEventListener("touchmove",n,{passive:!0}),e.addEventListener("touchend",o,{passive:!0}),e.addEventListener("touchcancel",o,{passive:!0}),l.touchDelayTimer=window.setTimeout(()=>{d(e,n,o),l.touchHandled=!0,l.wasDelayed=!0,document.addEventListener("contextmenu",a,!0),document.addEventListener("selectstart",a,!0),g(t,"mousedown"),delete l.wasDelayed},300)}function p(t){l.touchHandled&&g(t,"mousemove")}function m(t){if(!l.touchHandled)return;h();const e=!!n.dragElement;g(t,"mouseup"),e||"touchcancel"===t.type||g(t,"click"),l.touchHandled=!1}class f{constructor(t,e,i){this.host=t,this.dir=e,this.option=i,this._mouseDown=this._mouseDown.bind(this),this._mouseMove=this._mouseMove.bind(this),this._mouseUp=this._mouseUp.bind(this),this._keyEvent=this._keyEvent.bind(this),this._init()}_init(){if(this.option.element)try{this.el=this.option.element instanceof HTMLElement?this.option.element:this.host.querySelector(this.option.element)}catch(t){this.option.element=void 0,console.error("Query for resizeable handle failed, falling back",t)}return this.el||(this.el=document.createElement("div"),this.host.appendChild(this.el)),this.el.classList.add("ui-resizable-handle"),this.el.classList.add(`${f.prefix}${this.dir}`),this.el.addEventListener("mousedown",this._mouseDown),r&&this.el.addEventListener("touchstart",u),this}destroy(){return this.mouseDownEvent&&this._mouseUp(this.mouseDownEvent),c(),this.el.removeEventListener("mousedown",this._mouseDown),r&&this.el.removeEventListener("touchstart",u),this.option.element||this.host.removeChild(this.el),this}_mouseDown(t){this.mouseDownEvent=t,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),r&&(this.el.addEventListener("touchmove",p),this.el.addEventListener("touchend",m),this.el.addEventListener("touchcancel",m)),l.wasDelayed&&this.el.classList.add("ui-resizable-armed"),t.stopPropagation(),t.preventDefault()}_mouseMove(t){const e=this.mouseDownEvent;this.moving?this._triggerEvent("move",t):Math.abs(t.x-e.x)+Math.abs(t.y-e.y)>2&&(this.moving=!0,this.el.classList.remove("ui-resizable-armed"),this._triggerEvent("start",this.mouseDownEvent),this._triggerEvent("move",t),document.addEventListener("keydown",this._keyEvent)),t.stopPropagation()}_mouseUp(t){this.moving&&(this._triggerEvent("stop",t),document.removeEventListener("keydown",this._keyEvent)),this.el.classList.remove("ui-resizable-armed"),document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp,!0),r&&(this.el.removeEventListener("touchmove",p),this.el.removeEventListener("touchend",m),this.el.removeEventListener("touchcancel",m)),delete this.moving,delete this.mouseDownEvent,t.stopPropagation(),t.preventDefault()}_keyEvent(t){"Escape"===t.key&&(this.host.gridstackNode?.grid?.engine.restoreInitial(),this._mouseUp(this.mouseDownEvent))}_triggerEvent(t,e){const i=this.option;return i[t]&&i[t](e),this}}f.prefix="ui-resizable-";class _{constructor(){this._eventRegister={}}get disabled(){return this._disabled}on(t,e){this._eventRegister[t]=e}off(t){delete this._eventRegister[t]}enable(){this._disabled=!1}disable(){this._disabled=!0}destroy(){this._eventRegister={}}triggerEvent(t,e){if(!this.disabled&&this._eventRegister[t])return this._eventRegister[t](e)}}class v extends _{constructor(t,e={}){super(),this.el=t,this.option=e,this.rectScale={x:1,y:1},this._ui=()=>{const t=this.el.parentElement.getBoundingClientRect(),e={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,right:this.originalRect.right,top:this.originalRect.top-this.scrolled},i=this.temporalRect||e;return{position:{left:this.option.rtl?(t.right-i.right)*this.rectScale.x:(i.left-t.left)*this.rectScale.x,top:(i.top-t.top)*this.rectScale.y},size:{width:i.width*this.rectScale.x,height:i.height*this.rectScale.y}}},this._mouseOver=this._mouseOver.bind(this),this._mouseOut=this._mouseOut.bind(this),this.enable(),this._setupAutoHide(!!this.option.autoHide),this._setupHandlers()}on(t,e){super.on(t,e)}off(t){super.off(t)}enable(){super.enable(),this.el.classList.remove("ui-resizable-disabled"),this._setupAutoHide(!!this.option.autoHide)}disable(){super.disable(),this.el.classList.add("ui-resizable-disabled"),this._setupAutoHide(!1)}destroy(){n.resizeElement===this&&delete n.resizeElement,this._removeHandlers(),this._setupAutoHide(!1),delete this.el,super.destroy()}updateOption(t){const e=t.handles&&t.handles!==this.option.handles,i=t.autoHide&&t.autoHide!==this.option.autoHide;return Object.assign(this.option,t),e&&(this._removeHandlers(),this._setupHandlers()),i&&this._setupAutoHide(!!this.option.autoHide),this}_setupAutoHide(t){return t?(this.el.classList.add("ui-resizable-autohide"),this.el.addEventListener("mouseover",this._mouseOver),this.el.addEventListener("mouseout",this._mouseOut)):(this.el.classList.remove("ui-resizable-autohide"),this.el.removeEventListener("mouseover",this._mouseOver),this.el.removeEventListener("mouseout",this._mouseOut),n.overResizeElement===this&&delete n.overResizeElement),this}_mouseOver(t){n.overResizeElement||n.dragElement||(n.overResizeElement=this,n.resizeElement||this.el.classList.remove("ui-resizable-autohide"))}_mouseOut(t){n.overResizeElement===this&&(delete n.overResizeElement,this.el.classList.add("ui-resizable-autohide"))}_setupHandlers(){return this.handlers=(this.option.handles??"se").split(",").map(t=>t.trim()).map(t=>new f(this.el,t,{element:this.option.element,start:t=>this._resizeStart(t),stop:t=>this._resizeStop(t),move:e=>this._resizing(e,t)})),this}_resizeStart(t){this.sizeToContent=i.shouldSizeToContent(this.el.gridstackNode,!0),this.originalRect=this.el.getBoundingClientRect(),this.scrollEl=i.getScrollElement(this.el),this.scrollY=this.scrollEl.scrollTop,this.scrolled=0,this.startEvent=t,i.pauseIframePointerEvents(!0),this._setupHelper(),this._applyChange();const e=i.initEvent(t,{type:"resizestart",target:this.el});return n.resizeElement=this,this.option.start&&this.option.start(e,this._ui()),this.el.classList.add("ui-resizable-resizing"),this.triggerEvent("resizestart",e),this}_resizing(t,e){this.scrolled=this.scrollEl.scrollTop-this.scrollY,this.temporalRect=this._getChange(t,e),this._applyChange();const s=i.initEvent(t,{type:"resize",target:this.el});return s.resizeDir=e,s.hasMovedX=this.option.rtl?e.includes("e"):e.includes("w"),s.hasMovedY=e.includes("n"),this.option.resize&&this.option.resize(s,this._ui()),this.triggerEvent("resize",s),this}_resizeStop(t){const e=i.initEvent(t,{type:"resizestop",target:this.el});return i.pauseIframePointerEvents(!1),this._cleanHelper(),this.option.stop&&this.option.stop(e),this.el.classList.remove("ui-resizable-resizing"),n.resizeElement===this&&delete n.resizeElement,!n.resizeElement&&n.overResizeElement&&n.overResizeElement.el.classList.remove("ui-resizable-autohide"),this.triggerEvent("resizestop",e),delete this.startEvent,delete this.originalRect,delete this.temporalRect,delete this.scrollY,delete this.scrolled,this}_setupHelper(){this.elOriginStyleVal=v._originStyleProp.map(t=>this.el.style[t]);const t=this.el.parentElement;this.parentOriginStylePosition=t.style.position;const e=i.getValuesFromTransformedElement(t);return this.rectScale={x:e.xScale,y:e.yScale},getComputedStyle(t).position.match(/static/)&&(t.style.position="relative"),this.el.style.position="absolute",this.el.style.opacity="0.8",this}_cleanHelper(){return v._originStyleProp.forEach((t,e)=>{this.el.style[t]=this.elOriginStyleVal[e]||null}),this.el.parentElement.style.position=this.parentOriginStylePosition||null,this}_getChange(t,e){const i=this.startEvent,s={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,right:this.originalRect.right,top:this.originalRect.top-this.scrolled},o=t.clientX-i.clientX,n=this.sizeToContent?0:t.clientY-i.clientY;let r=!1,l=!1;const a=this.option.rtl;!a&&e.indexOf("e")>-1?s.width+=o:a&&e.indexOf("w")>-1?s.width-=o:!a&&e.indexOf("w")>-1?(s.width-=o,s.left+=o,r=!0):a&&e.indexOf("e")>-1&&(s.width+=o,s.right+=o,r=!0),e.indexOf("s")>-1?s.height+=n:e.indexOf("n")>-1&&(s.height-=n,s.top+=n,l=!0);const h=this._constrainSize(s.width,s.height,r,l);return Math.round(s.width)!==Math.round(h.width)&&(!a&&e.indexOf("w")>-1?s.left+=s.width-h.width:a&&e.indexOf("e")>-1&&(s.right-=s.width-h.width),s.width=h.width),Math.round(s.height)!==Math.round(h.height)&&(e.indexOf("n")>-1&&(s.top+=s.height-h.height),s.height=h.height),s}_constrainSize(t,e,i,s){const o=this.option,n=(i?o.maxWidthMoveLeft:o.maxWidth)||Number.MAX_SAFE_INTEGER,r=(o.minWidth??0)/this.rectScale.x||t,l=(s?o.maxHeightMoveUp:o.maxHeight)||Number.MAX_SAFE_INTEGER,a=(o.minHeight??0)/this.rectScale.y||e;return{width:Math.min(n,Math.max(r,t)),height:Math.min(l,Math.max(a,e))}}_applyChange(){let t={left:0,right:0,top:0,width:0,height:0};if("absolute"===this.el.style.position){const e=this.el.parentElement,{left:i,right:s,top:o}=e.getBoundingClientRect();t={left:i,right:s,top:o,width:0,height:0}}if(!this.temporalRect)return this;const e=t;return Object.entries(this.temporalRect).forEach(([i,s])=>{if(this.option.rtl?"left"===i:"right"===i)return;const o="width"===i||"left"===i||"right"===i?this.rectScale.x:"height"===i||"top"===i?this.rectScale.y:1;let n;n="right"===i?(t.right-s)*this.rectScale.x+"px":(s-e[i])*o+"px",this.el.style[i]=n}),this}_removeHandlers(){return this.handlers.forEach(t=>t.destroy()),delete this.handlers,this}}v._originStyleProp=["width","height","position","left","right","top","opacity","zIndex"];class y extends _{constructor(t,e={}){super(),this.el=t,this.option=e,this.eventEl=this.el.closest(".grid-stack-item")||this.el,y.byEventEl.set(this.eventEl,this),this.enable(),this._setupAccept()}on(t,e){super.on(t,e)}off(t){super.off(t)}enable(){!1!==this.disabled&&(super.enable(),this.el.classList.add("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"))}disable(t=!1){!0!==this.disabled&&(super.disable(),this.el.classList.remove("ui-droppable"),t||this.el.classList.add("ui-droppable-disabled"))}destroy(){this.disable(!0),this.el.classList.remove("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"),y.byEventEl.get(this.eventEl)===this&&y.byEventEl.delete(this.eventEl),super.destroy()}updateOption(t){return Object.assign(this.option,t),this._setupAccept(),this}_mouseEnter(t){if(!n.dragElement)return;if(!this._canDrop(n.dragElement.el))return;n.dragElement._stopScrolling(),n.dropElement&&n.dropElement!==this&&n.dropElement._mouseLeave(t,!0),n.dropElement=this;const e=i.initEvent(t,{target:this.el,type:"dropover"});this.option.over&&this.option.over(e,this._ui(n.dragElement)),this.triggerEvent("dropover",e),this.el.classList.add("ui-droppable-over")}_mouseLeave(t,e=!1){if(!n.dragElement||n.dropElement!==this)return;e&&n.dragElement._stopScrolling();const s=i.initEvent(t,{target:this.el,type:"dropout"});this.option.out&&this.option.out(s,this._ui(n.dragElement)),this.triggerEvent("dropout",s),n.dropElement===this&&delete n.dropElement}static overlap(t,e){const i=Math.min(t.right,e.right)-Math.max(t.left,e.left),s=Math.min(t.bottom,e.bottom)-Math.max(t.top,e.top),o=Math.min(t.width*t.height,e.width*e.height);return i>0&&s>0&&o>0?i*s/o:0}parentDroppable(){for(let t=y.parentOf(this.el);t;t=y.parentOf(t)){const e=t.ddElement?.ddDroppable;if(e)return e}}within(t){for(let e=this.el;t&&e;e=y.parentOf(e))if(e===t.el)return!0;return!1}static parentOf(t){return t.parentElement||t.getRootNode().host}drop(t){t.preventDefault();const e=i.initEvent(t,{target:this.el,type:"drop"});this.option.drop&&this.option.drop(e,this._ui(n.dragElement)),this.triggerEvent("drop",e)}_canDrop(t){return t&&(!this.accept||this.accept(t))}_setupAccept(){return this.option.accept?("string"==typeof this.option.accept?this.accept=t=>t.classList.contains(this.option.accept)||t.matches(this.option.accept):this.accept=this.option.accept,this):this}_ui(t){return{draggable:t.el,...t.ui()}}}y.byEventEl=new WeakMap,y.enterOver={grid:.5,sub:.75,trash:.5},y.stayOver={grid:.25,sub:.5,trash:.4},y.switchBy=.2;class b extends _{constructor(t,e={}){super(),this.el=t,this.option=e,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0},this._cbDrift={dx:0,dy:0},this._updateCBDrift=()=>{if(!this.dragging||!this.helperContainment)return;const t=i.getValuesFromTransformedElement(this.helperContainment);this._cbDrift={dx:t.xOffset-this.dragTransform.xOffset,dy:t.yOffset-this.dragTransform.yOffset},this.lastDrag&&this._dragFollow(this.lastDrag)},this._autoScrollTick=()=>{const t=this.helper,e=this._autoScrollContainer;if(!t||!e||!this.lastDrag)return void this._stopScrolling();const s=this._getScrollAmount(t,e,this.lastDrag.clientY);if(!s)return void this._stopScrolling();const o=e.scrollTop;if(e.scrollTop+=s,e.scrollTop===o){const t=e.parentElement?i.getScrollElement(e.parentElement):void 0;if(!t||t===e)return void this._stopScrolling();const o=t.scrollTop;if(t.scrollTop+=s,t.scrollTop===o)return void this._stopScrolling();this._autoScrollContainer=t}this.dragging&&this.lastDrag&&(this._updateCBDrift(),this._dragFollow(this.lastDrag),this._callDrag(this.lastDrag)),this._autoScrollAnimId=requestAnimationFrame(this._autoScrollTick)};const s=e?.handle?.substring(1),o=t.gridstackNode;this.dragEls=!s||t.classList.contains(s)?[t]:o?.subGrid?[t.querySelector(e.handle)||t]:this.getAllHandles(),0===this.dragEls.length&&(this.dragEls=[t]),this._mouseDown=this._mouseDown.bind(this),this._mouseMove=this._mouseMove.bind(this),this._mouseUp=this._mouseUp.bind(this),this._keyEvent=this._keyEvent.bind(this),this.enable()}getAllHandles(){const t=this.option.handle;if(!t)return[];const e=[],i=s=>{e.push(...Array.from(s.querySelectorAll(t))),s.querySelectorAll("*").forEach(t=>{const e=t.shadowRoot;e&&i(e)})};return i(this.el),e.filter(t=>{if(!(t instanceof HTMLElement))return!1;let e=t.closest(".grid-stack-item"),i=t.getRootNode();for(;!e&&i instanceof ShadowRoot;)e=i.host.closest(".grid-stack-item"),i=i.host.getRootNode();return e===this.el||!e})}on(t,e){super.on(t,e)}off(t){super.off(t)}enable(){!1!==this.disabled&&(super.enable(),this.dragEls.forEach(t=>{t.addEventListener("mousedown",this._mouseDown),r&&t.addEventListener("touchstart",u)}),this.el.classList.remove("ui-draggable-disabled"))}disable(t=!1){!0!==this.disabled&&(super.disable(),c(),this.dragEls.forEach(t=>{t.removeEventListener("mousedown",this._mouseDown),r&&t.removeEventListener("touchstart",u)}),t||this.el.classList.add("ui-draggable-disabled"))}destroy(){this.dragTimeout&&window.clearTimeout(this.dragTimeout),delete this.dragTimeout,this.mouseDownEvent&&this._mouseUp(this.mouseDownEvent),this.disable(!0),delete this.el,delete this.option,super.destroy()}updateOption(t){return Object.assign(this.option,t),this}refreshHandles(){const t=this.disabled;t||this.disable(!0);const e=this.option?.handle?.substring(1),i=this.el.gridstackNode;this.dragEls=!e||this.el.classList.contains(e)?[this.el]:i?.subGrid?[this.el.querySelector(this.option.handle)||this.el]:this.getAllHandles(),0===this.dragEls.length&&(this.dragEls=[this.el]),t||this.enable()}_matchInPath(t,e){const i=t.composedPath?.();if(!i?.length)return t.target?.closest(e)??void 0;for(const t of i){const i=t;if(1===i?.nodeType&&i.matches?.(e))return i}}_mouseDown(t){if(t.isTrusted&&(l.touchHandled&&(l.touchHandled=!1),n.mouseHandled&&t.timeStamp!==n.mouseHandledTimeStamp&&delete n.mouseHandled),n.mouseHandled)return!0;if(0!==t.button)return!0;const e=t.target.closest('input,textarea,button,select,option,[contenteditable="true"],.ui-resizable-handle');return e&&!this.dragEls.some(i=>i===t.target||i===e)||this.option.cancel&&this._matchInPath(t,this.option.cancel)||(this.mouseDownEvent=t,delete this.dragging,delete n.dragElement,delete n.dropElement,delete this._autoScrollMaxSpeed,delete this._autoScrollContainer,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),r&&t.currentTarget&&(this._touchTarget=t.currentTarget,this._touchTarget.addEventListener("touchmove",p),this._touchTarget.addEventListener("touchend",m),this._touchTarget.addEventListener("touchcancel",m)),l.wasDelayed&&this.el.classList.add("ui-draggable-armed"),t.preventDefault(),document.activeElement&&document.activeElement.blur(),n.mouseHandled=!0,n.mouseHandledTimeStamp=t.timeStamp),!0}_callDrag(t){if(!this.dragging)return;const e=i.initEvent(t,{target:this.el,type:"drag"});this.option.drag&&this.option.drag(e,this.ui()),this.triggerEvent("drag",e)}_overlap(t,e){if(t.eventEl===t.el||!t.eventEl.getAnimations?.().some(t=>"transitionProperty"in t))return y.overlap(e,t.eventEl.getBoundingClientRect())}_checkDropTarget(t){const e=this.helper?.getBoundingClientRect(),i=e?.width&&e.height?e:{left:t.clientX,top:t.clientY,right:t.clientX+1,bottom:t.clientY+1,width:1,height:1},s=n.dropElement,o=i.left+i.width/2,r=i.top+i.height/2;let l=document.elementFromPoint?.(o,r);for(;l?.shadowRoot;){const t=l.shadowRoot.elementFromPoint?.(o,r);if(!t||!l.shadowRoot.contains(t))break;l=t}const a=[];for(;l;l=y.parentOf(l)){const t=y.byEventEl.get(l);t&&!t.disabled&&t._canDrop(this.el)&&a.push(t)}const h=t=>t.el.gridstack?t.parentDroppable()?"sub":"grid":"trash",d=s?this._overlap(s,i):0;if(void 0===d)return;for(const e of a){if(s?.within(e))break;const o=this._overlap(e,i)??0,n=s&&!e.within(s)&&y.overlap(e.eventEl.getBoundingClientRect(),s.eventEl.getBoundingClientRect())<.5;if(o>=(n&&s.within(e.parentDroppable())?.5:y.enterOver[h(e)])&&(!n||o>=d+y.switchBy))return e._mouseEnter(t)}if(!s||d>=y.stayOver[h(s)])return;if(a.some(t=>!s.within(t)&&(this._overlap(t,i)??0)>=.5))return;let c=s.parentDroppable();for(;c&&!(c._canDrop(this.el)&&(this._overlap(c,i)??1)>=y.stayOver[h(c)]);)c=c.parentDroppable();c?c._mouseEnter(t):s._mouseLeave(t)}_mouseMove(t){const e=this.mouseDownEvent;if(this.lastDrag=t,this.dragging){if(this._dragFollow(t),n.pauseDrag){const e=Number.isInteger(n.pauseDrag)?n.pauseDrag:100;this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>this._callDrag(t),e)}else this._callDrag(t);this._checkDropTarget(t),!n.dropElement&&this._autoScrollContainer&&this._checkAutoScroll()}else if(Math.abs(t.x-e.x)+Math.abs(t.y-e.y)>3){this.dragging=!0,i.pauseIframePointerEvents(!0),this.el.classList.remove("ui-draggable-armed"),n.dragElement=this;const e=this.el.gridstackNode?.grid;e?(n.dropElement=e.el.ddElement?.ddDroppable,!1!==e.opts.draggable?.scroll&&(this._autoScrollContainer=i.getScrollElement(e.el))):delete n.dropElement,this.helper=this._createHelper(),this._setupHelperContainmentStyle(),this.dragTransform=i.getValuesFromTransformedElement(this.helperContainment),this._cbDrift={dx:0,dy:0},this.dragOffset=this._getDragOffset(t,this.el,this.helperContainment),document.addEventListener("scroll",this._updateCBDrift,{capture:!0,passive:!0}),this._setupHelperStyle(t);const s=i.initEvent(t,{target:this.el,type:"dragstart"});this.option.start&&this.option.start(s,this.ui()),this.triggerEvent("dragstart",s),this._checkAutoScroll(),document.addEventListener("keydown",this._keyEvent)}return!0}_mouseUp(t){if(this._stopScrolling(),this.el.classList.remove("ui-draggable-armed"),document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp,!0),r&&this._touchTarget&&(this._touchTarget.removeEventListener("touchmove",p),this._touchTarget.removeEventListener("touchend",m),this._touchTarget.removeEventListener("touchcancel",m),delete this._touchTarget),this.dragging){delete this.dragging,i.pauseIframePointerEvents(!1),delete this.el.gridstackNode?._origRotate,document.removeEventListener("keydown",this._keyEvent),document.removeEventListener("scroll",this._updateCBDrift,!0),this._cbDrift={dx:0,dy:0},n.dropElement?.el===this.el.parentElement&&delete n.dropElement,this.helperContainment.style.position=this.parentOriginStylePosition||null,this.helper&&this.helper!==this.el&&this.helper.remove(),this._removeHelperStyle();const e=i.initEvent(t,{target:this.el,type:"dragstop"});this.option.stop&&this.option.stop(e),this.triggerEvent("dragstop",e),n.dropElement&&n.dropElement.drop(t)}delete this.helper,delete this.mouseDownEvent,delete n.dragElement,delete n.dropElement,delete n.mouseHandled,delete n.mouseHandledTimeStamp,l.touchHandled=!1,t.preventDefault()}_keyEvent(t){const e=this.el.gridstackNode,s=e?.grid||n.dropElement?.el?.gridstack;if("Escape"===t.key)e&&e._origRotate&&(e._orig=e._origRotate,delete e._origRotate),s?.cancelDrag(),this._mouseUp(this.mouseDownEvent);else if(e&&s&&("r"===t.key||"R"===t.key)){if(!i.canBeRotated(e))return;e._origRotate=e._origRotate||{...e._orig},delete e._moving,s.setAnimation(!1).rotate(e.el,{top:-this.dragOffset.offsetTop,left:-this.dragOffset.offsetX}).setAnimation(),e._moving=!0,this.dragOffset=this._getDragOffset(this.lastDrag,e.el,this.helperContainment),this.helper.style.width=this.dragOffset.width+"px",this.helper.style.height=this.dragOffset.height+"px",i.swap(e._orig,"w","h"),delete e._rect,this._mouseMove(this.lastDrag)}}_createHelper(){let t=this.el;return"function"==typeof this.option.helper?t=this.option.helper(this.el):"clone"===this.option.helper&&(t=i.cloneNode(this.el)),t.parentElement||i.appendTo(t,"parent"===this.option.appendTo?this.el.parentElement:this.option.appendTo??"body"),this.dragElementOriginStyle=b.originStyleProp.map(t=>this.el.style[t]),t}_setupHelperStyle(t){this.helper.classList.add("ui-draggable-dragging"),this.el.gridstackNode?.grid?.el.classList.add("grid-stack-dragging");const e=this.helper.style;return e.pointerEvents="none",e.width=this.dragOffset.width+"px",e.height=this.dragOffset.height+"px",e.willChange="left, right, top",e.position="fixed",this._dragFollow(t),e.transition="none",setTimeout(()=>{this.helper&&(e.transition=null)},0),this}_removeHelperStyle(){this.helper.classList.remove("ui-draggable-dragging"),(this.el._gridstackNodeOrig||this.el.gridstackNode)?.grid?.el.classList.remove("grid-stack-dragging");const t=this.helper?.gridstackNode;if(!t?._isAboutToRemove&&this.dragElementOriginStyle){const t=this.helper,e=this.dragElementOriginStyle,i=b.originStyleProp.indexOf("transition"),s=e[i]||null;t.style.transition=e[i]="none";const o=t.style;b.originStyleProp.forEach((t,i)=>o[t]=e[i]||null),setTimeout(()=>t.style.transition=s||"",50)}return delete this.dragElementOriginStyle,this}_dragFollow(t){const e=this.helper.style,i=this.dragOffset,{dx:s,dy:o}=this._cbDrift;this.option.rtl?(e.right=(window.innerWidth-t.clientX+i.offsetX+s)*this.dragTransform.xScale+"px",e.left&&(e.left="")):(e.left=(t.clientX+i.offsetX-s)*this.dragTransform.xScale+"px",e.right&&(e.right="")),e.top=(t.clientY+i.offsetTop-o)*this.dragTransform.yScale+"px"}_setupHelperContainmentStyle(){return this.helperContainment=this.helper.parentElement,"fixed"!==this.helper.style.position&&(this.parentOriginStylePosition=this.helperContainment.style.position,getComputedStyle(this.helperContainment).position.match(/static/)&&(this.helperContainment.style.position="relative")),this}_getDragOffset(t,e,i){let s=0,o=0;i&&(s=this.dragTransform.xOffset,o=this.dragTransform.yOffset);const n=e.getBoundingClientRect();let r=this.option.rtl?n.right:n.left,l=this.option.rtl?t.clientX-n.right+s:-t.clientX+n.left-s;return{x:r,top:n.top,offsetX:l,offsetTop:-t.clientY+n.top-o,width:n.width*this.dragTransform.xScale,height:n.height*this.dragTransform.yScale}}updateScrollPosition(t){this._autoScrollContainer=i.getScrollElement(t),this._checkAutoScroll()}_checkAutoScroll(){if(!this.lastDrag||!this.helper||!this._autoScrollContainer)return;const t=this.lastDrag.clientY,e=this._getScrollAmount(this.helper,this._autoScrollContainer,t);if(!e)return void this._stopScrolling();if(this._autoScrollAnimId)return;const i=Math.sign(e),s=(t-(this.mouseDownEvent?.clientY??t))*i,o=this._scrollEdges(this._autoScrollContainer),n=i<0?t-o.top:o.bottom-t;(s>=b.autoScrollStartMove||n<=b.autoScrollStartMove)&&(this._autoScrollAnimId=requestAnimationFrame(this._autoScrollTick))}_scrollEdges(t){const e=t.getBoundingClientRect(),s=i.getVisibleViewport();return{top:Math.max(e.top,s.top),bottom:Math.min(e.bottom,s.bottom)}}_getScrollAmount(t,e,i){const s=t.getBoundingClientRect(),{top:o,bottom:n}=this._scrollEdges(e);if(n<=o)return 0;const r=Math.max((n-o)*b.autoScrollBand,b.autoScrollBandMin);this._autoScrollMaxSpeed||(this._autoScrollMaxSpeed=Math.max((n-o)/50,12));const l=t=>this._autoScrollMaxSpeed*(b.autoScrollMinRatio+(1-b.autoScrollMinRatio)*Math.min(t/r,1)),a=o+r-i;if(a>0&&s.top<o-1)return-l(a);const h=i-(n-r);return h>0&&s.bottom>n+1?l(h):0}_stopScrolling(){this._autoScrollAnimId&&(cancelAnimationFrame(this._autoScrollAnimId),delete this._autoScrollAnimId)}ui(){const t=this.el.parentElement.getBoundingClientRect(),e=this.helper.getBoundingClientRect(),i=this.option.rtl?(t.right-e.right)*this.dragTransform.xScale:(e.left-t.left)*this.dragTransform.xScale;return{position:{top:(e.top-t.top)*this.dragTransform.yScale,left:i}}}}b.originStyleProp=["width","height","transform","transform-origin","transition","pointerEvents","position","left","right","top","minWidth","willChange"],b.autoScrollBand=.08,b.autoScrollBandMin=30,b.autoScrollMinRatio=.4,b.autoScrollStartMove=10;class w{static init(t){return t.ddElement||(t.ddElement=new w(t)),t.ddElement}constructor(t){this.el=t}on(t,e){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(t)>-1?this.ddDraggable.on(t,e):this.ddDroppable&&["drop","dropover","dropout"].indexOf(t)>-1?this.ddDroppable.on(t,e):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(t)>-1&&this.ddResizable.on(t,e),this}off(t){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(t)>-1?this.ddDraggable.off(t):this.ddDroppable&&["drop","dropover","dropout"].indexOf(t)>-1?this.ddDroppable.off(t):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(t)>-1&&this.ddResizable.off(t),this}setupDraggable(t){return this.ddDraggable?this.ddDraggable.updateOption(t):this.ddDraggable=new b(this.el,t),this}cleanDraggable(){return this.ddDraggable&&(this.ddDraggable.destroy(),delete this.ddDraggable),this}setupResizable(t){return this.ddResizable?this.ddResizable.updateOption(t):this.ddResizable=new v(this.el,t),this}cleanResizable(){return this.ddResizable&&(this.ddResizable.destroy(),delete this.ddResizable),this}setupDroppable(t){return this.ddDroppable?this.ddDroppable.updateOption(t):this.ddDroppable=new y(this.el,t),this}cleanDroppable(){return this.ddDroppable&&(this.ddDroppable.destroy(),delete this.ddDroppable),this}}const E=new class{resizable(t,e,i,s){return this._getDDElements(t,"string"==typeof e?e:void 0).forEach(t=>{if("disable"===e||"enable"===e)t.ddResizable&&t.ddResizable[e]();else if("destroy"===e)t.ddResizable&&t.cleanResizable();else if("option"===e)t.setupResizable({[i]:s});else{const i=t.el.gridstackNode.grid;let s=t.el.getAttribute("gs-resize-handles")||i.opts.resizable.handles||"e,s,se";"all"===s&&(s="n,e,s,w,se,sw,ne,nw");const o=!i.opts.alwaysShowResizeHandle,n=e;t.setupResizable({...i.opts.resizable,handles:s,autoHide:o,start:n.start,stop:n.stop,resize:n.resize,rtl:n.rtl})}}),this}draggable(t,e,i,s){return this._getDDElements(t,"string"==typeof e?e:void 0).forEach(t=>{if("disable"===e||"enable"===e)t.ddDraggable&&t.ddDraggable[e]();else if("destroy"===e)t.ddDraggable&&t.cleanDraggable();else if("option"===e)t.setupDraggable({[i]:s});else{const i=t.el.gridstackNode.grid,s=e;t.setupDraggable({...i.opts.draggable,start:s.start,stop:s.stop,drag:s.drag,rtl:s.rtl})}}),this}dragIn(t,e){return this._getDDElements(t).forEach(t=>t.setupDraggable(e)),this}droppable(t,e,i,s){if("string"!=typeof e){const t=e;"function"!=typeof t.accept||t._accept||(t._accept=t.accept,t.accept=e=>t._accept(e))}const o="string"==typeof e?e:void 0;return this._getDDElements(t,o).forEach(t=>{"disable"===e||"enable"===e?t.ddDroppable&&t.ddDroppable[e]():"destroy"===e?t.ddDroppable&&t.cleanDroppable():"option"===e?t.setupDroppable({[i]:s}):t.setupDroppable(e)}),this}isDroppable(t){return!(!t?.ddElement?.ddDroppable||t.ddElement.ddDroppable.disabled)}isDraggable(t){return!(!t?.ddElement?.ddDraggable||t.ddElement.ddDraggable.disabled)}isResizable(t){return!(!t?.ddElement?.ddResizable||t.ddElement.ddResizable.disabled)}on(t,e,i){return this._getDDElements(t).forEach(t=>t.on(e,t=>{i(t,n.dragElement?n.dragElement.el:t.target,n.dragElement?n.dragElement.helper:void 0)})),this}off(t,e){return this._getDDElements(t).forEach(t=>t.off(e)),this}_getDDElements(t,e){const s=t.gridstack||"destroy"!==e&&"disable"!==e,o=i.getElements(t);return o.length?o.map(t=>t.ddElement||(s?w.init(t):null)).filter(t=>!!t):[]}};class x{static init(t={},e=".grid-stack"){if("undefined"==typeof document)return null;const s=x.getGridElement(e);return s?(s.gridstack||(s.gridstack=new x(s,i.cloneDeep(t))),s.gridstack):("string"==typeof e?console.error('GridStack.initAll() no grid was found with selector "'+e+'" - element missing or wrong selector ?\nNote: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.'):console.error("GridStack.init() no grid element was passed."),null)}static initAll(t={},e=".grid-stack"){const s=[];return"undefined"==typeof document||(x.getGridElements(e).forEach(e=>{e.gridstack||(e.gridstack=new x(e,i.cloneDeep(t))),s.push(e.gridstack)}),0===s.length&&console.error('GridStack.initAll() no grid was found with selector "'+e+'" - element missing or wrong selector ?\nNote: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.')),s}static addGrid(t,e={}){if(!t)return null;let s=t;if(s.gridstack){const t=s.gridstack;return e&&(t.opts={...t.opts,...e}),void 0!==e.children&&t.load(e.children),t}return t.classList.contains("grid-stack")&&!x.addRemoveCB||(s=x.addRemoveCB?x.addRemoveCB(t,e,!0,!0):i.createDiv(["grid-stack",e.class],t)),x.init(e,s)}static registerEngine(t){x.engineClass=t}static _migrateFloat(t){const e=t.float;void 0!==e&&(void 0===t.mode&&(t.mode=e?"float":"top"),delete t.float)}get placeholder(){if(!this._placeholder){this._placeholder=i.createDiv([this.opts.placeholderClass,o.itemClass,this.opts.itemClass]);const t=i.createDiv(["placeholder-content"],this._placeholder);this.opts.placeholderText&&(t.textContent=this.opts.placeholderText)}return this._placeholder}constructor(t,e={}){this.el=t,this.opts=e,this.animationDelay=310,this._gsEventHandler={},this._extraDragRow=0,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0},t.gridstack=this,this.opts=e=e||{},x._migrateFloat(e),t.classList.contains("grid-stack")||this.el.classList.add("grid-stack"),e.row&&(e.minRow=e.maxRow=e.row,delete e.row);const l=i.toNumber(t.getAttribute("gs-row"));"auto"===e.column&&delete e.column,void 0!==e.alwaysShowResizeHandle&&(e._alwaysShowResizeHandle=e.alwaysShowResizeHandle);const a=e.columnOpts;if(a){const t=a.breakpoints;a.columnWidth||t?.length?(t&&t.length>1&&(t.sort((t,e)=>(e.w||0)-(t.w||0)),delete a.columnWidth),a.columnMax??(a.columnMax=12)):delete e.columnOpts}const h={...i.cloneDeep(o),column:i.toNumber(t.getAttribute("gs-column"))||o.column,minRow:l||i.toNumber(t.getAttribute("gs-min-row"))||o.minRow,maxRow:l||i.toNumber(t.getAttribute("gs-max-row"))||o.maxRow,staticGrid:i.toBool(t.getAttribute("gs-static"))||o.staticGrid,sizeToContent:i.toBool(t.getAttribute("gs-size-to-content"))||void 0,draggable:{handle:(e.handleClass?"."+e.handleClass:e.handle?e.handle:"")||o.draggable.handle},removableOptions:{accept:e.itemClass||o.removableOptions.accept,decline:o.removableOptions.decline}};t.getAttribute("gs-animate")&&(h.animate=i.toBool(t.getAttribute("gs-animate"))),e=i.defaults(e,h),this._initMargin(),this.checkDynamicColumn(),this._updateColumnVar(e),"auto"===e.rtl&&(e.rtl="rtl"===t.style.direction),e.rtl&&this.el.classList.add("grid-stack-rtl");const d=this.el.closest("."+o.itemClass),c=d?.gridstackNode;if(c&&(c.subGrid=this,this.parentGridNode=c,this.el.classList.add("grid-stack-nested"),c.el.classList.add("grid-stack-sub-grid")),this._isAutoCellHeight="auto"===e.cellHeight,this._isFillCellHeight="fill"===e.cellHeight,this._isAutoCellHeight||this._isFillCellHeight||"initial"===e.cellHeight)this.cellHeight(void 0);else{"number"==typeof e.cellHeight&&e.cellHeightUnit&&e.cellHeightUnit!==o.cellHeightUnit&&(e.cellHeight=e.cellHeight+e.cellHeightUnit,delete e.cellHeightUnit);const t=e.cellHeight;delete e.cellHeight,this.cellHeight(t)}"mobile"===e.alwaysShowResizeHandle&&(e.alwaysShowResizeHandle=r),this._setStaticClass();const g=e.engineClass||x.engineClass||s;if(this.engine=new g({column:this.getColumn(),mode:e.mode,maxRow:e.maxRow,onChange:t=>{t.forEach(t=>{const e=t.el;e&&(t._removeDOM?(e&&e.remove(),delete t._removeDOM):this._writePosAttr(e,t))}),this._updateContainerHeight()}}),e.auto&&(this.batchUpdate(),this.engine._loading=!0,this.getGridItems().forEach(t=>this._prepareElement(t)),delete this.engine._loading,this.batchUpdate(!1)),e.children){const t=e.children;delete e.children,t.length&&this.load(t)}this.setAnimation(),e.subGridDynamic&&!n.pauseDrag&&(n.pauseDrag=!0),void 0!==e.draggable?.pause&&(n.pauseDrag=e.draggable.pause),this._setupRemoveDrop(),this._setupAcceptWidget(),this._updateResizeEvent()}_updateColumnVar(t=this.opts){this.el.classList.add("gs-"+t.column),"number"==typeof t.column&&(this.el.style.setProperty("--gs-column-width",100/t.column+"%"),this.el.style.setProperty("--gs-columns",String(t.column)))}addWidget(t){if(!t)return;if("string"==typeof t)return void console.error("V11: GridStack.addWidget() does not support string anymore. see #2736");if(t.ELEMENT_NODE)return console.error("V11: GridStack.addWidget() does not support HTMLElement anymore. use makeWidget()"),this.makeWidget(t);let e,s=t;if(s.grid=this,e=s.el?s.el:x.addRemoveCB?x.addRemoveCB(this.el,t,!0,!1):this.createWidgetDivs(s),!e)return;if(s=e.gridstackNode,s&&e.parentElement===this.el&&this.engine.nodes.find(t=>t._id===s._id))return e;const o=this._readAttr(e);return i.defaults(t,o),this.engine.prepareNode(t),this.el.appendChild(e),this.makeWidget(e,t),e}createWidgetDivs(t){const e=i.createDiv(["grid-stack-item",this.opts.itemClass]),s=i.createDiv(["grid-stack-item-content"],e);return i.lazyLoad(t)?t.visibleObservable||(t.visibleObservable=new IntersectionObserver(([e])=>{e.isIntersecting&&(t.visibleObservable?.disconnect(),delete t.visibleObservable,x.renderCB(s,t),t.grid?.prepareDragDrop(t.el))}),window.setTimeout(()=>t.visibleObservable?.observe(e))):x.renderCB(s,t),e}makeSubGrid(t,e,s,o=!0){let n,r=t.gridstackNode;if(r||(r=this.makeWidget(t).gridstackNode),r.subGrid?.el)return r.subGrid;let l=this;for(;l&&!n;)n=l.opts?.subGridOpts,l=l.parentGridNode?.grid;e=i.cloneDeep({...this.opts,id:void 0,children:void 0,column:"auto",columnOpts:void 0,layout:"list",subGridOpts:void 0,...n||{},...e||r.subGridOpts||{}}),r.subGridOpts=e;let a=!1;"auto"===e.column&&(a=!0,e.column=Math.max(r.w||1,s?.w||1),delete e.columnOpts);let h,d,c=r.el.querySelector(".grid-stack-item-content");if(o&&(this._removeDD(r.el),d={...r,x:0,y:0},i.removeInternalForSave(d),delete d.subGridOpts,r.content&&(d.content=r.content,delete r.content),x.addRemoveCB?h=x.addRemoveCB(this.el,d,!0,!1)||void 0:(h=i.createDiv(["grid-stack-item"]),h.appendChild(c),c=i.createDiv(["grid-stack-item-content"],r.el)),this.prepareDragDrop(r.el)),s){const t=a?e.column:r.w,i=r.h+s.h,o=r.el.style;o.transition="none",this.update(r.el,{w:t,h:i}),setTimeout(()=>o.transition="")}const g=r.subGrid=x.addGrid(c,e)||void 0;return s?._moving&&(g._isTemp=!0),a&&(g._autoColumn=!0),o&&g.makeWidget(h,d),s&&(s._moving?window.setTimeout(()=>g.el.ddElement?.ddDroppable?._mouseEnter(s._event),0):g.makeWidget(r.el,r)),this.resizeToContentCheck(!1,r),g}removeAsSubGrid(t){const e=this.parentGridNode?.grid;if(e&&(e.batchUpdate(),e.removeWidget(this.parentGridNode.el,!0,!0),this.engine.nodes.forEach(t=>{t.x=(t.x??0)+(this.parentGridNode.x??0),t.y=(t.y??0)+(this.parentGridNode.y??0),this._removeDD(t.el),t.el.remove(),delete t.el.gridstackNode,e.makeWidget(t.el,t)}),e.batchUpdate(!1),this.parentGridNode&&delete this.parentGridNode.subGrid,delete this.parentGridNode,t)){const e=t.el?.gridstackNode;e&&e!==t&&(e._temporaryRemoved=!0)}}save(t=!0,e=!1,s=x.saveCB,n){const r=this.engine.save(t,s,n);if(r.forEach(i=>{if(t&&i.el&&!i.subGrid&&!s){const t=i.el.querySelector(".grid-stack-item-content");i.content=t?.innerHTML,i.content||delete i.content}else if(t||s||delete i.content,i.subGrid?.el){const o=i.w||i.subGrid.getColumn(),n=i.subGrid.save(t,e,s,o);i.subGridOpts=e?n:{children:n},delete i.subGrid}delete i.el}),e){const t=i.cloneDeep(this.opts);t.marginBottom===t.marginTop&&t.marginRight===t.marginLeft&&t.marginTop===t.marginRight&&(t.margin=t.marginTop,delete t.marginTop,delete t.marginRight,delete t.marginBottom,delete t.marginLeft),t.rtl===("rtl"===this.el.style.direction)&&(t.rtl="auto"),this._isAutoCellHeight&&(t.cellHeight="auto"),this._autoColumn&&(t.column="auto");const e=t._alwaysShowResizeHandle;return delete t._alwaysShowResizeHandle,void 0!==e?t.alwaysShowResizeHandle=e:delete t.alwaysShowResizeHandle,i.removeInternalAndSame(t,o),t.children=r,t}return r}load(t,e=x.addRemoveCB||!0){t.forEach(t=>{t.w=t.w||t.minW||1,t.h=t.h||t.minH||1}),t=i.sort(t),this.engine.skipCacheUpdate=this._ignoreLayoutsNodeChange=!0;let s=0;t.forEach(t=>{s=Math.max(s,(t.x||0)+t.w)}),s>this.engine.defaultColumn&&(this.engine.defaultColumn=s);const o=this.getColumn();s>o&&(0===this.engine.nodes.length&&this.responseLayout?(this.engine.nodes=t,this.engine.columnChanged(s,o,this.responseLayout),t=this.engine.nodes,this.engine.nodes=[],delete this.responseLayout):this.engine.cacheLayout(t,s,!0));const n=x.addRemoveCB;"function"==typeof e&&(x.addRemoveCB=e);const r=[];this.batchUpdate();const l=!this.engine.nodes.length,a=l&&this.opts.animate;a&&this.setAnimation(!1),!l&&e&&[...this.engine.nodes].forEach(e=>{e.id&&(i.find(t,e.id)||(x.addRemoveCB&&x.addRemoveCB(this.el,e,!1,!1),r.push(e),this.removeWidget(e.el,!0,!1)))}),this.engine._loading=!0;const h=[];return this.engine.nodes=this.engine.nodes.filter(e=>!e.id||!i.find(t,e.id)||(h.push(e),!1)),t.forEach(t=>{const s=t.id?i.find(h,t.id):void 0;if(s){if(i.shouldSizeToContent(s)&&(t.h=s.h),this.engine.nodeBoundFix(t),(t.autoPosition||void 0===t.x||void 0===t.y)&&(t.w=t.w||s.w,t.h=t.h||s.h,this.engine.findEmptyPosition(t)),this.engine.nodes.push(s),i.samePos(s,t)&&this.engine.nodes.length>1&&(this.moveNode(s,{...t,forceCollide:!0}),i.copyPos(t,s)),this.update(s.el,t),t.subGridOpts?.children){const e=s.el.querySelector(".grid-stack");e&&e.gridstack&&e.gridstack.load(t.subGridOpts.children)}}else e&&this.addWidget(t)}),delete this.engine._loading,this.engine.removedNodes=r,this.batchUpdate(!1),delete this._ignoreLayoutsNodeChange,delete this.engine.skipCacheUpdate,n?x.addRemoveCB=n:delete x.addRemoveCB,a&&this.setAnimation(!0,!0),this}batchUpdate(t=!0){return this.engine.batchUpdate(t),t||(this._updateContainerHeight(),this._triggerRemoveEvent(),this._triggerAddEvent(),this._triggerChangeEvent()),this}getCellHeight(t=!1){if(this.opts.cellHeight&&"auto"!==this.opts.cellHeight&&(!t||!this.opts.cellHeightUnit||"px"===this.opts.cellHeightUnit))return this.opts.cellHeight;if("rem"===this.opts.cellHeightUnit)return this.opts.cellHeight*parseFloat(getComputedStyle(document.documentElement).fontSize);if("em"===this.opts.cellHeightUnit)return this.opts.cellHeight*parseFloat(getComputedStyle(this.el).fontSize);if("cm"===this.opts.cellHeightUnit)return this.opts.cellHeight*(96/2.54);if("mm"===this.opts.cellHeightUnit)return this.opts.cellHeight*(96/2.54)/10;if("vw"===this.opts.cellHeightUnit||"vh"===this.opts.cellHeightUnit){const t="vw"===this.opts.cellHeightUnit?window.innerWidth||document.documentElement.clientWidth:window.innerHeight||document.documentElement.clientHeight;return this.opts.cellHeight*t/100}const e=this.el.querySelector("."+this.opts.itemClass);if(e){const t=i.toNumber(e.getAttribute("gs-h"))||1;return Math.round(e.offsetHeight/t)}const s=parseInt(this.el.getAttribute("gs-current-row")||"0");return s?Math.round(this.el.getBoundingClientRect().height/s):this.opts.cellHeight}cellHeight(t){if(void 0!==t&&(this._isAutoCellHeight===("auto"===t)&&this._isFillCellHeight===("fill"===t)||(this._isAutoCellHeight="auto"===t,this._isFillCellHeight="fill"===t,this._updateResizeEvent())),"initial"!==t&&"auto"!==t&&"fill"!==t||(t=void 0),void 0===t&&this._isFillCellHeight){let e=this.getRow()||this.opts.row||this.opts.maxRow||1;const i=this.el.clientHeight;i>0&&(t=Math.max(1,i/e))}if(void 0===t){const e=-this.opts.marginRight-this.opts.marginLeft+this.opts.marginTop+this.opts.marginBottom;t=this.cellWidth()+e}const e=i.parseHeight(t);return this.opts.cellHeightUnit===e.unit&&this.opts.cellHeight===e.h||(this.opts.cellHeightUnit=e.unit,this.opts.cellHeight=e.h,this.el.style.setProperty("--gs-cell-height",`${this.opts.cellHeight}${this.opts.cellHeightUnit}`),this._updateContainerHeight(),this.resizeToContentCheck()),this}cellWidth(){return this._widthOrContainer()/this.getColumn()}_widthOrContainer(t=!1){return t&&this.opts.columnOpts?.breakpointForWindow?window.innerWidth:this.el.clientWidth||this.el.parentElement.clientWidth||window.innerWidth}checkDynamicColumn(){const t=this.opts.columnOpts;if(!t||!t.columnWidth&&!t.breakpoints?.length)return!1;const e=this.getColumn();let i=e;const s=this._widthOrContainer(!0);if(t.columnWidth)i=Math.min(Math.round(s/t.columnWidth)||1,t.columnMax);else{i=t.columnMax;let o=0;for(;o<t.breakpoints.length&&s<=t.breakpoints[o].w;)i=t.breakpoints[o++].c||e}if(i!==e){const e=t.breakpoints?.find(t=>t.c===i);return this.column(i,e?.layout||t.layout),!0}return!1}compact(t="compact",e=!0){return this.engine.compact(t,e),this._triggerChangeEvent(),this}column(t,e){if(!t||t<1||this.opts.column===t)return this;e??(e="list"===this.opts.mode||"compact"===this.opts.mode?this.opts.mode:"moveScale");const i=this.getColumn();return this.opts.column=t,this.engine?(this.engine.column=t,this.el.classList.remove("gs-"+i),this._updateColumnVar(),this.engine.columnChanged(i,t,e),(this._isAutoCellHeight||this._isFillCellHeight)&&this.cellHeight(),this.resizeToContentCheck(!0),this._ignoreLayoutsNodeChange=!0,this._triggerChangeEvent(),delete this._ignoreLayoutsNodeChange,this):(this.responseLayout=e,this)}getColumn(){return this.opts.column}getGridItems(){return Array.from(this.el.children).filter(t=>t.matches("."+this.opts.itemClass)&&!t.matches("."+this.opts.placeholderClass))}isIgnoreChangeCB(){return!!this._ignoreLayoutsNodeChange}destroy(t=!0){return this.el?(this.offAll(),this._updateResizeEvent(!0),this.setStatic(!0,!1),this.setAnimation(!1),t?this.el.parentNode.removeChild(this.el):(this.removeAll(t),this.el.removeAttribute("gs-current-row")),this.parentGridNode&&delete this.parentGridNode.subGrid,delete this.parentGridNode,delete this.opts,delete this._placeholder?.gridstackNode,delete this._placeholder,delete this.engine,delete this.el.gridstack,delete this.el,this):this}mode(t){return this.opts.mode!==t&&(this.opts.mode=this.engine.mode=t,this._triggerChangeEvent()),this}getMode(){return this.engine.mode}getCellFromPixel(t,e=!1){const i=this.el.getBoundingClientRect();let s;s=e?{top:i.top+document.documentElement.scrollTop,left:i.left}:{top:this.el.offsetTop,left:this.el.offsetLeft};const o=t.left-s.left,n=t.top-s.top,r=i.width/this.getColumn(),l=i.height/parseInt(this.el.getAttribute("gs-current-row")||"0");return{x:Math.floor(o/r),y:Math.floor(n/l)}}getRow(){return Math.max(this.engine?.getRow()||0,this.opts.minRow||0)}isAreaEmpty(t,e,i,s){return this.engine.isAreaEmpty(t,e,i,s)}makeWidget(t,e){const i=x.getElement(t);if(!i||i.gridstackNode)return i;i.parentElement||this.el.appendChild(i),this._prepareElement(i,!0,e);const s=i.gridstackNode;this._updateContainerHeight(),s.subGridOpts&&this.makeSubGrid(i,s.subGridOpts,void 0,!1);let o=!1;return 1!==this.opts.column||this._ignoreLayoutsNodeChange||(o=this._ignoreLayoutsNodeChange=!0),this._triggerAddEvent(),this._triggerChangeEvent(),o&&delete this._ignoreLayoutsNodeChange,i}on(t,e){if(-1!==t.indexOf(" "))return t.split(" ").forEach(t=>this.on(t,e)),this;if("change"===t||"added"===t||"removed"===t||"enable"===t||"disable"===t){const i="enable"===t||"disable"===t;this._gsEventHandler[t]=i?t=>e(t):t=>{t.detail&&e(t,t.detail)},this.el.addEventListener(t,this._gsEventHandler[t])}else"drag"===t||"dragstart"===t||"dragstop"===t||"resizestart"===t||"resize"===t||"resizestop"===t||"dropped"===t||"resizecontent"===t?this._gsEventHandler[t]=e:console.error("GridStack.on("+t+") event not supported");return this}off(t){return-1!==t.indexOf(" ")?(t.split(" ").forEach(t=>this.off(t)),this):("change"!==t&&"added"!==t&&"removed"!==t&&"enable"!==t&&"disable"!==t||this._gsEventHandler[t]&&this.el.removeEventListener(t,this._gsEventHandler[t]),delete this._gsEventHandler[t],this)}offAll(){return Object.keys(this._gsEventHandler).forEach(t=>this.off(t)),this}removeWidget(t,e=!0,i=!0){return t?(x.getElements(t).forEach(t=>{if(t.parentElement&&t.parentElement!==this.el)return;let s=t.gridstackNode;s||(s=this.engine.nodes.find(e=>t===e.el)),s&&(e&&x.addRemoveCB&&x.addRemoveCB(this.el,s,!1,!1),delete t.gridstackNode,this._removeDD(t),this.engine.removeNode(s,e,i),e&&t.parentElement&&t.remove())}),i&&(this._triggerRemoveEvent(),this._triggerChangeEvent()),this):(console.error("Error: GridStack.removeWidget(undefined) called"),this)}removeAll(t=!0,e=!0){return this.engine.nodes.forEach(e=>{t&&x.addRemoveCB&&x.addRemoveCB(this.el,e,!1,!1),delete e.el.gridstackNode,this.opts.staticGrid||this._removeDD(e.el)}),this.engine.removeAll(t,e),e&&this._triggerRemoveEvent(),this}setAnimation(t=this.opts.animate,e){return e?setTimeout(()=>{this.opts&&this.setAnimation(t)}):t?this.el.classList.add("grid-stack-animate"):this.el.classList.remove("grid-stack-animate"),this.opts.animate=t,this}hasAnimationCSS(){return this.el.classList.contains("grid-stack-animate")}setStatic(t,e=!0,i=!0){return!!this.opts.staticGrid===t||(t?this.opts.staticGrid=!0:delete this.opts.staticGrid,this._setupRemoveDrop(),this._setupAcceptWidget(),this.engine.nodes.forEach(s=>{this.prepareDragDrop(s.el),s.subGrid&&i&&s.subGrid.setStatic(t,e,i)}),e&&this._setStaticClass()),this}updateOptions(t){const e=this.opts;if(t===e)return this;if(x._migrateFloat(t),void 0!==t.acceptWidgets&&(e.acceptWidgets=t.acceptWidgets,this._setupAcceptWidget()),void 0!==t.animate&&this.setAnimation(t.animate),t.cellHeight&&this.cellHeight(t.cellHeight),void 0!==t.class&&t.class!==e.class&&(e.class&&this.el.classList.remove(e.class),t.class&&this.el.classList.add(t.class)),t.columnOpts){const e=!!this.opts.columnOpts;this.opts.columnOpts=t.columnOpts,e!==!!this.opts.columnOpts&&this._updateResizeEvent(),this.checkDynamicColumn()}else null===t.columnOpts&&this.opts.columnOpts?(delete this.opts.columnOpts,this._updateResizeEvent()):"number"==typeof t.column&&this.column(t.column);return void 0!==t.margin&&this.margin(t.margin),void 0!==t.staticGrid&&this.setStatic(t.staticGrid),void 0===t.disableDrag||t.staticGrid||this.enableMove(!t.disableDrag),void 0===t.disableResize||t.staticGrid||this.enableResize(!t.disableResize),void 0!==t.mode&&this.mode(t.mode),void 0!==t.row?(e.minRow=e.maxRow=this.engine.maxRow=e.row=t.row,this._updateContainerHeight(),this.engine.getRow()>t.row&&this.compact()):(void 0!==t.minRow&&(e.minRow=t.minRow,this._updateContainerHeight()),void 0!==t.maxRow&&(e.maxRow=this.engine.maxRow=t.maxRow,this.engine.getRow()>t.maxRow&&this.compact())),void 0!==t.lazyLoad&&(e.lazyLoad=t.lazyLoad),t.children?.length&&this.load(t.children),this}update(t,e){return x.getElements(t).forEach(t=>{const s=t?.gridstackNode;if(!s)return;const o={...i.copyPos({},s),...i.cloneDeep(e)};this.engine.nodeBoundFix(o),delete o.autoPosition;const n=["x","y","w","h"];let r;const l=o,a=s;if(n.some(t=>void 0!==l[t]&&l[t]!==a[t])){r={};const t=r;n.forEach(e=>{t[e]=void 0!==l[e]?l[e]:a[e],delete l[e]})}if(!r&&(o.minW||o.minH||o.maxW||o.maxH)&&(r={}),void 0!==o.content){const e=t.querySelector(".grid-stack-item-content");e&&e.textContent!==o.content&&(s.content=o.content,x.renderCB(e,o),s.subGrid?.el&&(e.appendChild(s.subGrid.el),s.subGrid._updateContainerHeight())),delete o.content}let h=!1,d=!1;for(const t in l)"_"!==t[0]&&a[t]!==l[t]&&(a[t]=l[t],h=!0,d=d||!this.opts.staticGrid&&("noResize"===t||"noMove"===t||"locked"===t));if(i.sanitizeMinMax(s),r){const t=void 0!==r.w&&r.w!==s.w;this.moveNode(s,r),t&&s.subGrid?s.subGrid.onResize(this.hasAnimationCSS()?s.w:void 0):this.resizeToContentCheck(t,s),s._updating||delete s._orig}(r||h)&&this._writeAttr(t,s),d&&this.prepareDragDrop(s.el),x.updateCB&&x.updateCB(s)}),this}moveNode(t,e){const i=t._updating;i||this.engine.cleanNodes().beginUpdate(t),this.engine.moveNodeCheck(t,e),this._updateContainerHeight(),i||(this._triggerChangeEvent(),this.engine.endUpdate())}resizeToContent(t){if(!t)return;if(t.classList.remove("size-to-content-max"),!t.clientHeight)return;const e=t.gridstackNode;if(!e)return;const i=e.grid;if(!i||t.parentElement!==i.el)return;const s=i.getCellHeight(!0);if(!s)return;let o=e.h?e.h*s:t.clientHeight,n=null;if(e.resizeToContentParent&&(n=t.querySelector(e.resizeToContentParent)),n||(n=t.querySelector(x.resizeToContentParent)),!n)return;const r=t.clientHeight-n.clientHeight,l=e.h?e.h*s-r:n.clientHeight;let a;if(e.subGrid){a=e.subGrid.getRow()*e.subGrid.getCellHeight(!0);const i=e.subGrid.el.getBoundingClientRect(),s=t.getBoundingClientRect();a+=i.top-s.top}else{if(e.subGridOpts?.children?.length)return;{const t=n.firstElementChild;if(!t)return void console.error(`Error: GridStack.resizeToContent() widget id:${e.id} '${x.resizeToContentParent}'.firstElementChild is null, make sure to have a div like container. Skipping sizing.`);a=t.getBoundingClientRect().height||l}}if(l===a)return;o+=a-l;let h=Math.ceil(o/s);const d=Number.isInteger(e.sizeToContent)?e.sizeToContent:0;d&&h>d&&(h=d,t.classList.add("size-to-content-max")),e.minH&&h<e.minH?h=e.minH:e.maxH&&h>e.maxH&&(h=e.maxH),h!==e.h&&(i._ignoreLayoutsNodeChange=!0,i.moveNode(e,{h}),delete i._ignoreLayoutsNodeChange)}resizeToContentCBCheck(t){x.resizeToContentCB?x.resizeToContentCB(t):this.resizeToContent(t)}rotate(t,e){return x.getElements(t).forEach(t=>{const s=t.gridstackNode;if(!s||!i.canBeRotated(s))return;const o={w:s.h,h:s.w,minH:s.minW,minW:s.minH,maxH:s.maxW,maxW:s.maxH};if(e){const t=e.left>0?Math.floor(e.left/this.cellWidth()):0,i=e.top>0?Math.floor(e.top/this.opts.cellHeight):0;o.x=s.x+t-(s.h-(i+1)),o.y=s.y+i-t}const n=o;Object.keys(n).forEach(t=>{void 0===n[t]&&delete n[t]});const r=s._orig;this.update(t,o),s._orig=r}),this}margin(t){if(!("string"==typeof t&&t.split(" ").length>1)){const e=i.parseHeight(t);if(this.opts.marginUnit===e.unit&&this.opts.margin===e.h)return this}return this.opts.margin=t,this.opts.marginTop=this.opts.marginBottom=this.opts.marginLeft=this.opts.marginRight=void 0,this._initMargin(),this}getMargin(){return this.opts.margin}willItFit(t){return this.engine.willItFit(t)}_triggerChangeEvent(){if(this.engine.batchMode)return this;const t=this.engine.getDirtyNodes(!0);return t&&t.length&&(this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(t),this._triggerEvent("change",t)),this.engine.saveInitial(),this._sortDom(),this._isFillCellHeight&&this.cellHeight(),this}_sortDom(){let t=this.engine.nodes;if(t.forEach(t=>{t.subGrid&&t.subGrid._sortDom()}),t.length<2)return this;this.engine.sortNodes(),t=this.engine.nodes;const e=this.el.children;if(t.some((t,i)=>t.el!==e[i])){const e=this.el.moveBefore?.bind(this.el);t.forEach(t=>{t.el&&t.el.parentElement===this.el&&(e?e(t.el,null):this.el.appendChild(t.el))})}return this}_triggerAddEvent(){if(this.engine.batchMode)return this;if(this.engine.addedNodes?.length){this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(this.engine.addedNodes),this.engine.addedNodes.forEach(t=>{delete t._dirty});const t=[...this.engine.addedNodes];this.engine.addedNodes=[],this._triggerEvent("added",t)}return this}_triggerRemoveEvent(){if(this.engine.batchMode)return this;if(this.engine.removedNodes?.length){const t=[...this.engine.removedNodes];this.engine.removedNodes=[],this._triggerEvent("removed",t)}return this}_triggerEvent(t,e){const i=e?new CustomEvent(t,{bubbles:!1,detail:e}):new Event(t);let s=this;for(;s.parentGridNode;)s=s.parentGridNode.grid;return s.el.dispatchEvent(i),this}_updateContainerHeight(){if(!this.engine||this.engine.batchMode)return this;const t=this.parentGridNode;let e=this.getRow()+this._extraDragRow;const s=this.opts.cellHeight,o=this.opts.cellHeightUnit;if(!s)return this;if(!t&&!this.opts.minRow){const t=i.parseHeight(getComputedStyle(this.el).minHeight);if(t.h>0&&t.unit===o){const i=Math.floor(t.h/s);e<i&&(e=i)}}return this.el.setAttribute("gs-current-row",String(e)),this.el.style.removeProperty("min-height"),this.el.style.removeProperty("height"),!e||!t&&this._isFillCellHeight||(this.el.style[t?"minHeight":"height"]=e*s+o),t&&i.shouldSizeToContent(t)&&t.grid.resizeToContentCBCheck(t.el),this}_prepareElement(t,e=!1,s){s=s||this._readAttr(t),t.gridstackNode=s,s.el=t,s.grid=this,s=this.engine.addNode(s,e),this._writeAttr(t,s),t.classList.add(o.itemClass,this.opts.itemClass);const n=i.shouldSizeToContent(s);return n?t.classList.add("size-to-content"):t.classList.remove("size-to-content"),n&&this.resizeToContentCheck(!1,s),i.lazyLoad(s)&&s.visibleObservable||this.prepareDragDrop(s.el),this}_writePosAttr(t,e){if(!e._moving&&!e._resizing||this._placeholder===t){const i=this.opts.rtl?"right":"left",s=t.style;s.top=e.y?1===e.y?"var(--gs-cell-height)":`calc(${e.y} * var(--gs-cell-height))`:null,s[i]=e.x?1===e.x?"var(--gs-column-width)":`calc(${e.x} * var(--gs-column-width))`:null,s.width=e.w>1?`calc(${e.w} * var(--gs-column-width))`:null,s.height=e.h>1?`calc(${e.h} * var(--gs-cell-height))`:null}return t.style.setProperty("--gs-x",String(e.x||0)),t.style.setProperty("--gs-y",String(e.y||0)),t.style.setProperty("--gs-w",String(e.w||1)),t.style.setProperty("--gs-h",String(e.h||1)),t.setAttribute("gs-x",String(e.x??0)),t.setAttribute("gs-y",String(e.y??0)),e.w>1?t.setAttribute("gs-w",String(e.w)):t.removeAttribute("gs-w"),e.h>1?t.setAttribute("gs-h",String(e.h)):t.removeAttribute("gs-h"),this}_writeAttr(t,e){if(!e)return this;this._writePosAttr(t,e);const i=e,s={noResize:"gs-no-resize",noMove:"gs-no-move",locked:"gs-locked",id:"gs-id",sizeToContent:"gs-size-to-content"};for(const e in s)void 0!==i[e]&&null!==i[e]&&!1!==i[e]?t.setAttribute(s[e],String(i[e])):t.removeAttribute(s[e]);const o=e.print;return o?(o.pageBreak?t.setAttribute("gs-page-break",String(o.pageBreak)):t.removeAttribute("gs-page-break"),o.hide?t.classList.add("gs-print-hide"):t.classList.remove("gs-print-hide"),o.orientation?t.setAttribute("gs-print-orientation",String(o.orientation)):t.removeAttribute("gs-print-orientation"),o.breakInside?t.setAttribute("gs-break-inside",String(o.breakInside)):t.removeAttribute("gs-break-inside")):(t.removeAttribute("gs-page-break"),t.classList.remove("gs-print-hide"),t.removeAttribute("gs-print-orientation"),t.removeAttribute("gs-break-inside")),this}_readAttr(t,e=!0){const s={};s.x=i.toNumber(t.getAttribute("gs-x")),s.y=i.toNumber(t.getAttribute("gs-y")),s.w=i.toNumber(t.getAttribute("gs-w")),s.h=i.toNumber(t.getAttribute("gs-h")),s.autoPosition=i.toBool(t.getAttribute("gs-auto-position")),s.noResize=i.toBool(t.getAttribute("gs-no-resize")),s.noMove=i.toBool(t.getAttribute("gs-no-move")),s.locked=i.toBool(t.getAttribute("gs-locked"));let o=t.getAttribute("gs-page-break"),n=t.classList.contains("gs-print-hide"),r=t.getAttribute("gs-print-orientation"),l=t.getAttribute("gs-break-inside");(o||n||r||l)&&(s.print={},o&&(s.print.pageBreak=i.toBool(o)),n&&(s.print.hide=!0),r&&(s.print.orientation=r),l&&(s.print.breakInside=i.toBool(l)));const a=t.getAttribute("gs-size-to-content");a&&(s.sizeToContent="true"===a||"false"===a?i.toBool(a):parseInt(a,10)),s.id=t.getAttribute("gs-id")??void 0,s.maxW=i.toNumber(t.getAttribute("gs-max-w")),s.minW=i.toNumber(t.getAttribute("gs-min-w")),s.maxH=i.toNumber(t.getAttribute("gs-max-h")),s.minH=i.toNumber(t.getAttribute("gs-min-h")),e&&(1===s.w&&t.removeAttribute("gs-w"),1===s.h&&t.removeAttribute("gs-h"),s.maxW&&t.removeAttribute("gs-max-w"),s.minW&&t.removeAttribute("gs-min-w"),s.maxH&&t.removeAttribute("gs-max-h"),s.minH&&t.removeAttribute("gs-min-h"));const h=s;for(const t in h)s.hasOwnProperty(t)&&(h[t]||0===h[t]||"sizeToContent"===t||delete h[t]);return s}_setStaticClass(){const t=["grid-stack-static"];return this.opts.staticGrid?(this.el.classList.add(...t),this.el.setAttribute("gs-static","true")):(this.el.classList.remove(...t),this.el.removeAttribute("gs-static")),this}onResize(t=this.el?.clientWidth,e=this.el?.clientHeight){if(!t)return this;if(t===this.prevWidth&&e===this.prevHeight)return this;if(t===this.prevWidth&&!this._isFillCellHeight)return this;this.prevWidth=t,this.prevHeight=e,this.batchUpdate();let i=!1;return this._autoColumn&&this.parentGridNode?this.opts.column!==this.parentGridNode.w&&(this.column(this.parentGridNode.w,this.opts.layout||"list"),i=!0):i=this.checkDynamicColumn(),(this._isAutoCellHeight||this._isFillCellHeight)&&this.cellHeight(),this.engine.nodes.forEach(t=>{t.subGrid&&t.subGrid.onResize()}),this._skipInitialResize||this.resizeToContentCheck(i),delete this._skipInitialResize,this.batchUpdate(!1),this}resizeToContentCheck(t=!1,e){if(!this.engine)return;if(t&&this.hasAnimationCSS())return void setTimeout(()=>this.resizeToContentCheck(!1,e),this.animationDelay);if(e)i.shouldSizeToContent(e)&&this.resizeToContentCBCheck(e.el);else if(this.engine.nodes.some(t=>i.shouldSizeToContent(t))){const t=[...this.engine.nodes];this.batchUpdate(),t.forEach(t=>{i.shouldSizeToContent(t)&&this.resizeToContentCBCheck(t.el)}),this._ignoreLayoutsNodeChange=!0,this.batchUpdate(!1),this._ignoreLayoutsNodeChange=!1}const s=this._gsEventHandler.resizecontent;s&&s(new Event("resizecontent"),e?[e]:this.engine.nodes)}_updateResizeEvent(t=!1){const e=!this.parentGridNode&&(this._isAutoCellHeight||this._isFillCellHeight||this.opts.sizeToContent||this.opts.columnOpts||this.engine.nodes.find(t=>t.sizeToContent));return t||!e||this.resizeObserver?!t&&e||!this.resizeObserver||(this.resizeObserver.disconnect(),delete this.resizeObserver,delete this._sizeThrottle):(this._sizeThrottle=i.throttle(()=>this.onResize(),this.opts.cellHeightThrottle),this.resizeObserver=new ResizeObserver(()=>this._sizeThrottle()),this.resizeObserver.observe(this.el),this._skipInitialResize=!0),this}static getElement(t=".grid-stack-item"){return i.getElement(t)}static getElements(t=".grid-stack-item"){return i.getElements(t)}static getGridElement(t){return x.getElement(t)}static getGridElements(t){return i.getElements(t)}_initMargin(){let t={h:0,unit:"px"},e=0,s=[];"string"==typeof this.opts.margin&&(s=this.opts.margin.split(" ")),2===s.length?(this.opts.marginTop=this.opts.marginBottom=s[0],this.opts.marginLeft=this.opts.marginRight=s[1]):4===s.length?(this.opts.marginTop=s[0],this.opts.marginRight=s[1],this.opts.marginBottom=s[2],this.opts.marginLeft=s[3]):(t=i.parseHeight(this.opts.margin),this.opts.marginUnit=t.unit,e=this.opts.margin=t.h);const o=this.opts;["marginTop","marginRight","marginBottom","marginLeft"].forEach(s=>{void 0===o[s]?o[s]=e:(t=i.parseHeight(o[s]),o[s]=t.h,delete this.opts.margin)}),this.opts.marginUnit=t.unit,this.opts.marginTop===this.opts.marginBottom&&this.opts.marginLeft===this.opts.marginRight&&this.opts.marginTop===this.opts.marginRight&&(this.opts.margin=this.opts.marginTop);const n=this.el.style;return n.setProperty("--gs-item-margin-top",`${this.opts.marginTop}${this.opts.marginUnit}`),n.setProperty("--gs-item-margin-bottom",`${this.opts.marginBottom}${this.opts.marginUnit}`),n.setProperty("--gs-item-margin-right",`${this.opts.marginRight}${this.opts.marginUnit}`),n.setProperty("--gs-item-margin-left",`${this.opts.marginLeft}${this.opts.marginUnit}`),this}static getDD(){return E}static setupDragIn(t,e,s,o=document){void 0!==e?.pause&&(n.pauseDrag=e.pause);const r=(e={appendTo:"body",helper:"clone",...e||{}}).start,l=e.drag,a=e.stop,h=(t,e,i)=>t.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:{el:t,ui:i}}));("string"==typeof t?i.getElements(t,o):t).forEach((t,i)=>{E.isDraggable(t)||E.dragIn(t,{...e,start:(e,i)=>{r?.(e,i),h(t,"dragstart",i)},drag:(e,i)=>{l?.(e,i),h(t,"drag",i)},stop:e=>{a?.(e),h(t,"dragstop")}}),s?.[i]&&(t.gridstackNode=s[i])})}movable(t,e){return this.opts.staticGrid||x.getElements(t).forEach(t=>{const i=t.gridstackNode;i&&(e?delete i.noMove:i.noMove=!0,this.prepareDragDrop(i.el))}),this}resizable(t,e){return this.opts.staticGrid||x.getElements(t).forEach(t=>{const i=t.gridstackNode;i&&(e?delete i.noResize:i.noResize=!0,this.prepareDragDrop(i.el))}),this}disable(t=!0){return this.opts.staticGrid||(this.enableMove(!1,t),this.enableResize(!1,t),this._triggerEvent("disable")),this}enable(t=!0){return this.opts.staticGrid||(this.enableMove(!0,t),this.enableResize(!0,t),this._triggerEvent("enable")),this}enableMove(t,e=!0){return this.opts.staticGrid||(t?delete this.opts.disableDrag:this.opts.disableDrag=!0,this.engine.nodes.forEach(i=>{this.prepareDragDrop(i.el),i.subGrid&&e&&i.subGrid.enableMove(t,e)})),this}enableResize(t,e=!0){return this.opts.staticGrid||(t?delete this.opts.disableResize:this.opts.disableResize=!0,this.engine.nodes.forEach(i=>{this.prepareDragDrop(i.el),i.subGrid&&e&&i.subGrid.enableResize(t,e)})),this}cancelDrag(){const t=n.dragElement?.el;if(t?._gridstackNodeOrig){const e=t._gridstackNodeOrig,i=e.grid,s=this._placeholder?.gridstackNode;return s&&(s._isAboutToRemove=!0,this.engine.removeNode(s)),this.engine.restoreInitial(),t.gridstackNode=e,delete t._gridstackNodeOrig,delete n.dropElement,void(i&&(i.engine.addNode(e,!1),i.engine.restoreInitial()))}const e=this._placeholder?.gridstackNode;e&&(e._isExternal?(e._isAboutToRemove=!0,this.engine.removeNode(e)):e._isAboutToRemove&&x._itemRemoving(e.el,!1),!e._isExternal&&e._temporaryRemoved&&e._orig&&i.copyPos(e,e._orig),this.engine.restoreInitial())}_removeDD(t){return E.draggable(t,"destroy").resizable(t,"destroy"),t.gridstackNode&&delete t.gridstackNode._initDD,delete t.ddElement,this}_setupAcceptWidget(){if(this.opts.staticGrid||!this.opts.acceptWidgets&&!this.opts.removable)return E.droppable(this.el,"destroy"),this;let t,e;const s=(s,o,n)=>{const r=(n=n||o).gridstackNode;if(!r)return;if(!r.grid?.el){n.style.transform=`scale(${1/this.dragTransform.xScale},${1/this.dragTransform.yScale})`;const t=n.getBoundingClientRect();n.style.left=t.x+(this.dragTransform.xScale-1)*(s.clientX-t.x)/this.dragTransform.xScale+"px",n.style.top=t.y+(this.dragTransform.yScale-1)*(s.clientY-t.y)/this.dragTransform.yScale+"px",n.style.transformOrigin="0px 0px"}let{top:l,left:a}=n.getBoundingClientRect();const h=this.el.getBoundingClientRect();a-=h.left,l-=h.top;const d={position:{top:l*this.dragTransform.xScale,left:a*this.dragTransform.yScale}};if(r._temporaryRemoved){r.x=Math.max(0,Math.min(this.getColumn()-r.w,Math.round(a/e))),r.y=Math.max(0,Math.round(l/t)),delete r.autoPosition,this.engine.nodeBoundFix(r);const h=this._acceptingSubGrid(r);if(h){const i=(a/e+r.w/2-(h.x+h.w/2))/h.w,s=(l/t+r.h/2-(h.y+h.h/2))/h.h;Math.abs(s)>=Math.abs(i)?s>0&&(r.y=h.y+h.h):i>0?h.x+h.w+r.w<=this.getColumn()&&(r.x=h.x+h.w):h.x>=r.w&&(r.x=h.x-r.w)}if(!this.engine.willItFit(r)){if(r.autoPosition=!0,!this.engine.willItFit(r))return void E.off(o,"drag");r._willFitPos&&(i.copyPos(r,r._willFitPos),delete r._willFitPos)}this._onStartMoving(n,s,d,r,e,t)}else this._dragOrResize(n,s,d,r,e,t)};return E.droppable(this.el,{accept:t=>{const e=t.gridstackNode||this._readAttr(t,!1);if(e?.grid===this)return!0;if(!this.opts.acceptWidgets)return!1;let i=!0;if("function"==typeof this.opts.acceptWidgets)i=this.opts.acceptWidgets(t);else{const e=!0===this.opts.acceptWidgets?".grid-stack-item":this.opts.acceptWidgets;i=t.matches(e)}if(i&&e&&this.opts.maxRow){const t={w:e.w,h:e.h,minW:e.minW,minH:e.minH};i=this.engine.willItFit(t)}return i}}).on(this.el,"dropover",(i,o,n)=>{let r=n?.gridstackNode||o.gridstackNode;if(r?.grid===this&&!r._temporaryRemoved)return!1;if(r?._sidebarOrig&&(r.w=r._sidebarOrig.w,r.h=r._sidebarOrig.h),r?.grid&&r.grid!==this&&!r._temporaryRemoved&&r.grid._leave(o,n),n=n||o,e=this.cellWidth(),t=this.getCellHeight(!0),!r){const t=n.getAttribute("data-gs-widget")||n.getAttribute("gridstacknode");if(t){try{r=JSON.parse(t)}catch(e){console.error("Gridstack dropover: Bad JSON format: ",t)}n.removeAttribute("data-gs-widget"),n.removeAttribute("gridstacknode")}r||(r=this._readAttr(n)),r._sidebarOrig={w:r.w,h:r.h}}r.grid||(r.el||(r={...r}),r._isExternal=!0,n.gridstackNode=r);const l=r.w||Math.round(n.offsetWidth/e)||1,a=r.h||Math.round(n.offsetHeight/t)||1;return r.grid&&r.grid!==this?(o._gridstackNodeOrig||(o._gridstackNodeOrig=r),o.gridstackNode=r={...r,w:l,h:a,grid:this},delete r.x,delete r.y,this.engine.cleanupNode(r).nodeBoundFix(r),r._initDD=r._isExternal=r._temporaryRemoved=!0):(r.w=l,r.h=a,r._temporaryRemoved=!0),x._itemRemoving(r.el,!1),E.on(o,"drag",s),s(i,o,n),!1}).on(this.el,"dropout",(t,e,i)=>{const s=i?.gridstackNode||e.gridstackNode;return!!s&&(s.grid&&s.grid!==this||(this._leave(e,i),this._isTemp&&this.removeAsSubGrid(s)),!1)}).on(this.el,"drop",(t,e,s)=>{const o=s?.gridstackNode||e.gridstackNode;if(o?.grid===this&&!o._isExternal)return!1;const n=!!this.placeholder.parentElement,r=e!==s;this.placeholder.remove(),delete this.placeholder.gridstackNode,n&&this.opts.animate&&(this.setAnimation(!1),this.setAnimation(!0,!0));const l=e._gridstackNodeOrig;if(delete e._gridstackNodeOrig,n&&l?.grid&&l.grid!==this){const t=l.grid;t.engine.removeNodeFromLayoutCache(l),t.engine.removedNodes.push(l),t._triggerRemoveEvent()._triggerChangeEvent(),t.parentGridNode&&!t.engine.nodes.length&&t.opts.subGridDynamic&&t.removeAsSubGrid()}if(!o)return!1;if(n&&(this.engine.cleanupNode(o),o.grid=this),delete o.grid?._isTemp,E.off(e,"drag"),s&&s!==e?(s.remove(),e=s):e.remove(),this._removeDD(e),!n)return!1;const a=o.subGrid?.el?.gridstack;return i.copyPos(o,this._readAttr(this.placeholder)),i.removePositioningStyles(e),r&&(o.content||o.subGridOpts||x.addRemoveCB)?(delete o.el,e=this.addWidget(o)||e):(this._prepareElement(e,!0,o),this.el.appendChild(e),this.resizeToContentCheck(!1,o),a&&(a.parentGridNode=o),this._updateContainerHeight()),this.engine.addedNodes.push(o),this._triggerAddEvent(),this._triggerChangeEvent(),this.engine.endUpdate(),this._gsEventHandler.dropped&&this._gsEventHandler.dropped({...t,type:"dropped"},l&&l.grid?l:void 0,o),!1}),this}static _itemRemoving(t,e){if(!t)return;const i=t?t.gridstackNode:void 0;i?.grid&&!t.classList.contains(i.grid.opts.removableOptions.decline)&&(e?i._isAboutToRemove=!0:delete i._isAboutToRemove,e?t.classList.add("grid-stack-item-removing"):t.classList.remove("grid-stack-item-removing"))}_setupRemoveDrop(){if("string"!=typeof this.opts.removable)return this;const t=document.querySelector(this.opts.removable);return t?(this.opts.staticGrid||E.isDroppable(t)||E.droppable(t,this.opts.removableOptions).on(t,"dropover",(t,e)=>x._itemRemoving(e,!0)).on(t,"dropout",(t,e)=>x._itemRemoving(e,!1)),this):this}refreshDragHandles(t){return x.getElements(t).forEach(t=>{t.ddElement?.ddDraggable?.refreshHandles()}),this}prepareDragDrop(t,e=!1){const s=t?.gridstackNode;if(!s)return this;const o=s.noMove||this.opts.disableDrag,n=s.noResize||this.opts.disableResize,r=this.opts.staticGrid||o&&n;if((e||r)&&(s._initDD&&(this._removeDD(t),delete s._initDD),r))return t.classList.add("ui-draggable-disabled","ui-resizable-disabled"),this;if(!s._initDD){let e,o;const n=(i,n)=>{this.triggerEvent(i,i.target),e=this.cellWidth(),o=this.getCellHeight(!0),this._onStartMoving(t,i,n,s,e,o)},r=(i,n)=>{this._dragOrResize(t,i,n,s,e,o)},l=e=>{this.placeholder.remove(),delete this.placeholder.gridstackNode,delete s._moving,delete s._resizing,delete s._event,delete s._lastTried;const o=!!s._orig&&s.w!==s._orig.w,n=e.target;if(n.gridstackNode&&n.gridstackNode.grid===this){if(s.el=n,s._isAboutToRemove){const i=t.gridstackNode.grid;i._gsEventHandler[e.type]&&i._gsEventHandler[e.type](e,n),i.engine.nodes.push(s),i.removeWidget(t,!0,!0)}else i.removePositioningStyles(n),s._temporaryRemoved?(this._writePosAttr(n,s),this.engine.addNode(s)):this._writePosAttr(n,s),this.triggerEvent(e,n);this._extraDragRow=0,this._updateContainerHeight(),this._triggerChangeEvent(),this.engine.endUpdate(),"resizestop"===e.type&&(Number.isInteger(s.sizeToContent)&&(s.sizeToContent=s.h),this.resizeToContentCheck(o,s))}};E.draggable(t,{start:n,stop:l,drag:r,rtl:"auto"===this.opts.rtl?void 0:this.opts.rtl}).resizable(t,{start:n,stop:l,resize:r,rtl:"auto"===this.opts.rtl?void 0:this.opts.rtl}),s._initDD=!0}return E.draggable(t,o?"disable":"enable").resizable(t,n?"disable":"enable"),this}_onStartMoving(t,e,s,o,n,r){if(this.engine.cleanNodes().beginUpdate(o),this._writePosAttr(this.placeholder,o),this.el.appendChild(this.placeholder),this.placeholder.gridstackNode=o,o.grid?.el)this.dragTransform=i.getValuesFromTransformedElement(t);else if(this.placeholder&&this.placeholder.closest(".grid-stack")){const t=this.placeholder.closest(".grid-stack");this.dragTransform=i.getValuesFromTransformedElement(t)}else this.dragTransform={xScale:1,xOffset:0,yScale:1,yOffset:0};if(o.el=this.placeholder,o._lastUiPosition=s.position,o._prevYPix=s.position.top,o._moving="dragstart"===e.type,o._resizing="resizestart"===e.type,delete o._lastTried,"dropover"===e.type&&o._temporaryRemoved&&(this.engine.addNode(o),o._moving=!0),this.engine.cacheRects(n,r,this.opts.marginTop,this.opts.marginRight,this.opts.marginBottom,this.opts.marginLeft),"resizestart"===e.type){const e=this.getColumn()-o.x,i=(this.opts.maxRow||Number.MAX_SAFE_INTEGER)-o.y;E.resizable(t,"option","minWidth",n*Math.min(o.minW||1,e)).resizable(t,"option","minHeight",r*Math.min(o.minH||1,i)).resizable(t,"option","maxWidth",n*Math.min(o.maxW||Number.MAX_SAFE_INTEGER,e)).resizable(t,"option","maxWidthMoveLeft",n*Math.min(o.maxW||Number.MAX_SAFE_INTEGER,o.x+o.w)).resizable(t,"option","maxHeight",r*Math.min(o.maxH||Number.MAX_SAFE_INTEGER,i)).resizable(t,"option","maxHeightMoveUp",r*Math.min(o.maxH||Number.MAX_SAFE_INTEGER,o.y+o.h))}}_dragOrResize(t,e,s,o,r,l){const a={...o._orig};let h=!1,d=this.opts.marginLeft,c=this.opts.marginRight,g=this.opts.marginTop,u=this.opts.marginBottom;const p=Math.round(.1*l),m=Math.round(.1*r);if(d=Math.min(d,m),c=Math.min(c,m),g=Math.min(g,p),u=Math.min(u,p),"drag"===e.type){if(o._temporaryRemoved)return;o._prevYPix=s.position.top,!1!==this.opts.draggable.scroll&&n.dragElement?.updateScrollPosition(this.el);const t=s.position.left+(s.position.left>o._lastUiPosition.left?-c:d),e=s.position.top+(s.position.top>o._lastUiPosition.top?-u:g);a.x=Math.round(t/r),a.y=Math.round(e/l);const i=this._extraDragRow;if(this.engine.collide(o,a)){const t=this.getRow();let e=Math.max(0,a.y+o.h-t);this.opts.maxRow&&t+e>this.opts.maxRow&&(e=Math.max(0,this.opts.maxRow-t)),this._extraDragRow=e}else this._extraDragRow=0;if(this._extraDragRow!==i&&this._updateContainerHeight(),o.x===a.x&&o.y===a.y)return;if(this._acceptingSubGrid(o,a))return}else if("resize"===e.type){if((a.x??0)<0)return;i.updateScrollResize(e,t,l);const n=e.resizeDir||"";if(a.w=n.indexOf("e")>-1||n.indexOf("w")>-1?Math.round((s.size.width-d)/r):o.w,a.h=n.indexOf("n")>-1||n.indexOf("s")>-1?Math.round((s.size.height-g)/l):o.h,o.w===a.w&&o.h===a.h)return;if(o._lastTried&&o._lastTried.w===a.w&&o._lastTried.h===a.h)return;if(e.hasMovedX){const t=o.x-(a.w-o.w);a.x=t<0?0:t}if(e.hasMovedY){const t=o.y-(a.h-o.h);a.y=t<0?0:t}h=!0}o._event=e,o._lastTried=a;const f={x:s.position.left+d,y:s.position.top+g,w:(s.size?s.size.width:o.w*r)-d-c,h:(s.size?s.size.height:o.h*l)-g-u};if(this.engine.moveNodeCheck(o,{...a,cellWidth:r,cellHeight:l,rect:f,resizing:h})){o._lastUiPosition=s.position,this.engine.cacheRects(r,l,g,c,u,d),delete o._skipDown,h&&o.subGrid&&o.subGrid.onResize(),this._extraDragRow=0,this._updateContainerHeight();const t=e.target;o._sidebarOrig||this._writePosAttr(t,o),this.triggerEvent(e,t)}}_acceptingSubGrid(t,e=t){const i=n.dragElement;if(i)return this.engine.collideAll(t,{...t,...e}).find(t=>{const e=t.subGrid?.el?.ddElement?.ddDroppable;return e&&!e.disabled&&e._canDrop(i.el)})}triggerEvent(t,e){let i=this;for(;i.parentGridNode;)i=i.parentGridNode.grid;i._gsEventHandler[t.type]&&i._gsEventHandler[t.type](t,e)}_leave(t,e){const i=(e=e||t).gridstackNode;if(!i)return;if(e.style.transform=e.style.transformOrigin="",E.off(t,"drag"),i._temporaryRemoved)return;i._temporaryRemoved=!0,this.engine.removeNode(i),i.el=i._isExternal&&e?e:t;const s=i._sidebarOrig;i._isExternal&&this.engine.cleanupNode(i),i._sidebarOrig=s,!0===this.opts.removable&&x._itemRemoving(t,!0),t._gridstackNodeOrig?(t.gridstackNode=t._gridstackNodeOrig,delete t._gridstackNodeOrig):i._isExternal&&this.engine.restoreInitial()}}return x.renderCB=(t,e)=>{t&&e?.content&&(t.textContent=e.content)},x.resizeToContentParent=".grid-stack-item-content",x.Utils=i,x.Engine=s,x.GDRev="14.1.0",e.GridStack})());
-//# sourceMappingURL=gridstack-all.js.map \ No newline at end of file
diff --git a/static/vendor/gridstack/gridstack.min.css b/static/vendor/gridstack/gridstack.min.css
deleted file mode 100644
index ed4f716..0000000
--- a/static/vendor/gridstack/gridstack.min.css
+++ /dev/null
@@ -1 +0,0 @@
-.grid-stack{position:relative}.grid-stack-placeholder>.placeholder-content{background-color:rgba(0,0,0,.1);margin:0;position:absolute;width:auto;z-index:0!important}.grid-stack>.grid-stack-item{position:absolute;padding:0;top:0;width:var(--gs-column-width);height:var(--gs-cell-height)}.grid-stack>.grid-stack-item>.grid-stack-item-content{margin:0;position:absolute;width:auto;overflow-x:hidden;overflow-y:auto}.grid-stack>.grid-stack-item.size-to-content:not(.size-to-content-max)>.grid-stack-item-content{overflow-y:hidden}.grid-stack:not(.grid-stack-rtl)>.grid-stack-item{left:0}.grid-stack.grid-stack-rtl>.grid-stack-item{right:0}.grid-stack>.grid-stack-item>.grid-stack-item-content,.grid-stack>.grid-stack-placeholder>.placeholder-content{top:var(--gs-item-margin-top);right:var(--gs-item-margin-right);bottom:var(--gs-item-margin-bottom);left:var(--gs-item-margin-left)}.grid-stack-item>.ui-resizable-handle{position:absolute;font-size:.1px;display:block;-ms-touch-action:manipulation;touch-action:manipulation;user-select:none;z-index:100}.grid-stack-item.ui-resizable-autohide>.ui-resizable-handle,.grid-stack-item.ui-resizable-disabled>.ui-resizable-handle{display:none}.grid-stack-item>.ui-resizable-ne,.grid-stack-item>.ui-resizable-nw,.grid-stack-item>.ui-resizable-se,.grid-stack-item>.ui-resizable-sw{background-image:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" stroke="%23666" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 20 20"><path d="m10 3 2 2H8l2-2v14l-2-2h4l-2 2"/></svg>');background-repeat:no-repeat;background-position:center;z-index:101}.grid-stack-item>.ui-resizable-ne{transform:rotate(45deg)}.grid-stack-item>.ui-resizable-sw{transform:rotate(45deg)}.grid-stack-item>.ui-resizable-nw{transform:rotate(-45deg)}.grid-stack-item>.ui-resizable-se{transform:rotate(-45deg)}.grid-stack-item>.ui-resizable-nw{cursor:nw-resize;width:20px;height:20px;top:var(--gs-item-margin-top);left:var(--gs-item-margin-left)}.grid-stack-item>.ui-resizable-n{cursor:n-resize;height:10px;top:var(--gs-item-margin-top);left:25px;right:25px}.grid-stack-item>.ui-resizable-ne{cursor:ne-resize;width:20px;height:20px;top:var(--gs-item-margin-top);right:var(--gs-item-margin-right)}.grid-stack-item>.ui-resizable-e{cursor:e-resize;width:10px;top:15px;bottom:15px;right:var(--gs-item-margin-right)}.grid-stack-item>.ui-resizable-se{cursor:se-resize;width:20px;height:20px;bottom:var(--gs-item-margin-bottom);right:var(--gs-item-margin-right)}.grid-stack-item>.ui-resizable-s{cursor:s-resize;height:10px;left:25px;bottom:var(--gs-item-margin-bottom);right:25px}.grid-stack-item>.ui-resizable-sw{cursor:sw-resize;width:20px;height:20px;bottom:var(--gs-item-margin-bottom);left:var(--gs-item-margin-left)}.grid-stack-item>.ui-resizable-w{cursor:w-resize;width:10px;top:15px;bottom:15px;left:var(--gs-item-margin-left)}.grid-stack-item.ui-draggable-dragging>.ui-resizable-handle{display:none!important}.grid-stack-item.ui-draggable-dragging{will-change:left,right,top}.grid-stack-item.ui-resizable-resizing{will-change:width,height}.grid-stack-item.ui-draggable-armed{cursor:move;animation:gs-armed-wiggle .25s ease-in-out infinite}.grid-stack-item>.ui-resizable-handle.ui-resizable-armed{animation:gs-armed-pulse .5s ease-in-out infinite}@keyframes gs-armed-wiggle{0%,100%{transform:rotate(0)}25%{transform:rotate(-1.5deg)}75%{transform:rotate(1.5deg)}}@keyframes gs-armed-pulse{0%,100%{opacity:1}50%{opacity:.3}}.ui-draggable-dragging,.ui-resizable-resizing{z-index:10000}.ui-draggable-dragging>.grid-stack-item-content,.ui-resizable-resizing>.grid-stack-item-content{box-shadow:1px 4px 6px rgba(0,0,0,.2);opacity:.8}.grid-stack-animate,.grid-stack-animate .grid-stack-item{transition:left .3s,right .3s,top .3s,height .3s,width .3s}.grid-stack-animate .grid-stack-item.grid-stack-placeholder,.grid-stack-animate .grid-stack-item.ui-draggable-dragging,.grid-stack-animate .grid-stack-item.ui-resizable-resizing{transition:left 0s,right 0s,top 0s,height 0s,width 0s}.grid-stack>.grid-stack-item[gs-y="0"]{top:0}.grid-stack:not(.grid-stack-rtl)>.grid-stack-item[gs-x="0"]{left:0}.grid-stack.grid-stack-rtl>.grid-stack-item[gs-x="0"]{right:0}.gs-print-show{display:none}@media print{@page gs-landscape{size:landscape}@page gs-portrait{size:portrait}.grid-stack{display:block!important;height:auto!important;position:static!important}.grid-stack>.grid-stack-item{display:block!important;float:left!important;position:static!important;height:auto!important;left:auto!important;top:auto!important;width:calc(100% * var(--gs-w)/ var(--gs-columns,12))!important;break-inside:avoid!important;page-break-inside:avoid!important}.grid-stack>.grid-stack-item>.grid-stack-item-content{position:relative!important;height:auto!important;overflow:visible!important;white-space:normal!important;margin-top:var(--gs-item-margin-top)!important;margin-right:var(--gs-item-margin-right)!important;margin-bottom:var(--gs-item-margin-bottom)!important;margin-left:var(--gs-item-margin-left)!important;top:auto!important;right:auto!important;bottom:auto!important;left:auto!important}.gs-print-hide{display:none}.gs-print-show{display:block}.gs-print-avoid-break-after{break-after:avoid!important;page-break-after:avoid!important}.grid-stack>.grid-stack-item.gs-print-hide{display:none!important}.grid-stack>.grid-stack-item[gs-page-break=true],.grid-stack>.grid-stack-item[gs-print-orientation]{float:none!important;clear:both!important}.grid-stack>.grid-stack-item[gs-page-break=true]{page-break-before:always!important;break-before:page!important}.grid-stack>.grid-stack-item[gs-print-orientation=landscape]{page:gs-landscape;min-width:calc(100vmax * var(--gs-w)/ var(--gs-columns,12))!important}.grid-stack>.grid-stack-item[gs-print-orientation=portrait]{page:gs-portrait;min-width:calc(100vmin * var(--gs-w)/ var(--gs-columns,12))!important}.grid-stack>.grid-stack-item[gs-break-inside=true]{float:none!important;clear:both!important;width:100%!important;break-inside:auto!important;page-break-inside:auto!important}.grid-stack>.grid-stack-item>.ui-resizable-handle{display:none!important}} \ No newline at end of file
diff --git a/tests/test_dashboard.mjs b/tests/test_dashboard.mjs
new file mode 100644
index 0000000..2fc19eb
--- /dev/null
+++ b/tests/test_dashboard.mjs
@@ -0,0 +1,55 @@
+// deck-it - check for static/dashboard.js: `node tests/test_dashboard.mjs`
+// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+import assert from "node:assert/strict";
+import { area, push, spendParts, batteryGlyph, HISTORY } from "../static/dashboard.js";
+import { busy as printing } from "../static/modules/k1c.js";
+import { busy as building } from "../static/modules/sbbuilder.js";
+import { busy as live } from "../static/modules/obs.js";
+
+// push keeps the last HISTORY samples
+const h = [];
+for (let i = 0; i < HISTORY + 5; i++) push(h, i);
+assert.equal(h.length, HISTORY);
+assert.equal(h[0], 5);
+
+// area: empty without samples; closed path from the bottom edge to the right edge
+assert.equal(area([], 10), "");
+const d = area([0, 10], 10);
+assert.match(d, /^M[\d.]+,100 /);
+assert.match(d, / L120,100 Z$/);
+assert.ok(d.includes(",12"), "the max sample sits at 12% from the top");
+
+// spendParts: top 3 paid models, then "other" with the rest
+const models = [5, 4, 3, 2, 1, 0].map((c, i) => ({ model: `m${i}`, cost: c }));
+assert.deepEqual(spendParts(models).map((m) => [m.model, m.cost]),
+ [["m0", 5], ["m1", 4], ["m2", 3], ["other", 3]]);
+assert.deepEqual(spendParts([{ model: "free", cost: 0 }]), []);
+
+// batteryGlyph: level steps, bolt while charging or full
+assert.equal(batteryGlyph({ level: 3, status: "discharging" }), "");
+assert.equal(batteryGlyph({ level: 50, status: "discharging" }), "");
+assert.equal(batteryGlyph({ level: 100, status: "discharging" }), "");
+assert.equal(batteryGlyph({ level: 40, status: "charging" }), "\u{f0084}");
+
+// busy checks
+assert.equal(printing({ state: "printing" }), true);
+assert.equal(printing({ state: "standby" }), false);
+assert.equal(printing({ offline: true }), false);
+assert.equal(building({ jobs: [{ status: "running" }] }), true);
+assert.equal(building({ jobs: [{ status: "done" }] }), false);
+assert.equal(live({ connected: true, recording: true }), true);
+assert.equal(live({ connected: true, recording: false, streaming: false }), false);
diff --git a/tests/test_frontend.py b/tests/test_frontend.py
index 635b57a..42126b8 100644
--- a/tests/test_frontend.py
+++ b/tests/test_frontend.py
@@ -69,8 +69,9 @@ class Frontend(unittest.TestCase):
status, body = self.get("/")
self.assertEqual(status, 200)
text = body.decode()
- for asset in ("app.js", "deck.css", "vendor/gridstack/gridstack-all.js"):
+ for asset in ("app.js", "deck.css"):
self.assertIn(asset, text)
+ self.assertNotIn("gridstack", text)
def test_pwa_manifest(self):
self.assertIn(b'rel="manifest"', self.get("/")[1])
@@ -80,9 +81,8 @@ class Frontend(unittest.TestCase):
for size in (192, 512):
self.assertEqual(self.get(f"/icon-{size}.png")[0], 200)
- def test_vendor_assets_served(self):
- for path in ("/vendor/gridstack/gridstack-all.js", "/vendor/gridstack/gridstack.min.css"):
- self.assertEqual(self.get(path)[0], 200, path)
+ def test_vendor_gridstack_is_gone(self):
+ self.assertEqual(self.get("/vendor/gridstack/gridstack-all.js")[0], 404)
def test_css_uses_udt_vars(self):
status, body = self.get("/deck.css")
@@ -96,16 +96,19 @@ class Frontend(unittest.TestCase):
for part in ("export default", "mount", "update"):
self.assertIn(part, text, name)
- def test_panel_for_every_module(self):
- from deckit.modules import build
- names = [m["name"] for m in build({}).names()]
- self.assertIn("stats", names)
- for name in names:
+ def test_panels(self):
+ # Tabs and the music card have panels; stats, tablet, llm and actions
+ # are drawn by dashboard.js; k1c, sbbuilder and obs give it a slot.
+ for name in ("music", "k1c", "obs", "windows", "assistant"):
self.assert_panel(name)
+ for name in ("k1c", "sbbuilder", "obs"):
+ text = self.get(f"/modules/{name}.js")[1].decode()
+ self.assertIn("export const busy", text, name)
+ self.assertIn("export function slot", text, name)
+ self.assertEqual(self.get("/dashboard.js")[0], 200)
def test_panels_have_their_scoped_wrapper(self):
self.assertIn(b'class="music"', self.get("/modules/music.js")[1])
- self.assertIn(b'class="sbb"', self.get("/modules/sbbuilder.js")[1])
def test_tabbed_shell(self):
self.assertIn(b'id="tabs"', self.get("/")[1])
@@ -117,12 +120,11 @@ class Frontend(unittest.TestCase):
self.assertIn(b'tab: "OBS"', self.get("/modules/obs.js")[1])
self.assertIn(b'tab: "Windows"', self.get("/modules/windows.js")[1])
- def test_layout_is_browser_local(self):
- status, body = self.get("/app.js")
- self.assertEqual(status, 200)
- text = body.decode()
- for part in ("GridStack", "localStorage", "deckit.layout", "gs-id"):
- self.assertIn(part, text)
+ def test_dashboard_is_one_fixed_screen(self):
+ text = self.get("/app.js")[1].decode()
+ self.assertIn("dashboard.js", text)
+ for gone in ("GridStack", "deckit.layout", "deckit.folded"):
+ self.assertNotIn(gone, text)
if __name__ == "__main__":