aboutsummaryrefslogtreecommitdiffstats
path: root/static
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-09 18:53:11 +0100
committerDanilo M. <danix@danix.xyz>2026-11-09 18:53:11 +0100
commita9d709f6dd893b6fab6750b67f0c4f367458f40c (patch)
tree56da28331b95eac727ac715c71293d1e3d254f7d /static
parentc00a4775106bc5927c821f5359ec265c318d73ec (diff)
downloaddeck-it-a9d709f6dd893b6fab6750b67f0c4f367458f40c.tar.gz
deck-it-a9d709f6dd893b6fab6750b67f0c4f367458f40c.zip
feat: vendored Gridstack for drag and free grid resize
Diffstat (limited to 'static')
-rw-r--r--static/app.js135
-rw-r--r--static/deck.css37
-rw-r--r--static/index.html4
-rw-r--r--static/vendor/gridstack/gridstack-all.js3
-rw-r--r--static/vendor/gridstack/gridstack.min.css1
5 files changed, 76 insertions, 104 deletions
diff --git a/static/app.js b/static/app.js
index 526f57a..c6fb06e 100644
--- a/static/app.js
+++ b/static/app.js
@@ -1,71 +1,47 @@
-// The shell: discover modules, mount each panel, poll its state.
-// A module is static/modules/<name>.js exporting default {title, interval,
-// mount(el), update(state, el)}. A missing or broken panel is skipped.
-// Panel order and width are kept in this browser's localStorage.
+// The shell: discover modules, mount each panel as a Gridstack card, poll its
+// state. A module is static/modules/<name>.js exporting default {title,
+// interval, mount(el), update(state, el)}. Card position and size are kept in
+// this browser's localStorage.
-const grid = document.getElementById("grid");
+const gridEl = document.getElementById("grid");
const refreshers = [];
const LAYOUT_KEY = "deckit.layout";
+const DEFAULT_W = 6;
+const DEFAULT_H = 4;
+
+const grid = GridStack.init({
+ column: 12,
+ cellHeight: 80,
+ margin: 8,
+ float: true,
+ handle: ".panel-drag",
+ resizable: { handles: "se" },
+}, gridEl);
function loadLayout() {
try {
- return JSON.parse(localStorage.getItem(LAYOUT_KEY)) || {};
+ const saved = JSON.parse(localStorage.getItem(LAYOUT_KEY));
+ return Array.isArray(saved) ? saved : [];
} catch {
- return {};
+ return [];
}
}
-function saveLayout(layout) {
+function saveLayout() {
+ if (!ready) return; // don't clobber the stored layout while the cards mount
try {
- localStorage.setItem(LAYOUT_KEY, JSON.stringify(layout));
+ localStorage.setItem(LAYOUT_KEY, JSON.stringify(grid.save(false)));
} catch {
// private mode or storage full: the layout just won't persist
}
}
-function panelOrder() {
- return [...grid.querySelectorAll(".panel")].map((p) => p.dataset.module);
-}
+let ready = false;
+grid.on("change", saveLayout);
-function enableDrag(el) {
- const handle = el.querySelector(".drag-handle");
- handle.addEventListener("pointerdown", (start) => {
- start.preventDefault();
- el.classList.add("dragging");
- handle.setPointerCapture(start.pointerId);
- const move = (ev) => {
- const target = [...grid.querySelectorAll(".panel")].find((p) => {
- if (p === el) return false;
- const r = p.getBoundingClientRect();
- return ev.clientX >= r.left && ev.clientX <= r.right
- && ev.clientY >= r.top && ev.clientY <= r.bottom;
- });
- if (!target) return;
- const r = target.getBoundingClientRect();
- const after = ev.clientY > r.top + r.height / 2;
- grid.insertBefore(el, after ? target.nextSibling : target);
- };
- const end = () => {
- el.classList.remove("dragging");
- handle.releasePointerCapture(start.pointerId);
- handle.removeEventListener("pointermove", move);
- handle.removeEventListener("pointerup", end);
- handle.removeEventListener("pointercancel", end);
- saveLayout({ ...loadLayout(), order: panelOrder() });
- };
- handle.addEventListener("pointermove", move);
- handle.addEventListener("pointerup", end);
- handle.addEventListener("pointercancel", end);
- });
-}
-
-function enableResize(el, name) {
- el.querySelector(".resize-handle").addEventListener("click", () => {
- el.classList.toggle("wide");
- const layout = loadLayout();
- layout.spans = { ...(layout.spans ?? {}), [name]: el.classList.contains("wide") ? 2 : 1 };
- saveLayout(layout);
- });
+const savedById = {};
+for (const node of loadLayout()) {
+ if (node.id) savedById[node.id] = node;
}
function header(title) {
@@ -74,34 +50,43 @@ function header(title) {
const h = document.createElement("h2");
h.textContent = title;
const drag = document.createElement("button");
- drag.className = "drag-handle";
+ drag.className = "panel-drag";
drag.textContent = "≡";
drag.setAttribute("aria-label", "Move panel");
- const resize = document.createElement("button");
- resize.className = "resize-handle";
- resize.textContent = "⤢";
- resize.setAttribute("aria-label", "Toggle panel width");
- head.append(h, drag, resize);
+ head.append(h, drag);
return head;
}
-async function mountModule(name, layout) {
+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";
+ content.append(header(title));
+ item.append(content);
+ gridEl.append(item);
+ grid.makeWidget(item);
+ return content;
+}
+
+async function mountModule(name) {
try {
const panel = (await import(`./modules/${name}.js`)).default;
- const el = document.createElement("section");
- el.className = "panel";
- el.dataset.module = name;
- if ((layout.spans ?? {})[name] >= 2) el.classList.add("wide");
- el.append(header(panel.title ?? name));
- grid.append(el);
- panel.mount?.(el);
- enableDrag(el);
- enableResize(el, name);
+ const content = makeCard(name, panel.title ?? name);
+ panel.mount?.(content);
const poll = async () => {
try {
const r = await fetch(`/api/${name}`);
- if (r.ok) panel.update?.(await r.json(), el);
+ if (r.ok) panel.update?.(await r.json(), content);
} catch {
// keep the last state; the next tick retries
}
@@ -117,18 +102,8 @@ async function mountModule(name, layout) {
async function boot() {
const r = await fetch("/api/modules");
if (!r.ok) return;
- const layout = loadLayout();
- const order = layout.order ?? [];
- const mods = await r.json();
- mods.sort((a, b) => {
- const ia = order.indexOf(a.name);
- const ib = order.indexOf(b.name);
- if (ia === -1 && ib === -1) return 0;
- if (ia === -1) return 1;
- if (ib === -1) return -1;
- return ia - ib;
- });
- for (const { name } of mods) await mountModule(name, layout);
+ for (const { name } of await r.json()) await mountModule(name);
+ ready = true;
}
document.addEventListener("visibilitychange", () => {
diff --git a/static/deck.css b/static/deck.css
index 200a651..d6b62dc 100644
--- a/static/deck.css
+++ b/static/deck.css
@@ -11,21 +11,17 @@ body {
-webkit-touch-callout: none;
-webkit-user-select: none;
user-select: none;
- overflow: hidden;
+ overflow-y: auto;
+ overflow-x: hidden;
}
#grid {
- height: 100dvh;
padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
- display: grid;
- gap: 12px;
- grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
- grid-auto-rows: minmax(0, auto);
- align-content: start;
- overflow-y: auto;
}
+.grid-stack { min-height: 100dvh; }
+
.panel {
background: var(--udt-surface0);
border: 1px solid var(--udt-surface1);
@@ -35,30 +31,25 @@ body {
min-width: 0;
}
-.panel { position: relative; }
-.panel.wide { grid-column: span 2; }
-@media (max-width: 620px) { .panel.wide { grid-column: auto; } }
-.panel.dragging { opacity: .6; outline: 2px dashed var(--udt-accent); }
+.grid-stack-item-content.panel { position: absolute; }
.panel-head { display: flex; align-items: center; gap: 4px; margin-bottom: 12px; }
-.panel .panel-head h2 { margin: 0; flex: 1; }
-.panel-head button {
+.panel .panel-head h2 {
+ margin: 0;
+ flex: 1;
+ font-size: 13px;
+ font-weight: 500;
+ color: var(--udt-subtext0);
+}
+.panel-drag {
font: inherit;
color: var(--udt-overlay0);
background: transparent;
border: 0;
padding: 2px 8px;
- cursor: pointer;
+ cursor: grab;
touch-action: none;
}
-.drag-handle { cursor: grab; }
-
-.panel h2 {
- font-size: 13px;
- font-weight: 500;
- color: var(--udt-subtext0);
- margin-bottom: 12px;
-}
.num {
font-family: "Inconsolata Nerd Font Mono", ui-monospace, monospace;
diff --git a/static/index.html b/static/index.html
index 2c5bdfa..dfb34cb 100644
--- a/static/index.html
+++ b/static/index.html
@@ -8,12 +8,14 @@
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="deck-it">
<meta name="theme-color" content="#24273a">
+<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>
</head>
<body>
-<main id="grid"></main>
+<main id="grid" class="grid-stack"></main>
+<script src="vendor/gridstack/gridstack-all.js"></script>
<script type="module" src="app.js"></script>
</body>
</html>
diff --git a/static/vendor/gridstack/gridstack-all.js b/static/vendor/gridstack/gridstack-all.js
new file mode 100644
index 0000000..496dc55
--- /dev/null
+++ b/static/vendor/gridstack/gridstack-all.js
@@ -0,0 +1,3 @@
+/*! 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
new file mode 100644
index 0000000..ed4f716
--- /dev/null
+++ b/static/vendor/gridstack/gridstack.min.css
@@ -0,0 +1 @@
+.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