From e48496316e4a3ee876003070b28e83984d5f021f Mon Sep 17 00:00:00 2001 From: David Vincent Date: Tue, 14 May 2024 09:30:44 +0200 Subject: [PATCH] Add columns function Add columns function to plugin to define the number of columns in the grid --- README.md | 15 +++++++++++++++ .../components/filament-gridstack-dashboard.js | 6 +++--- resources/js/index.js | 5 ++++- resources/views/pages/dashboard.blade.php | 5 +++-- src/Filament/Pages/Dashboard.php | 4 ++-- src/GridstackDashboardPlugin.php | 14 ++++++++++++++ 6 files changed, 41 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 94d1203..f29453f 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,21 @@ public function panel(Panel $panel): Panel } ``` +You can configure the number of columns of the grid. Default is 12. + +```php +use InvadersXX\FilamentGridstackDashboard\GridstackDashboardPlugin; + +public function panel(Panel $panel): Panel +{ + return $panel + ->plugins([ + GridstackDashboardPlugin::make() + ->columns(3), + ]) +} +``` + You can configure the settings path (string in dotted format where to store in the settings) By default the path is 'dashboard.layout' diff --git a/resources/dist/components/filament-gridstack-dashboard.js b/resources/dist/components/filament-gridstack-dashboard.js index 1242e02..1ee5ba9 100644 --- a/resources/dist/components/filament-gridstack-dashboard.js +++ b/resources/dist/components/filament-gridstack-dashboard.js @@ -1,6 +1,6 @@ -function W(h,t,e,i,s){let r=(...o)=>(console.warn("gridstack.js: Function `"+e+"` is deprecated in "+s+" and has been replaced with `"+i+"`. It will be **removed** in a future release"),t.apply(h,o));return r.prototype=t.prototype,r}var a=class h{static getElements(t,e=document){if(typeof t=="string"){let i="getElementById"in e?e:void 0;if(i&&!isNaN(+t[0])){let r=i.getElementById(t);return r?[r]:[]}let s=e.querySelectorAll(t);return!s.length&&t[0]!=="."&&t[0]!=="#"&&(s=e.querySelectorAll("."+t),s.length||(s=e.querySelectorAll("#"+t))),Array.from(s)}return[t]}static getElement(t,e=document){if(typeof t=="string"){let 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 shouldSizeToContent(t,e=!1){return t?.grid&&(e?t.sizeToContent===!0||t.grid.opts.sizeToContent===!0&&t.sizeToContent===void 0:!!t.sizeToContent||t.grid.opts.sizeToContent&&t.sizeToContent!==!1)}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 h.isIntercepted(t,{x:e.x-.5,y:e.y-.5,w:e.w+1,h:e.h+1})}static areaIntercept(t,e){let i=t.x>e.x?t.x:e.x,s=t.x+t.we.y?t.y:e.y,o=t.y+t.h{let o=e*((s.y??1e4)-(r.y??1e4));return o===0?e*((s.x??1e4)-(r.x??1e4)):o})}static find(t,e){return e?t.find(i=>i.id===e):void 0}static createStylesheet(t,e,i){let s=document.createElement("style"),r=i?.nonce;return r&&(s.nonce=r),s.setAttribute("type","text/css"),s.setAttribute("gs-style-id",t),s.styleSheet?s.styleSheet.cssText="":s.appendChild(document.createTextNode("")),e?e.insertBefore(s,e.firstChild):(e=document.getElementsByTagName("head")[0],e.appendChild(s)),s.sheet}static removeStylesheet(t,e){let s=(e||document).querySelector("STYLE[gs-style-id="+t+"]");s&&s.parentNode&&s.remove()}static addCSSRule(t,e,i){typeof t.addRule=="function"?t.addRule(e,i):typeof t.insertRule=="function"&&t.insertRule(`${e}{${i}}`)}static toBool(t){return typeof t=="boolean"?t:typeof t=="string"?(t=t.toLowerCase(),!(t===""||t==="no"||t==="false"||t==="0")):!!t}static toNumber(t){return t===null||t.length===0?void 0:Number(t)}static parseHeight(t){let e,i="px";if(typeof t=="string")if(t==="auto"||t==="")e=0;else{let 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(i=>{for(let s in i){if(!i.hasOwnProperty(s))return;t[s]===null||t[s]===void 0?t[s]=i[s]:typeof i[s]=="object"&&typeof t[s]=="object"&&this.defaults(t[s],i[s])}}),t}static same(t,e){if(typeof t!="object")return t==e;if(typeof t!=typeof e||Object.keys(t).length!==Object.keys(e).length)return!1;for(let i in t)if(t[i]!==e[i])return!1;return!0}static copyPos(t,e,i=!1){return e.x!==void 0&&(t.x=e.x),e.y!==void 0&&(t.y=e.y),e.w!==void 0&&(t.w=e.w),e.h!==void 0&&(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(!(typeof t!="object"||typeof e!="object"))for(let i in t){let s=t[i];if(i[0]==="_"||s===e[i])delete t[i];else if(s&&typeof s=="object"&&e[i]!==void 0){for(let r in s)(s[r]===e[i][r]||r[0]==="_")&&delete s[r];Object.keys(s).length||delete t[i]}}}static removeInternalForSave(t,e=!0){for(let i in t)(i[0]==="_"||t[i]===null||t[i]===void 0)&&delete t[i];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,(t.w===1||t.w===t.minW)&&delete t.w,(t.h===1||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){let 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 getScrollElement(t){if(!t)return document.scrollingElement||document.documentElement;let e=getComputedStyle(t);return/(auto|scroll)/.test(e.overflow+e.overflowY)?t:this.getScrollElement(t.parentElement)}static updateScrollPosition(t,e,i){let s=t.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight;if(s.top<0||s.bottom>r){let o=s.bottom-r,n=s.top,u=this.getScrollElement(t);if(u!==null){let d=u.scrollTop;s.top<0&&i<0?t.offsetHeight>r?u.scrollTop+=i:u.scrollTop+=Math.abs(n)>Math.abs(i)?i:n:i>0&&(t.offsetHeight>r?u.scrollTop+=i:u.scrollTop+=o>i?i:o),e.top+=u.scrollTop-d}}}static updateScrollResize(t,e,i){let s=this.getScrollElement(e),r=s.clientHeight,o=s===this.getScrollElement()?0:s.getBoundingClientRect().top,n=t.clientY-o,u=nr-i;u?s.scrollBy({behavior:"smooth",top:n-i}):d&&s.scrollBy({behavior:"smooth",top:i-(r-n)})}static clone(t){return t==null||typeof t!="object"?t:t instanceof Array?[...t]:{...t}}static cloneDeep(t){let e=["parentGrid","el","grid","subGrid","engine"],i=h.clone(t);for(let s in i)i.hasOwnProperty(s)&&typeof i[s]=="object"&&s.substring(0,2)!=="__"&&!e.find(r=>r===s)&&(i[s]=h.cloneDeep(t[s]));return i}static cloneNode(t){let e=t.cloneNode(!0);return e.removeAttribute("id"),e}static appendTo(t,e){let i;typeof e=="string"?i=h.getElement(e):i=e,i&&i.appendChild(t)}static addElStyles(t,e){if(e instanceof Object)for(let i in e)e.hasOwnProperty(i)&&(Array.isArray(e[i])?e[i].forEach(s=>{t.style[i]=s}):t.style[i]=e[i])}static initEvent(t,e){let i={type:e.type},s={button:0,which:0,buttons:1,bubbles:!0,cancelable:!0,target:e.target?e.target:t.target};return t.dataTransfer&&(i.dataTransfer=t.dataTransfer),["altKey","ctrlKey","metaKey","shiftKey"].forEach(r=>i[r]=t[r]),["pageX","pageY","clientX","clientY","screenX","screenY"].forEach(r=>i[r]=t[r]),{...i,...s}}static simulateMouseEvent(t,e,i){let s=document.createEvent("MouseEvents");s.initMouseEvent(e,!0,!0,window,1,t.screenX,t.screenY,t.clientX,t.clientY,t.ctrlKey,t.altKey,t.shiftKey,t.metaKey,0,t.target),(i||t.target).dispatchEvent(s)}static getValuesFromTransformedElement(t){let e=document.createElement("div");h.addElStyles(e,{opacity:"0",position:"fixed",top:"0px",left:"0px",width:"1px",height:"1px",zIndex:"-999999"}),t.appendChild(e);let i=e.getBoundingClientRect();return t.removeChild(e),e.remove(),{xScale:1/i.width,yScale:1/i.height,xOffset:i.left,yOffset:i.top}}};var x=class h{constructor(t={}){this.addedNodes=[],this.removedNodes=[],this.column=t.column||12,this.maxRow=t.maxRow,this._float=t.float,this.nodes=t.nodes||[],this.onChange=t.onChange}batchUpdate(t=!0,e=!0){return!!this.batchMode===t?this:(this.batchMode=t,t?(this._prevFloat=this._float,this._float=!0,this.cleanNodes(),this.saveInitial()):(this._float=this._prevFloat,delete this._prevFloat,e&&this._packNodes(),this._notify()),this)}_useEntireRowArea(t,e){return(!this.float||this.batchMode&&!this._prevFloat)&&!this._hasLocked&&(!t._moving||t._skipDown||e.y<=t.y)}_fixCollisions(t,e=t,i,s={}){if(this.sortNodes(-1),i=i||this.collide(t,e),!i)return!1;if(t._moving&&!s.nested&&!this.float&&this.swap(t,i))return!0;let r=e;this._useEntireRowArea(t,e)&&(r={x:0,w:this.column,y:e.y,h:e.h},i=this.collide(t,r,s.skip));let o=!1,n={nested:!0,pack:!1};for(;i=i||this.collide(t,r,s.skip);){let u;if(i.locked||t._moving&&!t._skipDown&&e.y>t.y&&!this.float&&(!this.collide(i,{...i,y:t.y},t)||!this.collide(i,{...i,y:e.y-i.h},t))?(t._skipDown=t._skipDown||e.y>t.y,u=this.moveNode(t,{...e,y:i.y+i.h,...n}),i.locked&&u?a.copyPos(e,t):!i.locked&&u&&s.pack&&(this._packNodes(),e.y=i.y+i.h,a.copyPos(t,e)),o=o||u):u=this.moveNode(i,{...i,y:e.y+e.h,skip:t,...n}),!u)return o;i=void 0}return o}collide(t,e=t,i){let s=t._id,r=i?._id;return this.nodes.find(o=>o._id!==s&&o._id!==r&&a.isIntercepted(o,e))}collideAll(t,e=t,i){let s=t._id,r=i?._id;return this.nodes.filter(o=>o._id!==s&&o._id!==r&&a.isIntercepted(o,e))}directionCollideCoverage(t,e,i){if(!e.rect||!t._rect)return;let s=t._rect,r={...e.rect};r.y>s.y?(r.h+=r.y-s.y,r.y=s.y):r.h+=s.y-r.y,r.x>s.x?(r.w+=r.x-s.x,r.x=s.x):r.w+=s.x-r.x;let o,n=.5;for(let u of i){if(u.locked||!u._rect)break;let d=u._rect,l=Number.MAX_VALUE,f=Number.MAX_VALUE;s.yd.y+d.h&&(l=(d.y+d.h-r.y)/d.h),s.xd.x+d.w&&(f=(d.x+d.w-r.x)/d.w);let g=Math.min(f,l);g>n&&(n=g,o=u)}return e.collide=o,o}cacheRects(t,e,i,s,r,o){return this.nodes.forEach(n=>n._rect={y:n.y*e+i,x:n.x*t+o,w:n.w*t-o-s,h:n.h*e-i-r}),this}swap(t,e){if(!e||e.locked||!t||t.locked)return!1;function i(){let r=e.x,o=e.y;return e.x=t.x,e.y=t.y,t.h!=e.h?(t.x=r,t.y=e.y+e.h):t.w!=e.w?(t.x=e.x+e.w,t.y=o):(t.x=r,t.y=o),t._dirty=e._dirty=!0,!0}let s;if(t.w===e.w&&t.h===e.h&&(t.x===e.x||t.y===e.y)&&(s=a.isTouching(t,e)))return i();if(s!==!1){if(t.w===e.w&&t.x===e.x&&(s||(s=a.isTouching(t,e)))){if(e.y{let d;o.locked||(o.autoPosition=!0,t==="list"&&n&&(d=u[n-1])),this.addNode(o,!1,d)}),s||delete this._inColumnResize,i||this.batchUpdate(!1),this}set float(t){this._float!==t&&(this._float=t||!1,t||this._packNodes()._notify())}get float(){return this._float||!1}sortNodes(t=1){return this.nodes=a.sort(this.nodes,t),this}_packNodes(){return this.batchMode?this:(this.sortNodes(),this.float?this.nodes.forEach(t=>{if(t._updating||t._orig===void 0||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)}):this.nodes.forEach((t,e)=>{if(!t.locked)for(;t.y>0;){let i=e===0?0:t.y-1;if(!(e===0||!this.collide(t,{x:t.x,y:i,w:t.w,h:t.h})))break;t._dirty=t.y!==i,t.y=i}}),this)}prepareNode(t,e){t._id=t._id??h._idSeq++,(t.x===void 0||t.y===void 0||t.x===null||t.y===null)&&(t.autoPosition=!0);let i={x:0,y:0,w:1,h:1};return a.defaults(t,i),t.autoPosition||delete t.autoPosition,t.noResize||delete t.noResize,t.noMove||delete t.noMove,a.sanitizeMinMax(t),typeof t.x=="string"&&(t.x=Number(t.x)),typeof t.y=="string"&&(t.y=Number(t.y)),typeof t.w=="string"&&(t.w=Number(t.w)),typeof t.h=="string"&&(t.h=Number(t.h)),isNaN(t.x)&&(t.x=i.x,t.autoPosition=!0),isNaN(t.y)&&(t.y=i.y,t.autoPosition=!0),isNaN(t.w)&&(t.w=i.w),isNaN(t.h)&&(t.h=i.h),this.nodeBoundFix(t,e),t}nodeBoundFix(t,e){let i=t._orig||a.copyPos({},t);if(t.maxW&&(t.w=Math.min(t.w,t.maxW)),t.maxH&&(t.h=Math.min(t.h,t.maxH)),t.minW&&t.minW<=this.column&&(t.w=Math.max(t.w,t.minW)),t.minH&&(t.h=Math.max(t.h,t.minH)),(t.x||0)+(t.w||1)>this.column&&this.column<12&&!this._inColumnResize&&t._id&&this.findCacheLayout(t,12)===-1){let r={...t};r.autoPosition||r.x===void 0?(delete r.x,delete r.y):r.x=Math.min(11,r.x),r.w=Math.min(12,r.w||1),this.cacheOneLayout(r,12)}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),a.samePos(t,i)||(t._dirty=!0),this}getDirtyNodes(t){return t?this.nodes.filter(e=>e._dirty&&!a.samePos(e,e._orig)):this.nodes.filter(e=>e._dirty)}_notify(t){if(this.batchMode||!this.onChange)return this;let e=(t||[]).concat(this.getDirtyNodes());return this.onChange(e),this}cleanNodes(){return this.batchMode?this:(this.nodes.forEach(t=>{delete t._dirty,delete t._lastTried}),this)}saveInitial(){return this.nodes.forEach(t=>{t._orig=a.copyPos({},t),delete t._dirty}),this._hasLocked=this.nodes.some(t=>t.locked),this}restoreInitial(){return this.nodes.forEach(t=>{a.samePos(t,t._orig)||(a.copyPos(t,t._orig),t._dirty=!0)}),this._notify(),this}findEmptyPosition(t,e=this.nodes,i=this.column,s){let r=s?s.y*i+(s.x+s.w):0,o=!1;for(let n=r;!o;++n){let u=n%i,d=Math.floor(n/i);if(u+t.w>i)continue;let l={x:u,y:d,w:t.w,h:t.h};e.find(f=>a.isIntercepted(l,f))||((t.x!==u||t.y!==d)&&(t._dirty=!0),t.x=u,t.y=d,delete t.autoPosition,o=!0)}return o}addNode(t,e=!1,i){let s=this.nodes.find(o=>o._id===t._id);if(s)return s;this._inColumnResize?this.nodeBoundFix(t):this.prepareNode(t),delete t._temporaryRemoved,delete t._removeDOM;let r;return t.autoPosition&&this.findEmptyPosition(t,this.nodes,this.column,i)&&(delete t.autoPosition,r=!0),this.nodes.push(t),e&&this.addedNodes.push(t),r||this._fixCollisions(t),this.batchMode||this._packNodes()._notify(),t}removeNode(t,e=!0,i=!1){return this.nodes.find(s=>s._id===t._id)?(i&&this.removedNodes.push(t),e&&(t._removeDOM=!0),this.nodes=this.nodes.filter(s=>s._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(s=>s._removeDOM=!0);let i=this.nodes;return this.removedNodes=e?i:[],this.nodes=[],this._notify(i)}moveNodeCheck(t,e){if(!this.changedPosConstrain(t,e))return!1;if(e.pack=!0,!this.maxRow)return this.moveNode(t,e);let i,s=new h({column:this.column,float:this.float,nodes:this.nodes.map(o=>o._id===t._id?(i={...o},i):{...o})});if(!i)return!1;let r=s.moveNode(i,e)&&s.getRow()<=Math.max(this.getRow(),this.maxRow);if(!r&&!e.resizing&&e.collide){let o=e.collide.el.gridstackNode;if(this.swap(t,o))return this._notify(),!0}return r?(s.nodes.filter(o=>o._dirty).forEach(o=>{let n=this.nodes.find(u=>u._id===o._id);n&&(a.copyPos(n,o),n._dirty=!0)}),this._notify(),!0):!1}willItFit(t){if(delete t._willFitPos,!this.maxRow)return!0;let e=new h({column:this.column,float:this.float,nodes:this.nodes.map(s=>({...s}))}),i={...t};return this.cleanupNode(i),delete i.el,delete i._id,delete i.content,delete i.grid,e.addNode(i),e.getRow()<=this.maxRow?(t._willFitPos=a.copyPos({},i),!0):!1}changedPosConstrain(t,e){return e.w=e.w||t.w,e.h=e.h||t.h,t.x!==e.x||t.y!==e.y?!0:(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 i;e.pack===void 0&&!this.batchMode&&(i=e.pack=!0),typeof e.x!="number"&&(e.x=t.x),typeof e.y!="number"&&(e.y=t.y),typeof e.w!="number"&&(e.w=t.w),typeof e.h!="number"&&(e.h=t.h);let s=t.w!==e.w||t.h!==e.h,r=a.copyPos({},t,!0);if(a.copyPos(r,e),this.nodeBoundFix(r,s),a.copyPos(e,r),!e.forceCollide&&a.samePos(t,e))return!1;let o=a.copyPos({},t),n=this.collideAll(t,r,e.skip),u=!0;if(n.length){let d=t._moving&&!e.nested,l=d?this.directionCollideCoverage(t,e,n):n[0];if(d&&l&&t.grid?.opts?.subGridDynamic&&!t.grid._isTemp){let f=a.areaIntercept(e.rect,l._rect),g=a.area(e.rect),p=a.area(l._rect);f/(g.8&&(l.grid.makeSubGrid(l.el,void 0,t),l=void 0)}l?u=!this._fixCollisions(t,r,l,e):(u=!1,i&&delete e.pack)}return u&&(t._dirty=!0,a.copyPos(t,r)),e.pack&&this._packNodes()._notify(),!a.samePos(t,o)}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(){let t=this.nodes.find(e=>e._updating);return t&&(delete t._updating,delete t._skipDown),this}save(t=!0,e){let i=this._layouts?.length,s=i&&this.column!==i-1?this._layouts[i-1]:null,r=[];return this.sortNodes(),this.nodes.forEach(o=>{let n=s?.find(d=>d._id===o._id),u={...o,...n||{}};a.removeInternalForSave(u,!t),e&&e(o,u),r.push(u)}),r}layoutsNodesChange(t){return!this._layouts||this._inColumnResize?this:(this._layouts.forEach((e,i)=>{if(!e||i===this.column)return this;if(i{if(!r._orig)return;let o=e.find(n=>n._id===r._id);o&&(o.y>=0&&r.y!==r._orig.y&&(o.y+=r.y-r._orig.y),r.x!==r._orig.x&&(o.x=Math.round(r.x*s)),r.w!==r._orig.w&&(o.w=Math.round(r.w*s)))})}}),this)}columnChanged(t,e,i="moveScale"){if(!this.nodes.length||!e||t===e)return this;if(i==="none")return this;let s=i==="compact"||i==="list";s&&this.sortNodes(1),et&&this._layouts){let n=this._layouts[e]||[],u=this._layouts.length-1;!n.length&&t!==u&&this._layouts[u]?.length&&(t=u,this._layouts[u].forEach(d=>{let l=o.find(f=>f._id===d._id);l&&(!s&&!d.autoPosition&&(l.x=d.x??l.x,l.y=d.y??l.y),l.w=d.w??l.w,(d.x==null||d.y===void 0)&&(l.autoPosition=!0))})),n.forEach(d=>{let l=o.findIndex(f=>f._id===d._id);if(l!==-1){let f=o[l];if(s){f.w=d.w;return}(d.autoPosition||isNaN(d.x)||isNaN(d.y))&&this.findEmptyPosition(d,r),d.autoPosition||(f.x=d.x??f.x,f.y=d.y??f.y,f.w=d.w??f.w,r.push(f)),o.splice(l,1)}})}if(s)this.compact(i,!1);else{if(o.length)if(typeof i=="function")i(e,t,r,o);else{let n=s?1:e/t,u=i==="move"||i==="moveScale",d=i==="scale"||i==="moveScale";o.forEach(l=>{l.x=e===1?0:u?Math.round(l.x*n):Math.min(l.x,e-1),l.w=e===1||t===1?1:d?Math.round(l.w*n)||1:Math.min(l.w,e),r.push(l)}),o=[]}r=a.sort(r,-1),this._inColumnResize=!0,this.nodes=[],r.forEach(n=>{this.addNode(n,!1),delete n._orig})}return this.nodes.forEach(n=>delete n._orig),this.batchUpdate(!1,!s),delete this._inColumnResize,this}cacheLayout(t,e,i=!1){let s=[];return t.forEach((r,o)=>{if(r._id===void 0){let n=r.id?this.nodes.find(u=>u.id===r.id):void 0;r._id=n?._id??h._idSeq++}s[o]={x:r.x,y:r.y,w:r.w,_id:r._id}}),this._layouts=i?[]:this._layouts||[],this._layouts[e]=s,this}cacheOneLayout(t,e){t._id=t._id??h._idSeq++;let i={x:t.x,y:t.y,w:t.w,_id:t._id};(t.autoPosition||t.x===void 0)&&(delete i.x,delete i.y,t.autoPosition&&(i.autoPosition=!0)),this._layouts=this._layouts||[],this._layouts[e]=this._layouts[e]||[];let s=this.findCacheLayout(t,e);return s===-1?this._layouts[e].push(i):this._layouts[e][s]=i,this}findCacheLayout(t,e){return this._layouts?.[e]?.findIndex(i=>i._id===t._id)??-1}removeNodeFromLayoutCache(t){if(this._layouts)for(let e=0;e0||navigator.msMaxTouchPoints>0),v=class{};function N(h,t){if(h.touches.length>1)return;h.cancelable&&h.preventDefault();let e=h.changedTouches[0],i=document.createEvent("MouseEvents");i.initMouseEvent(t,!0,!0,window,1,e.screenX,e.screenY,e.clientX,e.clientY,!1,!1,!1,!1,0,null),h.target.dispatchEvent(i)}function F(h,t){h.cancelable&&h.preventDefault();let e=document.createEvent("MouseEvents");e.initMouseEvent(t,!0,!0,window,1,h.screenX,h.screenY,h.clientX,h.clientY,!1,!1,!1,!1,0,null),h.target.dispatchEvent(e)}function R(h){v.touchHandled||(v.touchHandled=!0,N(h,"mousedown"))}function S(h){v.touchHandled&&N(h,"mousemove")}function z(h){if(!v.touchHandled)return;v.pointerLeaveTimeout&&(window.clearTimeout(v.pointerLeaveTimeout),delete v.pointerLeaveTimeout);let t=!!c.dragElement;N(h,"mouseup"),t||N(h,"click"),v.touchHandled=!1}function D(h){h.pointerType!=="mouse"&&h.target.releasePointerCapture(h.pointerId)}function B(h){c.dragElement&&h.pointerType!=="mouse"&&F(h,"mouseenter")}function U(h){c.dragElement&&h.pointerType!=="mouse"&&(v.pointerLeaveTimeout=window.setTimeout(()=>{delete v.pointerLeaveTimeout,F(h,"mouseleave")},10))}var H=class h{constructor(t,e,i){this.host=t,this.dir=e,this.option=i,this.moving=!1,this._mouseDown=this._mouseDown.bind(this),this._mouseMove=this._mouseMove.bind(this),this._mouseUp=this._mouseUp.bind(this),this._init()}_init(){let t=this.el=document.createElement("div");return t.classList.add("ui-resizable-handle"),t.classList.add(`${h.prefix}${this.dir}`),t.style.zIndex="100",t.style.userSelect="none",this.host.appendChild(this.el),this.el.addEventListener("mousedown",this._mouseDown),y&&(this.el.addEventListener("touchstart",R),this.el.addEventListener("pointerdown",D)),this}destroy(){return this.moving&&this._mouseUp(this.mouseDownEvent),this.el.removeEventListener("mousedown",this._mouseDown),y&&(this.el.removeEventListener("touchstart",R),this.el.removeEventListener("pointerdown",D)),this.host.removeChild(this.el),delete this.el,delete this.host,this}_mouseDown(t){this.mouseDownEvent=t,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),y&&(this.el.addEventListener("touchmove",S),this.el.addEventListener("touchend",z)),t.stopPropagation(),t.preventDefault()}_mouseMove(t){let 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._triggerEvent("start",this.mouseDownEvent),this._triggerEvent("move",t)),t.stopPropagation()}_mouseUp(t){this.moving&&this._triggerEvent("stop",t),document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp,!0),y&&(this.el.removeEventListener("touchmove",S),this.el.removeEventListener("touchend",z)),delete this.moving,delete this.mouseDownEvent,t.stopPropagation(),t.preventDefault()}_triggerEvent(t,e){return this.option[t]&&this.option[t](e),this}};H.prefix="ui-resizable-";var b=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(){delete this._eventRegister}triggerEvent(t,e){if(!this.disabled&&this._eventRegister&&this._eventRegister[t])return this._eventRegister[t](e)}};var k=class h extends b{constructor(t,e={}){super(),this.el=t,this.option=e,this.rectScale={x:1,y:1},this._ui=()=>{let s=this.el.parentElement.getBoundingClientRect(),r={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,top:this.originalRect.top-this.scrolled},o=this.temporalRect||r;return{position:{left:(o.left-s.left)*this.rectScale.x,top:(o.top-s.top)*this.rectScale.y},size:{width:o.width*this.rectScale.x,height:o.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(){this._removeHandlers(),this._setupAutoHide(!1),delete this.el,super.destroy()}updateOption(t){let e=t.handles&&t.handles!==this.option.handles,i=t.autoHide&&t.autoHide!==this.option.autoHide;return Object.keys(t).forEach(s=>this.option[s]=t[s]),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),c.overResizeElement===this&&delete c.overResizeElement),this}_mouseOver(t){c.overResizeElement||c.dragElement||(c.overResizeElement=this,this.el.classList.remove("ui-resizable-autohide"))}_mouseOut(t){c.overResizeElement===this&&(delete c.overResizeElement,this.el.classList.add("ui-resizable-autohide"))}_setupHandlers(){return this.handlers=this.option.handles.split(",").map(t=>t.trim()).map(t=>new H(this.el,t,{start:e=>{this._resizeStart(e)},stop:e=>{this._resizeStop(e)},move:e=>{this._resizing(e,t)}})),this}_resizeStart(t){this.sizeToContent=a.shouldSizeToContent(this.el.gridstackNode,!0),this.originalRect=this.el.getBoundingClientRect(),this.scrollEl=a.getScrollElement(this.el),this.scrollY=this.scrollEl.scrollTop,this.scrolled=0,this.startEvent=t,this._setupHelper(),this._applyChange();let e=a.initEvent(t,{type:"resizestart",target:this.el});return 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();let i=a.initEvent(t,{type:"resize",target:this.el});return this.option.resize&&this.option.resize(i,this._ui()),this.triggerEvent("resize",i),this}_resizeStop(t){let e=a.initEvent(t,{type:"resizestop",target:this.el});return this.option.stop&&this.option.stop(e),this.el.classList.remove("ui-resizable-resizing"),this.triggerEvent("resizestop",e),this._cleanHelper(),delete this.startEvent,delete this.originalRect,delete this.temporalRect,delete this.scrollY,delete this.scrolled,this}_setupHelper(){this.elOriginStyleVal=h._originStyleProp.map(i=>this.el.style[i]),this.parentOriginStylePosition=this.el.parentElement.style.position;let t=this.el.parentElement,e=a.getValuesFromTransformedElement(t);return this.rectScale={x:e.xScale,y:e.yScale},getComputedStyle(this.el.parentElement).position.match(/static/)&&(this.el.parentElement.style.position="relative"),this.el.style.position="absolute",this.el.style.opacity="0.8",this}_cleanHelper(){return h._originStyleProp.forEach((t,e)=>{this.el.style[t]=this.elOriginStyleVal[e]||null}),this.el.parentElement.style.position=this.parentOriginStylePosition||null,this}_getChange(t,e){let i=this.startEvent,s={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,top:this.originalRect.top-this.scrolled},r=t.clientX-i.clientX,o=this.sizeToContent?0:t.clientY-i.clientY;e.indexOf("e")>-1?s.width+=r:e.indexOf("w")>-1&&(s.width-=r,s.left+=r),e.indexOf("s")>-1?s.height+=o:e.indexOf("n")>-1&&(s.height-=o,s.top+=o);let n=this._constrainSize(s.width,s.height);return Math.round(s.width)!==Math.round(n.width)&&(e.indexOf("w")>-1&&(s.left+=s.width-n.width),s.width=n.width),Math.round(s.height)!==Math.round(n.height)&&(e.indexOf("n")>-1&&(s.top+=s.height-n.height),s.height=n.height),s}_constrainSize(t,e){let i=this.option.maxWidth||Number.MAX_SAFE_INTEGER,s=this.option.minWidth/this.rectScale.x||t,r=this.option.maxHeight||Number.MAX_SAFE_INTEGER,o=this.option.minHeight/this.rectScale.y||e,n=Math.min(i,Math.max(s,t)),u=Math.min(r,Math.max(o,e));return{width:n,height:u}}_applyChange(){let t={left:0,top:0,width:0,height:0};if(this.el.style.position==="absolute"){let e=this.el.parentElement,{left:i,top:s}=e.getBoundingClientRect();t={left:i,top:s,width:0,height:0}}return this.temporalRect?(Object.keys(this.temporalRect).forEach(e=>{let i=this.temporalRect[e],s=e==="width"||e==="left"?this.rectScale.x:e==="height"||e==="top"?this.rectScale.y:1;this.el.style[e]=(i-t[e])*s+"px"}),this):this}_removeHandlers(){return this.handlers.forEach(t=>t.destroy()),delete this.handlers,this}};k._originStyleProp=["width","height","position","left","top","opacity","zIndex"];var X='input,textarea,button,select,option,[contenteditable="true"],.ui-resizable-handle',T=class h extends b{constructor(t,e={}){super(),this.el=t,this.option=e,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0};let i=e.handle.substring(1);this.dragEl=t.classList.contains(i)?t:t.querySelector(e.handle)||t,this._mouseDown=this._mouseDown.bind(this),this._mouseMove=this._mouseMove.bind(this),this._mouseUp=this._mouseUp.bind(this),this.enable()}on(t,e){super.on(t,e)}off(t){super.off(t)}enable(){this.disabled!==!1&&(super.enable(),this.dragEl.addEventListener("mousedown",this._mouseDown),y&&(this.dragEl.addEventListener("touchstart",R),this.dragEl.addEventListener("pointerdown",D)),this.el.classList.remove("ui-draggable-disabled"))}disable(t=!1){this.disabled!==!0&&(super.disable(),this.dragEl.removeEventListener("mousedown",this._mouseDown),y&&(this.dragEl.removeEventListener("touchstart",R),this.dragEl.removeEventListener("pointerdown",D)),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.helper,delete this.option,super.destroy()}updateOption(t){return Object.keys(t).forEach(e=>this.option[e]=t[e]),this}_mouseDown(t){if(!c.mouseHandled)return t.button!==0||t.target.closest(X)||this.option.cancel&&t.target.closest(this.option.cancel)||(this.mouseDownEvent=t,delete this.dragging,delete c.dragElement,delete c.dropElement,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),y&&(this.dragEl.addEventListener("touchmove",S),this.dragEl.addEventListener("touchend",z)),t.preventDefault(),document.activeElement&&document.activeElement.blur(),c.mouseHandled=!0),!0}_callDrag(t){if(!this.dragging)return;let e=a.initEvent(t,{target:this.el,type:"drag"});this.option.drag&&this.option.drag(e,this.ui()),this.triggerEvent("drag",e)}_mouseMove(t){let e=this.mouseDownEvent;if(this.dragging)if(this._dragFollow(t),c.pauseDrag){let i=Number.isInteger(c.pauseDrag)?c.pauseDrag:100;this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>this._callDrag(t),i)}else this._callDrag(t);else if(Math.abs(t.x-e.x)+Math.abs(t.y-e.y)>3){this.dragging=!0,c.dragElement=this;let i=this.el.gridstackNode?.grid;i?c.dropElement=i.el.ddElement.ddDroppable:delete c.dropElement,this.helper=this._createHelper(t),this._setupHelperContainmentStyle(),this.dragTransform=a.getValuesFromTransformedElement(this.helperContainment),this.dragOffset=this._getDragOffset(t,this.el,this.helperContainment);let s=a.initEvent(t,{target:this.el,type:"dragstart"});this._setupHelperStyle(t),this.option.start&&this.option.start(s,this.ui()),this.triggerEvent("dragstart",s)}return!0}_mouseUp(t){if(document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp,!0),y&&(this.dragEl.removeEventListener("touchmove",S,!0),this.dragEl.removeEventListener("touchend",z,!0)),this.dragging){delete this.dragging,c.dropElement?.el===this.el.parentElement&&delete c.dropElement,this.helperContainment.style.position=this.parentOriginStylePosition||null,this.helper===this.el?this._removeHelperStyle():this.helper.remove();let e=a.initEvent(t,{target:this.el,type:"dragstop"});this.option.stop&&this.option.stop(e),this.triggerEvent("dragstop",e),c.dropElement&&c.dropElement.drop(t)}delete this.helper,delete this.mouseDownEvent,delete c.dragElement,delete c.dropElement,delete c.mouseHandled,t.preventDefault()}_createHelper(t){let e=this.el;return typeof this.option.helper=="function"?e=this.option.helper(t):this.option.helper==="clone"&&(e=a.cloneNode(this.el)),document.body.contains(e)||a.appendTo(e,this.option.appendTo==="parent"?this.el.parentElement:this.option.appendTo),e===this.el&&(this.dragElementOriginStyle=h.originStyleProp.map(i=>this.el.style[i])),e}_setupHelperStyle(t){this.helper.classList.add("ui-draggable-dragging");let e=this.helper.style;return e.pointerEvents="none",e.width=this.dragOffset.width+"px",e.height=this.dragOffset.height+"px",e.willChange="left, top",e.position="fixed",this._dragFollow(t),e.transition="none",setTimeout(()=>{this.helper&&(e.transition=null)},0),this}_removeHelperStyle(){if(this.helper.classList.remove("ui-draggable-dragging"),!this.helper?.gridstackNode?._isAboutToRemove&&this.dragElementOriginStyle){let e=this.helper,i=this.dragElementOriginStyle.transition||null;e.style.transition=this.dragElementOriginStyle.transition="none",h.originStyleProp.forEach(s=>e.style[s]=this.dragElementOriginStyle[s]||null),setTimeout(()=>e.style.transition=i,50)}return delete this.dragElementOriginStyle,this}_dragFollow(t){let e={left:0,top:0},i=this.helper.style,s=this.dragOffset;i.left=(t.clientX+s.offsetLeft-e.left)*this.dragTransform.xScale+"px",i.top=(t.clientY+s.offsetTop-e.top)*this.dragTransform.yScale+"px"}_setupHelperContainmentStyle(){return this.helperContainment=this.helper.parentElement,this.helper.style.position!=="fixed"&&(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,r=0;i&&(s=this.dragTransform.xOffset,r=this.dragTransform.yOffset);let o=e.getBoundingClientRect();return{left:o.left,top:o.top,offsetLeft:-t.clientX+o.left-s,offsetTop:-t.clientY+o.top-r,width:o.width*this.dragTransform.xScale,height:o.height*this.dragTransform.yScale}}ui(){let e=this.el.parentElement.getBoundingClientRect(),i=this.helper.getBoundingClientRect();return{position:{top:(i.top-e.top)*this.dragTransform.yScale,left:(i.left-e.left)*this.dragTransform.xScale}}}};T.originStyleProp=["transition","pointerEvents","position","left","top","minWidth","willChange"];var L=class extends b{constructor(t,e={}){super(),this.el=t,this.option=e,this._mouseEnter=this._mouseEnter.bind(this),this._mouseLeave=this._mouseLeave.bind(this),this.enable(),this._setupAccept()}on(t,e){super.on(t,e)}off(t){super.off(t)}enable(){this.disabled!==!1&&(super.enable(),this.el.classList.add("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"),this.el.addEventListener("mouseenter",this._mouseEnter),this.el.addEventListener("mouseleave",this._mouseLeave),y&&(this.el.addEventListener("pointerenter",B),this.el.addEventListener("pointerleave",U)))}disable(t=!1){this.disabled!==!0&&(super.disable(),this.el.classList.remove("ui-droppable"),t||this.el.classList.add("ui-droppable-disabled"),this.el.removeEventListener("mouseenter",this._mouseEnter),this.el.removeEventListener("mouseleave",this._mouseLeave),y&&(this.el.removeEventListener("pointerenter",B),this.el.removeEventListener("pointerleave",U)))}destroy(){this.disable(!0),this.el.classList.remove("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"),super.destroy()}updateOption(t){return Object.keys(t).forEach(e=>this.option[e]=t[e]),this._setupAccept(),this}_mouseEnter(t){if(!c.dragElement||!this._canDrop(c.dragElement.el))return;t.preventDefault(),t.stopPropagation(),c.dropElement&&c.dropElement!==this&&c.dropElement._mouseLeave(t,!0),c.dropElement=this;let e=a.initEvent(t,{target:this.el,type:"dropover"});this.option.over&&this.option.over(e,this._ui(c.dragElement)),this.triggerEvent("dropover",e),this.el.classList.add("ui-droppable-over")}_mouseLeave(t,e=!1){if(!c.dragElement||c.dropElement!==this)return;t.preventDefault(),t.stopPropagation();let i=a.initEvent(t,{target:this.el,type:"dropout"});if(this.option.out&&this.option.out(i,this._ui(c.dragElement)),this.triggerEvent("dropout",i),c.dropElement===this&&(delete c.dropElement,!e)){let s,r=this.el.parentElement;for(;!s&&r;)s=r.ddElement?.ddDroppable,r=r.parentElement;s&&s._mouseEnter(t)}}drop(t){t.preventDefault();let e=a.initEvent(t,{target:this.el,type:"drop"});this.option.drop&&this.option.drop(e,this._ui(c.dragElement)),this.triggerEvent("drop",e)}_canDrop(t){return t&&(!this.accept||this.accept(t))}_setupAccept(){return this.option.accept?(typeof this.option.accept=="string"?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()}}};var A=class h{static init(t){return t.ddElement||(t.ddElement=new h(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 T(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 k(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 L(this.el,t),this}cleanDroppable(){return this.ddDroppable&&(this.ddDroppable.destroy(),delete this.ddDroppable),this}};var O=class{resizable(t,e,i,s){return this._getDDElements(t).forEach(r=>{if(e==="disable"||e==="enable")r.ddResizable&&r.ddResizable[e]();else if(e==="destroy")r.ddResizable&&r.cleanResizable();else if(e==="option")r.setupResizable({[i]:s});else{let n=r.el.gridstackNode.grid,u=r.el.getAttribute("gs-resize-handles")||n.opts.resizable.handles||"e,s,se";u==="all"&&(u="n,e,s,w,se,sw,ne,nw");let d=!n.opts.alwaysShowResizeHandle;r.setupResizable({...n.opts.resizable,handles:u,autoHide:d,start:e.start,stop:e.stop,resize:e.resize})}}),this}draggable(t,e,i,s){return this._getDDElements(t).forEach(r=>{if(e==="disable"||e==="enable")r.ddDraggable&&r.ddDraggable[e]();else if(e==="destroy")r.ddDraggable&&r.cleanDraggable();else if(e==="option")r.setupDraggable({[i]:s});else{let o=r.el.gridstackNode.grid;r.setupDraggable({...o.opts.draggable,start:e.start,stop:e.stop,drag:e.drag})}}),this}dragIn(t,e){return this._getDDElements(t).forEach(i=>i.setupDraggable(e)),this}droppable(t,e,i,s){return typeof e.accept=="function"&&!e._accept&&(e._accept=e.accept,e.accept=r=>e._accept(r)),this._getDDElements(t).forEach(r=>{e==="disable"||e==="enable"?r.ddDroppable&&r.ddDroppable[e]():e==="destroy"?r.ddDroppable&&r.cleanDroppable():e==="option"?r.setupDroppable({[i]:s}):r.setupDroppable(e)}),this}isDroppable(t){return!!(t&&t.ddElement&&t.ddElement.ddDroppable&&!t.ddElement.ddDroppable.disabled)}isDraggable(t){return!!(t&&t.ddElement&&t.ddElement.ddDraggable&&!t.ddElement.ddDraggable.disabled)}isResizable(t){return!!(t&&t.ddElement&&t.ddElement.ddResizable&&!t.ddElement.ddResizable.disabled)}on(t,e,i){return this._getDDElements(t).forEach(s=>s.on(e,r=>{i(r,c.dragElement?c.dragElement.el:r.target,c.dragElement?c.dragElement.helper:null)})),this}off(t,e){return this._getDDElements(t).forEach(i=>i.off(e)),this}_getDDElements(t,e=!0){let i=a.getElements(t);if(!i.length)return[];let s=i.map(r=>r.ddElement||(e?A.init(r):null));return e||s.filter(r=>r),s}};var m=new O,E=class h{static init(t={},e=".grid-stack"){if(typeof document>"u")return null;let i=h.getGridElement(e);return i?(i.gridstack||(i.gridstack=new h(i,a.cloneDeep(t))),i.gridstack):(console.error(typeof e=="string"?'GridStack.initAll() no grid was found with selector "'+e+`" - element missing or wrong selector ? -Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.`:"GridStack.init() no grid element was passed."),null)}static initAll(t={},e=".grid-stack"){let i=[];return typeof document>"u"||(h.getGridElements(e).forEach(s=>{s.gridstack||(s.gridstack=new h(s,a.cloneDeep(t))),i.push(s.gridstack)}),i.length===0&&console.error('GridStack.initAll() no grid was found with selector "'+e+`" - element missing or wrong selector ? -Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.`)),i}static addGrid(t,e={}){if(!t)return null;let i=t;if(i.gridstack){let o=i.gridstack;return e&&(o.opts={...o.opts,...e}),e.children!==void 0&&o.load(e.children),o}if(!t.classList.contains("grid-stack")||h.addRemoveCB)if(h.addRemoveCB)i=h.addRemoveCB(t,e,!0,!0);else{let o=document.implementation.createHTMLDocument("");o.body.innerHTML=`
`,i=o.body.children[0],t.appendChild(i)}return h.init(e,i)}static registerEngine(t){h.engineClass=t}get placeholder(){if(!this._placeholder){let t=document.createElement("div");t.className="placeholder-content",this.opts.placeholderText&&(t.innerHTML=this.opts.placeholderText),this._placeholder=document.createElement("div"),this._placeholder.classList.add(this.opts.placeholderClass,_.itemClass,this.opts.itemClass),this.placeholder.appendChild(t)}return this._placeholder}constructor(t,e={}){this.el=t,this.opts=e,this._gsEventHandler={},this._extraDragRow=0,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0},t.gridstack=this,e=e||{},t.classList.contains("grid-stack")||this.el.classList.add("grid-stack"),e.row&&(e.minRow=e.maxRow=e.row,delete e.row);let i=a.toNumber(t.getAttribute("gs-row"));e.column==="auto"&&delete e.column,e.alwaysShowResizeHandle!==void 0&&(e._alwaysShowResizeHandle=e.alwaysShowResizeHandle);let s=e.columnOpts?.breakpoints,r=e;if(r.oneColumnModeDomSort&&(delete r.oneColumnModeDomSort,console.log("warning: Gridstack oneColumnModeDomSort no longer supported. Use GridStackOptions.columnOpts instead.")),r.oneColumnSize||r.disableOneColumnMode===!1){let f=r.oneColumnSize||768;delete r.oneColumnSize,delete r.disableOneColumnMode,e.columnOpts=e.columnOpts||{},s=e.columnOpts.breakpoints=e.columnOpts.breakpoints||[];let g=s.find(p=>p.c===1);g?g.w=f:(g={c:1,w:f},s.push(g,{c:12,w:f+1}))}let o=e.columnOpts;o&&(!o.columnWidth&&!o.breakpoints?.length?(delete e.columnOpts,s=void 0):o.columnMax=o.columnMax||12),s?.length>1&&s.sort((f,g)=>(g.w||0)-(f.w||0));let n={...a.cloneDeep(_),column:a.toNumber(t.getAttribute("gs-column"))||_.column,minRow:i||a.toNumber(t.getAttribute("gs-min-row"))||_.minRow,maxRow:i||a.toNumber(t.getAttribute("gs-max-row"))||_.maxRow,staticGrid:a.toBool(t.getAttribute("gs-static"))||_.staticGrid,draggable:{handle:(e.handleClass?"."+e.handleClass:e.handle?e.handle:"")||_.draggable.handle},removableOptions:{accept:e.itemClass||_.removableOptions.accept,decline:_.removableOptions.decline}};t.getAttribute("gs-animate")&&(n.animate=a.toBool(t.getAttribute("gs-animate"))),e=a.defaults(e,n),this._initMargin(),this.checkDynamicColumn(),this.el.classList.add("gs-"+e.column),e.rtl==="auto"&&(e.rtl=t.style.direction==="rtl"),e.rtl&&this.el.classList.add("grid-stack-rtl");let u=this.el.parentElement?.parentElement,d=u?.classList.contains(_.itemClass)?u.gridstackNode:void 0;d&&(d.subGrid=this,this.parentGridItem=d,this.el.classList.add("grid-stack-nested"),d.el.classList.add("grid-stack-sub-grid")),this._isAutoCellHeight=e.cellHeight==="auto",this._isAutoCellHeight||e.cellHeight==="initial"?this.cellHeight(void 0,!1):(typeof e.cellHeight=="number"&&e.cellHeightUnit&&e.cellHeightUnit!==_.cellHeightUnit&&(e.cellHeight=e.cellHeight+e.cellHeightUnit,delete e.cellHeightUnit),this.cellHeight(e.cellHeight,!1)),e.alwaysShowResizeHandle==="mobile"&&(e.alwaysShowResizeHandle=y),this._styleSheetClass="gs-id-"+x._idSeq++,this.el.classList.add(this._styleSheetClass),this._setStaticClass();let l=e.engineClass||h.engineClass||x;if(this.engine=new l({column:this.getColumn(),float:e.float,maxRow:e.maxRow,onChange:f=>{let g=0;this.engine.nodes.forEach(p=>{g=Math.max(g,p.y+p.h)}),f.forEach(p=>{let w=p.el;w&&(p._removeDOM?(w&&w.remove(),delete p._removeDOM):this._writePosAttr(w,p))}),this._updateStyles(!1,g)}}),this._updateStyles(!1,0),e.auto&&(this.batchUpdate(),this.getGridItems().forEach(f=>this._prepareElement(f)),this.batchUpdate(!1)),e.children){let f=e.children;delete e.children,f.length&&this.load(f)}this.setAnimation(e.animate),e.subGridDynamic&&!c.pauseDrag&&(c.pauseDrag=!0),e.draggable?.pause!==void 0&&(c.pauseDrag=e.draggable.pause),this._setupRemoveDrop(),this._setupAcceptWidget(),this._updateResizeEvent()}addWidget(t,e){function i(n){return n.el!==void 0||n.x!==void 0||n.y!==void 0||n.w!==void 0||n.h!==void 0||n.content!==void 0}let s,r;if(typeof t=="string"){let n=document.implementation.createHTMLDocument("");n.body.innerHTML=t,s=n.body.children[0]}else if(arguments.length===0||arguments.length===1&&i(t))if(r=e=t,r?.el)s=r.el;else if(h.addRemoveCB)s=h.addRemoveCB(this.el,e,!0,!1);else{let n=e?.content||"",u=document.implementation.createHTMLDocument("");u.body.innerHTML=`
${n}
`,s=u.body.children[0]}else s=t;if(!s)return;if(r=s.gridstackNode,r&&s.parentElement===this.el&&this.engine.nodes.find(n=>n._id===r._id))return s;let o=this._readAttr(s);return e=a.cloneDeep(e)||{},a.defaults(e,o),r=this.engine.prepareNode(e),this._writeAttr(s,e),this._insertNotAppend?this.el.prepend(s):this.el.appendChild(s),this.makeWidget(s,e),s}makeSubGrid(t,e,i,s=!0){let r=t.gridstackNode;if(r||(r=this.makeWidget(t).gridstackNode),r.subGrid?.el)return r.subGrid;let o,n=this;for(;n&&!o;)o=n.opts?.subGridOpts,n=n.parentGridItem?.grid;e=a.cloneDeep({...o||{},children:void 0,...e||r.subGridOpts||{}}),r.subGridOpts=e;let u;e.column==="auto"&&(u=!0,e.column=Math.max(r.w||1,i?.w||1),delete e.columnOpts);let d=r.el.querySelector(".grid-stack-item-content"),l,f;if(s){if(this._removeDD(r.el),f={...r,x:0,y:0},a.removeInternalForSave(f),delete f.subGridOpts,r.content&&(f.content=r.content,delete r.content),h.addRemoveCB)l=h.addRemoveCB(this.el,f,!0,!1);else{let p=document.implementation.createHTMLDocument("");p.body.innerHTML='
',l=p.body.children[0],l.appendChild(d),p.body.innerHTML='
',d=p.body.children[0],r.el.appendChild(d)}this._prepareDragDropByNode(r)}if(i){let p=u?e.column:r.w,w=r.h+i.h,M=r.el.style;M.transition="none",this.update(r.el,{w:p,h:w}),setTimeout(()=>M.transition=null)}let g=r.subGrid=h.addGrid(d,e);return i?._moving&&(g._isTemp=!0),u&&(g._autoColumn=!0),s&&g.addWidget(l,f),i&&(i._moving?window.setTimeout(()=>a.simulateMouseEvent(i._event,"mouseenter",g.el),0):g.addWidget(r.el,r)),g}removeAsSubGrid(t){let e=this.parentGridItem?.grid;e&&(e.batchUpdate(),e.removeWidget(this.parentGridItem.el,!0,!0),this.engine.nodes.forEach(i=>{i.x+=this.parentGridItem.x,i.y+=this.parentGridItem.y,e.addWidget(i.el,i)}),e.batchUpdate(!1),this.parentGridItem&&delete this.parentGridItem.subGrid,delete this.parentGridItem,t&&window.setTimeout(()=>a.simulateMouseEvent(t._event,"mouseenter",e.el),0))}save(t=!0,e=!1,i=h.saveCB){let s=this.engine.save(t,i);if(s.forEach(r=>{if(t&&r.el&&!r.subGrid&&!i){let o=r.el.querySelector(".grid-stack-item-content");r.content=o?o.innerHTML:void 0,r.content||delete r.content}else if(!t&&!i&&delete r.content,r.subGrid?.el){let o=r.subGrid.save(t,e,i);r.subGridOpts=e?o:{children:o},delete r.subGrid}delete r.el}),e){let r=a.cloneDeep(this.opts);r.marginBottom===r.marginTop&&r.marginRight===r.marginLeft&&r.marginTop===r.marginRight&&(r.margin=r.marginTop,delete r.marginTop,delete r.marginRight,delete r.marginBottom,delete r.marginLeft),r.rtl===(this.el.style.direction==="rtl")&&(r.rtl="auto"),this._isAutoCellHeight&&(r.cellHeight="auto"),this._autoColumn&&(r.column="auto");let o=r._alwaysShowResizeHandle;return delete r._alwaysShowResizeHandle,o!==void 0?r.alwaysShowResizeHandle=o:delete r.alwaysShowResizeHandle,a.removeInternalAndSame(r,_),r.children=s,r}return s}load(t,e=h.addRemoveCB||!0){t=a.cloneDeep(t);let i=this.getColumn(),s=t.filter(l=>(l.x===void 0||l.y===void 0)&&!a.find(this.engine.nodes,l.id));s.length&&s.length!==t.length?t=t.filter(l=>!a.find(s,l.id)):s=[];let r=t.some(l=>l.x!==void 0||l.y!==void 0);r&&(t=a.sort(t,-1)),this._insertNotAppend=r,t.some(l=>(l.x||0)+(l.w||1)>i)&&(this._ignoreLayoutsNodeChange=!0,this.engine.cacheLayout(t,12,!0));let o=h.addRemoveCB;typeof e=="function"&&(h.addRemoveCB=e);let n=[];this.batchUpdate();let u=!this.engine.nodes.length;u&&this.setAnimation(!1),e&&[...this.engine.nodes].forEach(f=>{if(!f.id)return;a.find(t,f.id)||(h.addRemoveCB&&h.addRemoveCB(this.el,f,!1,!1),n.push(f),this.removeWidget(f.el,!0,!1))});let d=[];return this.engine.nodes=this.engine.nodes.filter(l=>a.find(t,l.id)?(d.push(l),!1):!0),t.forEach(l=>{let f=a.find(d,l.id);if(f){if(a.shouldSizeToContent(f)&&(l.h=f.h),this.engine.nodeBoundFix(l),(l.autoPosition||l.x===void 0||l.y===void 0)&&(l.w=l.w||f.w,l.h=l.h||f.h,this.engine.findEmptyPosition(l)),this.engine.nodes.push(f),a.samePos(f,l)&&this.moveNode(f,{...l,forceCollide:!0}),this.update(f.el,l),l.subGridOpts?.children){let g=f.el.querySelector(".grid-stack");g&&g.gridstack&&(g.gridstack.load(l.subGridOpts.children),this._insertNotAppend=!0)}}else e&&this.addWidget(l)}),e&&s.forEach(l=>this.addWidget(l)),this.engine.removedNodes=n,this.batchUpdate(!1),delete this._ignoreLayoutsNodeChange,delete this._insertNotAppend,o?h.addRemoveCB=o:delete h.addRemoveCB,u&&this.opts?.animate&&setTimeout(()=>{this.opts&&this.setAnimation(this.opts.animate)}),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&&this.opts.cellHeight!=="auto"&&(!t||!this.opts.cellHeightUnit||this.opts.cellHeightUnit==="px"))return this.opts.cellHeight;if(this.opts.cellHeightUnit==="rem")return this.opts.cellHeight*parseFloat(getComputedStyle(document.documentElement).fontSize);if(this.opts.cellHeightUnit==="em")return this.opts.cellHeight*parseFloat(getComputedStyle(this.el).fontSize);if(this.opts.cellHeightUnit==="cm")return this.opts.cellHeight*(96/2.54);if(this.opts.cellHeightUnit==="mm")return this.opts.cellHeight*(96/2.54)/10;let e=this.el.querySelector("."+this.opts.itemClass);if(e){let s=a.toNumber(e.getAttribute("gs-h"))||1;return Math.round(e.offsetHeight/s)}let i=parseInt(this.el.getAttribute("gs-current-row"));return i?Math.round(this.el.getBoundingClientRect().height/i):this.opts.cellHeight}cellHeight(t,e=!0){if(e&&t!==void 0&&this._isAutoCellHeight!==(t==="auto")&&(this._isAutoCellHeight=t==="auto",this._updateResizeEvent()),(t==="initial"||t==="auto")&&(t=void 0),t===void 0){let s=-this.opts.marginRight-this.opts.marginLeft+this.opts.marginTop+this.opts.marginBottom;t=this.cellWidth()+s}let i=a.parseHeight(t);return this.opts.cellHeightUnit===i.unit&&this.opts.cellHeight===i.h?this:(this.opts.cellHeightUnit=i.unit,this.opts.cellHeight=i.h,this.resizeToContentCheck(),e&&this._updateStyles(!0),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(){let t=this.opts.columnOpts;if(!t||!t.columnWidth&&!t.breakpoints?.length)return!1;let e=this.getColumn(),i=e,s=this._widthOrContainer(!0);if(t.columnWidth)i=Math.min(Math.round(s/t.columnWidth)||1,t.columnMax);else{i=t.columnMax;let r=0;for(;ro.c===i);return this.column(i,r?.layout||t.layout),!0}return!1}compact(t="compact",e=!0){return this.engine.compact(t,e),this._triggerChangeEvent(),this}column(t,e="moveScale"){if(!t||t<1||this.opts.column===t)return this;let i=this.getColumn();return this.opts.column=t,this.engine?(this.engine.column=t,this.el.classList.remove("gs-"+i),this.el.classList.add("gs-"+t),this.engine.columnChanged(i,t,e),this._isAutoCellHeight&&this.cellHeight(),this.resizeToContentCheck(!0),this._ignoreLayoutsNodeChange=!0,this._triggerChangeEvent(),delete this._ignoreLayoutsNodeChange,this):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))}destroy(t=!0){if(this.el)return this.offAll(),this._updateResizeEvent(!0),this.setStatic(!0,!1),this.setAnimation(!1),t?this.el.parentNode.removeChild(this.el):(this.removeAll(t),this.el.classList.remove(this._styleSheetClass),this.el.removeAttribute("gs-current-row")),this._removeStylesheet(),this.parentGridItem&&delete this.parentGridItem.subGrid,delete this.parentGridItem,delete this.opts,delete this._placeholder,delete this.engine,delete this.el.gridstack,delete this.el,this}float(t){return this.opts.float!==t&&(this.opts.float=this.engine.float=t,this._triggerChangeEvent()),this}getFloat(){return this.engine.float}getCellFromPixel(t,e=!1){let i=this.el.getBoundingClientRect(),s;e?s={top:i.top+document.documentElement.scrollTop,left:i.left}:s={top:this.el.offsetTop,left:this.el.offsetLeft};let r=t.left-s.left,o=t.top-s.top,n=i.width/this.getColumn(),u=i.height/parseInt(this.el.getAttribute("gs-current-row"));return{x:Math.floor(r/n),y:Math.floor(o/u)}}getRow(){return Math.max(this.engine.getRow(),this.opts.minRow)}isAreaEmpty(t,e,i,s){return this.engine.isAreaEmpty(t,e,i,s)}makeWidget(t,e){let i=h.getElement(t);this._prepareElement(i,!0,e);let s=i.gridstackNode;return this._updateContainerHeight(),s.subGridOpts&&this.makeSubGrid(i,s.subGridOpts,void 0,!1),this.opts.column===1&&(this._ignoreLayoutsNodeChange=!0),this._triggerAddEvent(),this._triggerChangeEvent(),delete this._ignoreLayoutsNodeChange,i}on(t,e){return t.indexOf(" ")!==-1?(t.split(" ").forEach(s=>this.on(s,e)),this):(t==="change"||t==="added"||t==="removed"||t==="enable"||t==="disable"?(t==="enable"||t==="disable"?this._gsEventHandler[t]=s=>e(s):this._gsEventHandler[t]=s=>e(s,s.detail),this.el.addEventListener(t,this._gsEventHandler[t])):t==="drag"||t==="dragstart"||t==="dragstop"||t==="resizestart"||t==="resize"||t==="resizestop"||t==="dropped"||t==="resizecontent"?this._gsEventHandler[t]=e:console.error("GridStack.on("+t+") event not supported"),this)}off(t){return t.indexOf(" ")!==-1?(t.split(" ").forEach(i=>this.off(i)),this):((t==="change"||t==="added"||t==="removed"||t==="enable"||t==="disable")&&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 h.getElements(t).forEach(s=>{if(s.parentElement&&s.parentElement!==this.el)return;let r=s.gridstackNode;r||(r=this.engine.nodes.find(o=>s===o.el)),r&&(e&&h.addRemoveCB&&h.addRemoveCB(this.el,r,!1,!1),delete s.gridstackNode,this._removeDD(s),this.engine.removeNode(r,e,i),e&&s.parentElement&&s.remove())}),i&&(this._triggerRemoveEvent(),this._triggerChangeEvent()),this}removeAll(t=!0,e=!0){return this.engine.nodes.forEach(i=>{t&&h.addRemoveCB&&h.addRemoveCB(this.el,i,!1,!1),delete i.el.gridstackNode,this.opts.staticGrid||this._removeDD(i.el)}),this.engine.removeAll(t,e),e&&this._triggerRemoveEvent(),this}setAnimation(t){return t?this.el.classList.add("grid-stack-animate"):this.el.classList.remove("grid-stack-animate"),this}hasAnimationCSS(){return this.el.classList.contains("grid-stack-animate")}setStatic(t,e=!0,i=!0){return!!this.opts.staticGrid===t?this:(t?this.opts.staticGrid=!0:delete this.opts.staticGrid,this._setupRemoveDrop(),this._setupAcceptWidget(),this.engine.nodes.forEach(s=>{this._prepareDragDropByNode(s),s.subGrid&&i&&s.subGrid.setStatic(t,e,i)}),e&&this._setStaticClass(),this)}update(t,e){if(arguments.length>2){console.warn("gridstack.ts: `update(el, x, y, w, h)` is deprecated. Use `update(el, {x, w, content, ...})`. It will be removed soon");let i=arguments,s=1;return e={x:i[s++],y:i[s++],w:i[s++],h:i[s++]},this.update(t,e)}return h.getElements(t).forEach(i=>{let s=i?.gridstackNode;if(!s)return;let r=a.cloneDeep(e);this.engine.nodeBoundFix(r),delete r.autoPosition,delete r.id;let o=["x","y","w","h"],n;if(o.some(l=>r[l]!==void 0&&r[l]!==s[l])&&(n={},o.forEach(l=>{n[l]=r[l]!==void 0?r[l]:s[l],delete r[l]})),!n&&(r.minW||r.minH||r.maxW||r.maxH)&&(n={}),r.content!==void 0){let l=i.querySelector(".grid-stack-item-content");l&&l.innerHTML!==r.content&&(l.innerHTML=r.content,s.subGrid?.el&&(l.appendChild(s.subGrid.el),s.subGrid.opts.styleInHead||s.subGrid._updateStyles(!0))),delete r.content}let u=!1,d=!1;for(let l in r)l[0]!=="_"&&s[l]!==r[l]&&(s[l]=r[l],u=!0,d=d||!this.opts.staticGrid&&(l==="noResize"||l==="noMove"||l==="locked"));if(a.sanitizeMinMax(s),n){let l=n.w!==void 0&&n.w!==s.w;this.moveNode(s,n),this.resizeToContentCheck(l,s)}(n||u)&&this._writeAttr(i,s),d&&this._prepareDragDropByNode(s)}),this}moveNode(t,e){this.engine.cleanNodes().beginUpdate(t).moveNode(t,e),this._updateContainerHeight(),this._triggerChangeEvent(),this.engine.endUpdate()}resizeToContent(t){if(!t||(t.classList.remove("size-to-content-max"),!t.clientHeight))return;let e=t.gridstackNode;if(!e)return;let i=e.grid;if(!i||t.parentElement!==i.el)return;let s=i.getCellHeight(!0);if(!s)return;let r=e.h?e.h*s:t.clientHeight,o;if(e.resizeToContentParent&&(o=t.querySelector(e.resizeToContentParent)),o||(o=t.querySelector(h.resizeToContentParent)),!o)return;let n=t.clientHeight-o.clientHeight,u=e.h?e.h*s-n:o.clientHeight,d;if(e.subGrid)d=e.subGrid.getRow()*e.subGrid.getCellHeight(!0);else{let g=o.firstElementChild;if(!g){console.error(`Error: GridStack.resizeToContent() widget id:${e.id} '${h.resizeToContentParent}'.firstElementChild is null, make sure to have a div like container. Skipping sizing.`);return}d=g.getBoundingClientRect().height||u}if(u===d)return;r+=d-u;let l=Math.ceil(r/s),f=Number.isInteger(e.sizeToContent)?e.sizeToContent:0;f&&l>f&&(l=f,t.classList.add("size-to-content-max")),e.minH&&le.maxH&&(l=e.maxH),l!==e.h&&(i._ignoreLayoutsNodeChange=!0,i.moveNode(e,{h:l}),delete i._ignoreLayoutsNodeChange)}resizeToContentCBCheck(t){h.resizeToContentCB?h.resizeToContentCB(t):this.resizeToContent(t)}margin(t){if(!(typeof t=="string"&&t.split(" ").length>1)){let i=a.parseHeight(t);if(this.opts.marginUnit===i.unit&&this.opts.margin===i.h)return}return this.opts.margin=t,this.opts.marginTop=this.opts.marginBottom=this.opts.marginLeft=this.opts.marginRight=void 0,this._initMargin(),this._updateStyles(!0),this}getMargin(){return this.opts.margin}willItFit(t){if(arguments.length>1){console.warn("gridstack.ts: `willItFit(x,y,w,h,autoPosition)` is deprecated. Use `willItFit({x, y,...})`. It will be removed soon");let e=arguments,i=0,s={x:e[i++],y:e[i++],w:e[i++],h:e[i++],autoPosition:e[i++]};return this.willItFit(s)}return this.engine.willItFit(t)}_triggerChangeEvent(){if(this.engine.batchMode)return this;let t=this.engine.getDirtyNodes(!0);return t&&t.length&&(this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(t),this._triggerEvent("change",t)),this.engine.saveInitial(),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(e=>{delete e._dirty});let 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){let t=[...this.engine.removedNodes];this.engine.removedNodes=[],this._triggerEvent("removed",t)}return this}_triggerEvent(t,e){let i=e?new CustomEvent(t,{bubbles:!1,detail:e}):new Event(t);return this.el.dispatchEvent(i),this}_removeStylesheet(){if(this._styles){let t=this.opts.styleInHead?void 0:this.el.parentNode;a.removeStylesheet(this._styleSheetClass,t),delete this._styles}return this}_updateStyles(t=!1,e){if(t&&this._removeStylesheet(),e===void 0&&(e=this.getRow()),this._updateContainerHeight(),this.opts.cellHeight===0)return this;let i=this.opts.cellHeight,s=this.opts.cellHeightUnit,r=`.${this._styleSheetClass} > .${this.opts.itemClass}`;if(!this._styles){let o=this.opts.styleInHead?void 0:this.el.parentNode;if(this._styles=a.createStylesheet(this._styleSheetClass,o,{nonce:this.opts.nonce}),!this._styles)return this;this._styles._max=0,a.addCSSRule(this._styles,r,`height: ${i}${s}`);let n=this.opts.marginTop+this.opts.marginUnit,u=this.opts.marginBottom+this.opts.marginUnit,d=this.opts.marginRight+this.opts.marginUnit,l=this.opts.marginLeft+this.opts.marginUnit,f=`${r} > .grid-stack-item-content`,g=`.${this._styleSheetClass} > .grid-stack-placeholder > .placeholder-content`;a.addCSSRule(this._styles,f,`top: ${n}; right: ${d}; bottom: ${u}; left: ${l};`),a.addCSSRule(this._styles,g,`top: ${n}; right: ${d}; bottom: ${u}; left: ${l};`),a.addCSSRule(this._styles,`${r} > .ui-resizable-n`,`top: ${n};`),a.addCSSRule(this._styles,`${r} > .ui-resizable-s`,`bottom: ${u}`),a.addCSSRule(this._styles,`${r} > .ui-resizable-ne`,`right: ${d}`),a.addCSSRule(this._styles,`${r} > .ui-resizable-e`,`right: ${d}`),a.addCSSRule(this._styles,`${r} > .ui-resizable-se`,`right: ${d}; bottom: ${u}`),a.addCSSRule(this._styles,`${r} > .ui-resizable-nw`,`left: ${l}`),a.addCSSRule(this._styles,`${r} > .ui-resizable-w`,`left: ${l}`),a.addCSSRule(this._styles,`${r} > .ui-resizable-sw`,`left: ${l}; bottom: ${u}`)}if(e=e||this._styles._max,e>this._styles._max){let o=n=>i*n+s;for(let n=this._styles._max+1;n<=e;n++)a.addCSSRule(this._styles,`${r}[gs-y="${n}"]`,`top: ${o(n)}`),a.addCSSRule(this._styles,`${r}[gs-h="${n+1}"]`,`height: ${o(n+1)}`);this._styles._max=e}return this}_updateContainerHeight(){if(!this.engine||this.engine.batchMode)return this;let t=this.parentGridItem,e=this.getRow()+this._extraDragRow,i=this.opts.cellHeight,s=this.opts.cellHeightUnit;if(!i)return this;if(!t){let r=a.parseHeight(getComputedStyle(this.el).minHeight);if(r.h>0&&r.unit===s){let o=Math.floor(r.h/i);e1?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);let i={autoPosition:"gs-auto-position",noResize:"gs-no-resize",noMove:"gs-no-move",locked:"gs-locked",id:"gs-id"};for(let s in i)e[s]?t.setAttribute(i[s],String(e[s])):t.removeAttribute(i[s]);return this}_readAttr(t,e=!0){let i={};i.x=a.toNumber(t.getAttribute("gs-x")),i.y=a.toNumber(t.getAttribute("gs-y")),i.w=a.toNumber(t.getAttribute("gs-w")),i.h=a.toNumber(t.getAttribute("gs-h")),i.autoPosition=a.toBool(t.getAttribute("gs-auto-position")),i.noResize=a.toBool(t.getAttribute("gs-no-resize")),i.noMove=a.toBool(t.getAttribute("gs-no-move")),i.locked=a.toBool(t.getAttribute("gs-locked")),i.id=t.getAttribute("gs-id"),i.maxW=a.toNumber(t.getAttribute("gs-max-w")),i.minW=a.toNumber(t.getAttribute("gs-min-w")),i.maxH=a.toNumber(t.getAttribute("gs-max-h")),i.minH=a.toNumber(t.getAttribute("gs-min-h")),e&&(i.w===1&&t.removeAttribute("gs-w"),i.h===1&&t.removeAttribute("gs-h"),i.maxW&&t.removeAttribute("gs-max-w"),i.minW&&t.removeAttribute("gs-min-w"),i.maxH&&t.removeAttribute("gs-max-h"),i.minH&&t.removeAttribute("gs-min-h"));for(let s in i){if(!i.hasOwnProperty(s))return;!i[s]&&i[s]!==0&&delete i[s]}return i}_setStaticClass(){let 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(){if(!this.el?.clientWidth||this.prevWidth===this.el.clientWidth)return;this.prevWidth=this.el.clientWidth,this.batchUpdate();let t=!1;return this._autoColumn&&this.parentGridItem?this.opts.column!==this.parentGridItem.w&&(this.column(this.parentGridItem.w,"none"),t=!0):t=this.checkDynamicColumn(),this._isAutoCellHeight&&this.cellHeight(),this.engine.nodes.forEach(e=>{e.subGrid&&e.subGrid.onResize()}),this._skipInitialResize||this.resizeToContentCheck(t),delete this._skipInitialResize,this.batchUpdate(!1),this}resizeToContentCheck(t=!1,e=void 0){if(this.engine){if(t&&this.hasAnimationCSS())return setTimeout(()=>this.resizeToContentCheck(!1,e),310);if(e)a.shouldSizeToContent(e)&&this.resizeToContentCBCheck(e.el);else if(this.engine.nodes.some(i=>a.shouldSizeToContent(i))){let i=[...this.engine.nodes];this.batchUpdate(),i.forEach(s=>{a.shouldSizeToContent(s)&&this.resizeToContentCBCheck(s.el)}),this.batchUpdate(!1)}this._gsEventHandler.resizecontent&&this._gsEventHandler.resizecontent(null,e?[e]:this.engine.nodes)}}_updateResizeEvent(t=!1){let e=!this.parentGridItem&&(this._isAutoCellHeight||this.opts.sizeToContent||this.opts.columnOpts||this.engine.nodes.find(i=>i.sizeToContent));return!t&&e&&!this.resizeObserver?(this._sizeThrottle=a.throttle(()=>this.onResize(),this.opts.cellHeightThrottle),this.resizeObserver=new ResizeObserver(()=>this._sizeThrottle()),this.resizeObserver.observe(this.el),this._skipInitialResize=!0):(t||!e)&&this.resizeObserver&&(this.resizeObserver.disconnect(),delete this.resizeObserver,delete this._sizeThrottle),this}static getElement(t=".grid-stack-item"){return a.getElement(t)}static getElements(t=".grid-stack-item"){return a.getElements(t)}static getGridElement(t){return h.getElement(t)}static getGridElements(t){return a.getElements(t)}_initMargin(){let t,e=0,i=[];return typeof this.opts.margin=="string"&&(i=this.opts.margin.split(" ")),i.length===2?(this.opts.marginTop=this.opts.marginBottom=i[0],this.opts.marginLeft=this.opts.marginRight=i[1]):i.length===4?(this.opts.marginTop=i[0],this.opts.marginRight=i[1],this.opts.marginBottom=i[2],this.opts.marginLeft=i[3]):(t=a.parseHeight(this.opts.margin),this.opts.marginUnit=t.unit,e=this.opts.margin=t.h),this.opts.marginTop===void 0?this.opts.marginTop=e:(t=a.parseHeight(this.opts.marginTop),this.opts.marginTop=t.h,delete this.opts.margin),this.opts.marginBottom===void 0?this.opts.marginBottom=e:(t=a.parseHeight(this.opts.marginBottom),this.opts.marginBottom=t.h,delete this.opts.margin),this.opts.marginRight===void 0?this.opts.marginRight=e:(t=a.parseHeight(this.opts.marginRight),this.opts.marginRight=t.h,delete this.opts.margin),this.opts.marginLeft===void 0?this.opts.marginLeft=e:(t=a.parseHeight(this.opts.marginLeft),this.opts.marginLeft=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),this}static getDD(){return m}static setupDragIn(t,e,i=document){e?.pause!==void 0&&(c.pauseDrag=e.pause),e={...$,...e||{}};let s=typeof t=="string"?a.getElements(t,i):t;s.length&&s?.forEach(r=>{m.isDraggable(r)||m.dragIn(r,e)})}movable(t,e){return this.opts.staticGrid?this:(h.getElements(t).forEach(i=>{let s=i.gridstackNode;s&&(e?delete s.noMove:s.noMove=!0,this._prepareDragDropByNode(s))}),this)}resizable(t,e){return this.opts.staticGrid?this:(h.getElements(t).forEach(i=>{let s=i.gridstackNode;s&&(e?delete s.noResize:s.noResize=!0,this._prepareDragDropByNode(s))}),this)}disable(t=!0){if(!this.opts.staticGrid)return this.enableMove(!1,t),this.enableResize(!1,t),this._triggerEvent("disable"),this}enable(t=!0){if(!this.opts.staticGrid)return this.enableMove(!0,t),this.enableResize(!0,t),this._triggerEvent("enable"),this}enableMove(t,e=!0){return this.opts.staticGrid?this:(t?delete this.opts.disableDrag:this.opts.disableDrag=!0,this.engine.nodes.forEach(i=>{this._prepareDragDropByNode(i),i.subGrid&&e&&i.subGrid.enableMove(t,e)}),this)}enableResize(t,e=!0){return this.opts.staticGrid?this:(t?delete this.opts.disableResize:this.opts.disableResize=!0,this.engine.nodes.forEach(i=>{this._prepareDragDropByNode(i),i.subGrid&&e&&i.subGrid.enableResize(t,e)}),this)}_removeDD(t){return m.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 m.droppable(this.el,"destroy"),this;let t,e,i=(s,r,o)=>{let n=r.gridstackNode;if(!n)return;if(o=o||r,!n.grid?.el){o.style.transform=`scale(${1/this.dragTransform.xScale},${1/this.dragTransform.yScale})`;let g=o.getBoundingClientRect();o.style.left=g.x+(this.dragTransform.xScale-1)*(s.clientX-g.x)/this.dragTransform.xScale+"px",o.style.top=g.y+(this.dragTransform.yScale-1)*(s.clientY-g.y)/this.dragTransform.yScale+"px",o.style.transformOrigin="0px 0px"}let u=this.el.getBoundingClientRect(),{top:d,left:l}=o.getBoundingClientRect();l-=u.left,d-=u.top;let f={position:{top:d*this.dragTransform.xScale,left:l*this.dragTransform.yScale}};if(n._temporaryRemoved){if(n.x=Math.max(0,Math.round(l/e)),n.y=Math.max(0,Math.round(d/t)),delete n.autoPosition,this.engine.nodeBoundFix(n),!this.engine.willItFit(n)){if(n.autoPosition=!0,!this.engine.willItFit(n)){m.off(r,"drag");return}n._willFitPos&&(a.copyPos(n,n._willFitPos),delete n._willFitPos)}this._onStartMoving(o,s,f,n,e,t)}else this._dragOrResize(o,s,f,n,e,t)};return m.droppable(this.el,{accept:s=>{let r=s.gridstackNode||this._readAttr(s,!1);if(r?.grid===this)return!0;if(!this.opts.acceptWidgets)return!1;let o=!0;if(typeof this.opts.acceptWidgets=="function")o=this.opts.acceptWidgets(s);else{let n=this.opts.acceptWidgets===!0?".grid-stack-item":this.opts.acceptWidgets;o=s.matches(n)}if(o&&r&&this.opts.maxRow){let n={w:r.w,h:r.h,minW:r.minW,minH:r.minH};o=this.engine.willItFit(n)}return o}}).on(this.el,"dropover",(s,r,o)=>{let n=r.gridstackNode;if(n?.grid===this&&!n._temporaryRemoved)return!1;n?.grid&&n.grid!==this&&!n._temporaryRemoved&&n.grid._leave(r,o),e=this.cellWidth(),t=this.getCellHeight(!0),n||(n=this._readAttr(r,!1)),n.grid||(n._isExternal=!0,r.gridstackNode=n),o=o||r;let u=n.w||Math.round(o.offsetWidth/e)||1,d=n.h||Math.round(o.offsetHeight/t)||1;return n.grid&&n.grid!==this?(r._gridstackNodeOrig||(r._gridstackNodeOrig=n),r.gridstackNode=n={...n,w:u,h:d,grid:this},delete n.x,delete n.y,this.engine.cleanupNode(n).nodeBoundFix(n),n._initDD=n._isExternal=n._temporaryRemoved=!0):(n.w=u,n.h=d,n._temporaryRemoved=!0),h._itemRemoving(n.el,!1),m.on(r,"drag",i),i(s,r,o),!1}).on(this.el,"dropout",(s,r,o)=>{let n=r.gridstackNode;return n&&(!n.grid||n.grid===this)&&(this._leave(r,o),this._isTemp&&this.removeAsSubGrid(n)),!1}).on(this.el,"drop",(s,r,o)=>{let n=r.gridstackNode;if(n?.grid===this&&!n._isExternal)return!1;let u=!!this.placeholder.parentElement;this.placeholder.remove();let d=u&&this.opts.animate;d&&this.setAnimation(!1);let l=r._gridstackNodeOrig;if(delete r._gridstackNodeOrig,u&&l?.grid&&l.grid!==this){let g=l.grid;g.engine.removeNodeFromLayoutCache(l),g.engine.removedNodes.push(l),g._triggerRemoveEvent()._triggerChangeEvent(),g.parentGridItem&&!g.engine.nodes.length&&g.opts.subGridDynamic&&g.removeAsSubGrid()}if(!n||(u&&(this.engine.cleanupNode(n),n.grid=this),delete n.grid._isTemp,m.off(r,"drag"),o!==r?(o.remove(),r.gridstackNode=l,u&&(r=r.cloneNode(!0))):(r.remove(),this._removeDD(r)),!u))return!1;r.gridstackNode=n,n.el=r;let f=n.subGrid?.el?.gridstack;return a.copyPos(n,this._readAttr(this.placeholder)),a.removePositioningStyles(r),this.el.appendChild(r),this._prepareElement(r,!0,n),f&&(f.parentGridItem=n,f.opts.styleInHead||f._updateStyles(!0)),this._updateContainerHeight(),this.engine.addedNodes.push(n),this._triggerAddEvent(),this._triggerChangeEvent(),this.engine.endUpdate(),this._gsEventHandler.dropped&&this._gsEventHandler.dropped({...s,type:"dropped"},l&&l.grid?l:void 0,n),d&&setTimeout(()=>{this.opts&&this.setAnimation(this.opts.animate)}),!1}),this}static _itemRemoving(t,e){let 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(typeof this.opts.removable!="string")return this;let t=document.querySelector(this.opts.removable);return t?(!this.opts.staticGrid&&!m.isDroppable(t)&&m.droppable(t,this.opts.removableOptions).on(t,"dropover",(e,i)=>h._itemRemoving(i,!0)).on(t,"dropout",(e,i)=>h._itemRemoving(i,!1)),this):this}_prepareDragDropByNode(t){let e=t.el,i=t.noMove||this.opts.disableDrag,s=t.noResize||this.opts.disableResize;if(this.opts.staticGrid||i&&s)return t._initDD&&(this._removeDD(e),delete t._initDD),e.classList.add("ui-draggable-disabled","ui-resizable-disabled"),this;if(!t._initDD){let r,o,n=(l,f)=>{this._gsEventHandler[l.type]&&this._gsEventHandler[l.type](l,l.target),r=this.cellWidth(),o=this.getCellHeight(!0),this._onStartMoving(e,l,f,t,r,o)},u=(l,f)=>{this._dragOrResize(e,l,f,t,r,o)},d=l=>{this.placeholder.remove(),delete t._moving,delete t._event,delete t._lastTried;let f=t.w!==t._orig.w,g=l.target;if(!(!g.gridstackNode||g.gridstackNode.grid!==this)){if(t.el=g,t._isAboutToRemove){let p=e.gridstackNode.grid;p._gsEventHandler[l.type]&&p._gsEventHandler[l.type](l,g),p.engine.nodes.push(t),p.removeWidget(e,!0,!0)}else a.removePositioningStyles(g),t._temporaryRemoved?(a.copyPos(t,t._orig),this._writePosAttr(g,t),this.engine.addNode(t)):this._writePosAttr(g,t),this._gsEventHandler[l.type]&&this._gsEventHandler[l.type](l,g);this._extraDragRow=0,this._updateContainerHeight(),this._triggerChangeEvent(),this.engine.endUpdate(),l.type==="resizestop"&&(Number.isInteger(t.sizeToContent)&&(t.sizeToContent=t.h),this.resizeToContentCheck(f,t))}};m.draggable(e,{start:n,stop:d,drag:u}).resizable(e,{start:n,stop:d,resize:u}),t._initDD=!0}return m.draggable(e,i?"disable":"enable").resizable(e,s?"disable":"enable"),this}_onStartMoving(t,e,i,s,r,o){if(this.engine.cleanNodes().beginUpdate(s),this._writePosAttr(this.placeholder,s),this.el.appendChild(this.placeholder),s.grid?.el)this.dragTransform=a.getValuesFromTransformedElement(t);else if(this.placeholder&&this.placeholder.closest(".grid-stack")){let n=this.placeholder.closest(".grid-stack");this.dragTransform=a.getValuesFromTransformedElement(n)}else this.dragTransform={xScale:1,xOffset:0,yScale:1,yOffset:0};s.el=this.placeholder,s._lastUiPosition=i.position,s._prevYPix=i.position.top,s._moving=e.type==="dragstart",delete s._lastTried,e.type==="dropover"&&s._temporaryRemoved&&(this.engine.addNode(s),s._moving=!0),this.engine.cacheRects(r,o,this.opts.marginTop,this.opts.marginRight,this.opts.marginBottom,this.opts.marginLeft),e.type==="resizestart"&&(m.resizable(t,"option","minWidth",r*(s.minW||1)).resizable(t,"option","minHeight",o*(s.minH||1)),s.maxW&&m.resizable(t,"option","maxWidth",r*s.maxW),s.maxH&&m.resizable(t,"option","maxHeight",o*s.maxH))}_dragOrResize(t,e,i,s,r,o){let n={...s._orig},u,d=this.opts.marginLeft,l=this.opts.marginRight,f=this.opts.marginTop,g=this.opts.marginBottom,p=Math.round(o*.1),w=Math.round(r*.1);if(d=Math.min(d,w),l=Math.min(l,w),f=Math.min(f,p),g=Math.min(g,p),e.type==="drag"){if(s._temporaryRemoved)return;let C=i.position.top-s._prevYPix;s._prevYPix=i.position.top,this.opts.draggable.scroll!==!1&&a.updateScrollPosition(t,i.position,C);let P=i.position.left+(i.position.left>s._lastUiPosition.left?-l:d),Y=i.position.top+(i.position.top>s._lastUiPosition.top?-g:f);n.x=Math.round(P/r),n.y=Math.round(Y/o);let q=this._extraDragRow;if(this.engine.collide(s,n)){let G=this.getRow(),I=Math.max(0,n.y+s.h-G);this.opts.maxRow&&G+I>this.opts.maxRow&&(I=Math.max(0,this.opts.maxRow-G)),this._extraDragRow=I}else this._extraDragRow=0;if(this._extraDragRow!==q&&this._updateContainerHeight(),s.x===n.x&&s.y===n.y)return}else if(e.type==="resize"){if(n.x<0||(a.updateScrollResize(e,t,o),n.w=Math.round((i.size.width-d)/r),n.h=Math.round((i.size.height-f)/o),s.w===n.w&&s.h===n.h)||s._lastTried&&s._lastTried.w===n.w&&s._lastTried.h===n.h)return;let C=i.position.left+d,P=i.position.top+f;n.x=Math.round(C/r),n.y=Math.round(P/o),u=!0}s._event=e,s._lastTried=n;let M={x:i.position.left+d,y:i.position.top+f,w:(i.size?i.size.width:s.w*r)-d-l,h:(i.size?i.size.height:s.h*o)-f-g};if(this.engine.moveNodeCheck(s,{...n,cellWidth:r,cellHeight:o,rect:M,resizing:u})){s._lastUiPosition=i.position,this.engine.cacheRects(r,o,f,l,g,d),delete s._skipDown,u&&s.subGrid&&s.subGrid.onResize(),this._extraDragRow=0,this._updateContainerHeight();let C=e.target;this._writePosAttr(C,s),this._gsEventHandler[e.type]&&this._gsEventHandler[e.type](e,C)}}_leave(t,e){let i=t.gridstackNode;i&&(e=e||t,e.style.transform="scale(1)",m.off(t,"drag"),!i._temporaryRemoved&&(i._temporaryRemoved=!0,this.engine.removeNode(i),i.el=i._isExternal&&e?e:t,this.opts.removable===!0&&h._itemRemoving(t,!0),t._gridstackNodeOrig?(t.gridstackNode=t._gridstackNodeOrig,delete t._gridstackNodeOrig):i._isExternal&&(delete i.el,delete t.gridstackNode,this.engine.restoreInitial())))}commit(){return W(this,this.batchUpdate(!1),"commit","batchUpdate","5.2"),this}};E.resizeToContentParent=".grid-stack-item-content";E.Utils=a;E.Engine=x;E.GDRev="10.1.2";function j(){return{grid:null,gridItems:this.$wire.entangle("gridItems"),addItem:function(h,t){this.grid.addWidget({w:12,id:h,content:t})},removeAll:function(){this.grid.removeAll(),this.gridItems=[]},init:function(){this.grid=E.init({cellHeight:80,acceptWidgets:!0,removable:"#trash",alwaysShowResizeHandle:!0,disableOneColumnMode:!0}),this.grid.load(this.gridItems);let h=this;this.grid.on("removed",function(t,e){let i=[];e.forEach(function(s){i=h.gridItems.filter(function(r){return r.id!==s.id})}),h.gridItems=i}),this.grid.on("added",function(t,e){let i=[];e.forEach(function(s){let r={id:s.id,content:s.content,w:s.w,x:s.x,y:s.y};i.push(r)}),h.gridItems=h.gridItems.concat(i)}),this.grid.on("change",function(t,e){h.gridItems.forEach(function(i,s){e.forEach(function(r){r.id===i.id&&(h.gridItems[s].x=r.x,h.gridItems[s].w=r.w,h.gridItems[s].y=r.y)})})})}}}export{j as default}; +function W(d,t,e,i,s){let r=(...n)=>(console.warn("gridstack.js: Function `"+e+"` is deprecated in "+s+" and has been replaced with `"+i+"`. It will be **removed** in a future release"),t.apply(d,n));return r.prototype=t.prototype,r}var a=class d{static getElements(t,e=document){if(typeof t=="string"){let i="getElementById"in e?e:void 0;if(i&&!isNaN(+t[0])){let r=i.getElementById(t);return r?[r]:[]}let s=e.querySelectorAll(t);return!s.length&&t[0]!=="."&&t[0]!=="#"&&(s=e.querySelectorAll("."+t),s.length||(s=e.querySelectorAll("#"+t))),Array.from(s)}return[t]}static getElement(t,e=document){if(typeof t=="string"){let 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 shouldSizeToContent(t,e=!1){return t?.grid&&(e?t.sizeToContent===!0||t.grid.opts.sizeToContent===!0&&t.sizeToContent===void 0:!!t.sizeToContent||t.grid.opts.sizeToContent&&t.sizeToContent!==!1)}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 d.isIntercepted(t,{x:e.x-.5,y:e.y-.5,w:e.w+1,h:e.h+1})}static areaIntercept(t,e){let i=t.x>e.x?t.x:e.x,s=t.x+t.we.y?t.y:e.y,n=t.y+t.h{let n=e*((s.y??1e4)-(r.y??1e4));return n===0?e*((s.x??1e4)-(r.x??1e4)):n})}static find(t,e){return e?t.find(i=>i.id===e):void 0}static createStylesheet(t,e,i){let s=document.createElement("style"),r=i?.nonce;return r&&(s.nonce=r),s.setAttribute("type","text/css"),s.setAttribute("gs-style-id",t),s.styleSheet?s.styleSheet.cssText="":s.appendChild(document.createTextNode("")),e?e.insertBefore(s,e.firstChild):(e=document.getElementsByTagName("head")[0],e.appendChild(s)),s.sheet}static removeStylesheet(t,e){let s=(e||document).querySelector("STYLE[gs-style-id="+t+"]");s&&s.parentNode&&s.remove()}static addCSSRule(t,e,i){typeof t.addRule=="function"?t.addRule(e,i):typeof t.insertRule=="function"&&t.insertRule(`${e}{${i}}`)}static toBool(t){return typeof t=="boolean"?t:typeof t=="string"?(t=t.toLowerCase(),!(t===""||t==="no"||t==="false"||t==="0")):!!t}static toNumber(t){return t===null||t.length===0?void 0:Number(t)}static parseHeight(t){let e,i="px";if(typeof t=="string")if(t==="auto"||t==="")e=0;else{let 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(i=>{for(let s in i){if(!i.hasOwnProperty(s))return;t[s]===null||t[s]===void 0?t[s]=i[s]:typeof i[s]=="object"&&typeof t[s]=="object"&&this.defaults(t[s],i[s])}}),t}static same(t,e){if(typeof t!="object")return t==e;if(typeof t!=typeof e||Object.keys(t).length!==Object.keys(e).length)return!1;for(let i in t)if(t[i]!==e[i])return!1;return!0}static copyPos(t,e,i=!1){return e.x!==void 0&&(t.x=e.x),e.y!==void 0&&(t.y=e.y),e.w!==void 0&&(t.w=e.w),e.h!==void 0&&(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(!(typeof t!="object"||typeof e!="object"))for(let i in t){let s=t[i];if(i[0]==="_"||s===e[i])delete t[i];else if(s&&typeof s=="object"&&e[i]!==void 0){for(let r in s)(s[r]===e[i][r]||r[0]==="_")&&delete s[r];Object.keys(s).length||delete t[i]}}}static removeInternalForSave(t,e=!0){for(let i in t)(i[0]==="_"||t[i]===null||t[i]===void 0)&&delete t[i];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,(t.w===1||t.w===t.minW)&&delete t.w,(t.h===1||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){let 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 getScrollElement(t){if(!t)return document.scrollingElement||document.documentElement;let e=getComputedStyle(t);return/(auto|scroll)/.test(e.overflow+e.overflowY)?t:this.getScrollElement(t.parentElement)}static updateScrollPosition(t,e,i){let s=t.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight;if(s.top<0||s.bottom>r){let n=s.bottom-r,o=s.top,u=this.getScrollElement(t);if(u!==null){let h=u.scrollTop;s.top<0&&i<0?t.offsetHeight>r?u.scrollTop+=i:u.scrollTop+=Math.abs(o)>Math.abs(i)?i:o:i>0&&(t.offsetHeight>r?u.scrollTop+=i:u.scrollTop+=n>i?i:n),e.top+=u.scrollTop-h}}}static updateScrollResize(t,e,i){let s=this.getScrollElement(e),r=s.clientHeight,n=s===this.getScrollElement()?0:s.getBoundingClientRect().top,o=t.clientY-n,u=or-i;u?s.scrollBy({behavior:"smooth",top:o-i}):h&&s.scrollBy({behavior:"smooth",top:i-(r-o)})}static clone(t){return t==null||typeof t!="object"?t:t instanceof Array?[...t]:{...t}}static cloneDeep(t){let e=["parentGrid","el","grid","subGrid","engine"],i=d.clone(t);for(let s in i)i.hasOwnProperty(s)&&typeof i[s]=="object"&&s.substring(0,2)!=="__"&&!e.find(r=>r===s)&&(i[s]=d.cloneDeep(t[s]));return i}static cloneNode(t){let e=t.cloneNode(!0);return e.removeAttribute("id"),e}static appendTo(t,e){let i;typeof e=="string"?i=d.getElement(e):i=e,i&&i.appendChild(t)}static addElStyles(t,e){if(e instanceof Object)for(let i in e)e.hasOwnProperty(i)&&(Array.isArray(e[i])?e[i].forEach(s=>{t.style[i]=s}):t.style[i]=e[i])}static initEvent(t,e){let i={type:e.type},s={button:0,which:0,buttons:1,bubbles:!0,cancelable:!0,target:e.target?e.target:t.target};return t.dataTransfer&&(i.dataTransfer=t.dataTransfer),["altKey","ctrlKey","metaKey","shiftKey"].forEach(r=>i[r]=t[r]),["pageX","pageY","clientX","clientY","screenX","screenY"].forEach(r=>i[r]=t[r]),{...i,...s}}static simulateMouseEvent(t,e,i){let s=document.createEvent("MouseEvents");s.initMouseEvent(e,!0,!0,window,1,t.screenX,t.screenY,t.clientX,t.clientY,t.ctrlKey,t.altKey,t.shiftKey,t.metaKey,0,t.target),(i||t.target).dispatchEvent(s)}static getValuesFromTransformedElement(t){let e=document.createElement("div");d.addElStyles(e,{opacity:"0",position:"fixed",top:"0px",left:"0px",width:"1px",height:"1px",zIndex:"-999999"}),t.appendChild(e);let i=e.getBoundingClientRect();return t.removeChild(e),e.remove(),{xScale:1/i.width,yScale:1/i.height,xOffset:i.left,yOffset:i.top}}};var x=class d{constructor(t={}){this.addedNodes=[],this.removedNodes=[],this.column=t.column||12,this.maxRow=t.maxRow,this._float=t.float,this.nodes=t.nodes||[],this.onChange=t.onChange}batchUpdate(t=!0,e=!0){return!!this.batchMode===t?this:(this.batchMode=t,t?(this._prevFloat=this._float,this._float=!0,this.cleanNodes(),this.saveInitial()):(this._float=this._prevFloat,delete this._prevFloat,e&&this._packNodes(),this._notify()),this)}_useEntireRowArea(t,e){return(!this.float||this.batchMode&&!this._prevFloat)&&!this._hasLocked&&(!t._moving||t._skipDown||e.y<=t.y)}_fixCollisions(t,e=t,i,s={}){if(this.sortNodes(-1),i=i||this.collide(t,e),!i)return!1;if(t._moving&&!s.nested&&!this.float&&this.swap(t,i))return!0;let r=e;this._useEntireRowArea(t,e)&&(r={x:0,w:this.column,y:e.y,h:e.h},i=this.collide(t,r,s.skip));let n=!1,o={nested:!0,pack:!1};for(;i=i||this.collide(t,r,s.skip);){let u;if(i.locked||t._moving&&!t._skipDown&&e.y>t.y&&!this.float&&(!this.collide(i,{...i,y:t.y},t)||!this.collide(i,{...i,y:e.y-i.h},t))?(t._skipDown=t._skipDown||e.y>t.y,u=this.moveNode(t,{...e,y:i.y+i.h,...o}),i.locked&&u?a.copyPos(e,t):!i.locked&&u&&s.pack&&(this._packNodes(),e.y=i.y+i.h,a.copyPos(t,e)),n=n||u):u=this.moveNode(i,{...i,y:e.y+e.h,skip:t,...o}),!u)return n;i=void 0}return n}collide(t,e=t,i){let s=t._id,r=i?._id;return this.nodes.find(n=>n._id!==s&&n._id!==r&&a.isIntercepted(n,e))}collideAll(t,e=t,i){let s=t._id,r=i?._id;return this.nodes.filter(n=>n._id!==s&&n._id!==r&&a.isIntercepted(n,e))}directionCollideCoverage(t,e,i){if(!e.rect||!t._rect)return;let s=t._rect,r={...e.rect};r.y>s.y?(r.h+=r.y-s.y,r.y=s.y):r.h+=s.y-r.y,r.x>s.x?(r.w+=r.x-s.x,r.x=s.x):r.w+=s.x-r.x;let n,o=.5;for(let u of i){if(u.locked||!u._rect)break;let h=u._rect,l=Number.MAX_VALUE,f=Number.MAX_VALUE;s.yh.y+h.h&&(l=(h.y+h.h-r.y)/h.h),s.xh.x+h.w&&(f=(h.x+h.w-r.x)/h.w);let g=Math.min(f,l);g>o&&(o=g,n=u)}return e.collide=n,n}cacheRects(t,e,i,s,r,n){return this.nodes.forEach(o=>o._rect={y:o.y*e+i,x:o.x*t+n,w:o.w*t-n-s,h:o.h*e-i-r}),this}swap(t,e){if(!e||e.locked||!t||t.locked)return!1;function i(){let r=e.x,n=e.y;return e.x=t.x,e.y=t.y,t.h!=e.h?(t.x=r,t.y=e.y+e.h):t.w!=e.w?(t.x=e.x+e.w,t.y=n):(t.x=r,t.y=n),t._dirty=e._dirty=!0,!0}let s;if(t.w===e.w&&t.h===e.h&&(t.x===e.x||t.y===e.y)&&(s=a.isTouching(t,e)))return i();if(s!==!1){if(t.w===e.w&&t.x===e.x&&(s||(s=a.isTouching(t,e)))){if(e.y{let h;n.locked||(n.autoPosition=!0,t==="list"&&o&&(h=u[o-1])),this.addNode(n,!1,h)}),s||delete this._inColumnResize,i||this.batchUpdate(!1),this}set float(t){this._float!==t&&(this._float=t||!1,t||this._packNodes()._notify())}get float(){return this._float||!1}sortNodes(t=1){return this.nodes=a.sort(this.nodes,t),this}_packNodes(){return this.batchMode?this:(this.sortNodes(),this.float?this.nodes.forEach(t=>{if(t._updating||t._orig===void 0||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)}):this.nodes.forEach((t,e)=>{if(!t.locked)for(;t.y>0;){let i=e===0?0:t.y-1;if(!(e===0||!this.collide(t,{x:t.x,y:i,w:t.w,h:t.h})))break;t._dirty=t.y!==i,t.y=i}}),this)}prepareNode(t,e){t._id=t._id??d._idSeq++,(t.x===void 0||t.y===void 0||t.x===null||t.y===null)&&(t.autoPosition=!0);let i={x:0,y:0,w:1,h:1};return a.defaults(t,i),t.autoPosition||delete t.autoPosition,t.noResize||delete t.noResize,t.noMove||delete t.noMove,a.sanitizeMinMax(t),typeof t.x=="string"&&(t.x=Number(t.x)),typeof t.y=="string"&&(t.y=Number(t.y)),typeof t.w=="string"&&(t.w=Number(t.w)),typeof t.h=="string"&&(t.h=Number(t.h)),isNaN(t.x)&&(t.x=i.x,t.autoPosition=!0),isNaN(t.y)&&(t.y=i.y,t.autoPosition=!0),isNaN(t.w)&&(t.w=i.w),isNaN(t.h)&&(t.h=i.h),this.nodeBoundFix(t,e),t}nodeBoundFix(t,e){let i=t._orig||a.copyPos({},t);if(t.maxW&&(t.w=Math.min(t.w,t.maxW)),t.maxH&&(t.h=Math.min(t.h,t.maxH)),t.minW&&t.minW<=this.column&&(t.w=Math.max(t.w,t.minW)),t.minH&&(t.h=Math.max(t.h,t.minH)),(t.x||0)+(t.w||1)>this.column&&this.column<12&&!this._inColumnResize&&t._id&&this.findCacheLayout(t,12)===-1){let r={...t};r.autoPosition||r.x===void 0?(delete r.x,delete r.y):r.x=Math.min(11,r.x),r.w=Math.min(12,r.w||1),this.cacheOneLayout(r,12)}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),a.samePos(t,i)||(t._dirty=!0),this}getDirtyNodes(t){return t?this.nodes.filter(e=>e._dirty&&!a.samePos(e,e._orig)):this.nodes.filter(e=>e._dirty)}_notify(t){if(this.batchMode||!this.onChange)return this;let e=(t||[]).concat(this.getDirtyNodes());return this.onChange(e),this}cleanNodes(){return this.batchMode?this:(this.nodes.forEach(t=>{delete t._dirty,delete t._lastTried}),this)}saveInitial(){return this.nodes.forEach(t=>{t._orig=a.copyPos({},t),delete t._dirty}),this._hasLocked=this.nodes.some(t=>t.locked),this}restoreInitial(){return this.nodes.forEach(t=>{a.samePos(t,t._orig)||(a.copyPos(t,t._orig),t._dirty=!0)}),this._notify(),this}findEmptyPosition(t,e=this.nodes,i=this.column,s){let r=s?s.y*i+(s.x+s.w):0,n=!1;for(let o=r;!n;++o){let u=o%i,h=Math.floor(o/i);if(u+t.w>i)continue;let l={x:u,y:h,w:t.w,h:t.h};e.find(f=>a.isIntercepted(l,f))||((t.x!==u||t.y!==h)&&(t._dirty=!0),t.x=u,t.y=h,delete t.autoPosition,n=!0)}return n}addNode(t,e=!1,i){let s=this.nodes.find(n=>n._id===t._id);if(s)return s;this._inColumnResize?this.nodeBoundFix(t):this.prepareNode(t),delete t._temporaryRemoved,delete t._removeDOM;let r;return t.autoPosition&&this.findEmptyPosition(t,this.nodes,this.column,i)&&(delete t.autoPosition,r=!0),this.nodes.push(t),e&&this.addedNodes.push(t),r||this._fixCollisions(t),this.batchMode||this._packNodes()._notify(),t}removeNode(t,e=!0,i=!1){return this.nodes.find(s=>s._id===t._id)?(i&&this.removedNodes.push(t),e&&(t._removeDOM=!0),this.nodes=this.nodes.filter(s=>s._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(s=>s._removeDOM=!0);let i=this.nodes;return this.removedNodes=e?i:[],this.nodes=[],this._notify(i)}moveNodeCheck(t,e){if(!this.changedPosConstrain(t,e))return!1;if(e.pack=!0,!this.maxRow)return this.moveNode(t,e);let i,s=new d({column:this.column,float:this.float,nodes:this.nodes.map(n=>n._id===t._id?(i={...n},i):{...n})});if(!i)return!1;let r=s.moveNode(i,e)&&s.getRow()<=Math.max(this.getRow(),this.maxRow);if(!r&&!e.resizing&&e.collide){let n=e.collide.el.gridstackNode;if(this.swap(t,n))return this._notify(),!0}return r?(s.nodes.filter(n=>n._dirty).forEach(n=>{let o=this.nodes.find(u=>u._id===n._id);o&&(a.copyPos(o,n),o._dirty=!0)}),this._notify(),!0):!1}willItFit(t){if(delete t._willFitPos,!this.maxRow)return!0;let e=new d({column:this.column,float:this.float,nodes:this.nodes.map(s=>({...s}))}),i={...t};return this.cleanupNode(i),delete i.el,delete i._id,delete i.content,delete i.grid,e.addNode(i),e.getRow()<=this.maxRow?(t._willFitPos=a.copyPos({},i),!0):!1}changedPosConstrain(t,e){return e.w=e.w||t.w,e.h=e.h||t.h,t.x!==e.x||t.y!==e.y?!0:(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 i;e.pack===void 0&&!this.batchMode&&(i=e.pack=!0),typeof e.x!="number"&&(e.x=t.x),typeof e.y!="number"&&(e.y=t.y),typeof e.w!="number"&&(e.w=t.w),typeof e.h!="number"&&(e.h=t.h);let s=t.w!==e.w||t.h!==e.h,r=a.copyPos({},t,!0);if(a.copyPos(r,e),this.nodeBoundFix(r,s),a.copyPos(e,r),!e.forceCollide&&a.samePos(t,e))return!1;let n=a.copyPos({},t),o=this.collideAll(t,r,e.skip),u=!0;if(o.length){let h=t._moving&&!e.nested,l=h?this.directionCollideCoverage(t,e,o):o[0];if(h&&l&&t.grid?.opts?.subGridDynamic&&!t.grid._isTemp){let f=a.areaIntercept(e.rect,l._rect),g=a.area(e.rect),p=a.area(l._rect);f/(g.8&&(l.grid.makeSubGrid(l.el,void 0,t),l=void 0)}l?u=!this._fixCollisions(t,r,l,e):(u=!1,i&&delete e.pack)}return u&&(t._dirty=!0,a.copyPos(t,r)),e.pack&&this._packNodes()._notify(),!a.samePos(t,n)}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(){let t=this.nodes.find(e=>e._updating);return t&&(delete t._updating,delete t._skipDown),this}save(t=!0,e){let i=this._layouts?.length,s=i&&this.column!==i-1?this._layouts[i-1]:null,r=[];return this.sortNodes(),this.nodes.forEach(n=>{let o=s?.find(h=>h._id===n._id),u={...n,...o||{}};a.removeInternalForSave(u,!t),e&&e(n,u),r.push(u)}),r}layoutsNodesChange(t){return!this._layouts||this._inColumnResize?this:(this._layouts.forEach((e,i)=>{if(!e||i===this.column)return this;if(i{if(!r._orig)return;let n=e.find(o=>o._id===r._id);n&&(n.y>=0&&r.y!==r._orig.y&&(n.y+=r.y-r._orig.y),r.x!==r._orig.x&&(n.x=Math.round(r.x*s)),r.w!==r._orig.w&&(n.w=Math.round(r.w*s)))})}}),this)}columnChanged(t,e,i="moveScale"){if(!this.nodes.length||!e||t===e)return this;if(i==="none")return this;let s=i==="compact"||i==="list";s&&this.sortNodes(1),et&&this._layouts){let o=this._layouts[e]||[],u=this._layouts.length-1;!o.length&&t!==u&&this._layouts[u]?.length&&(t=u,this._layouts[u].forEach(h=>{let l=n.find(f=>f._id===h._id);l&&(!s&&!h.autoPosition&&(l.x=h.x??l.x,l.y=h.y??l.y),l.w=h.w??l.w,(h.x==null||h.y===void 0)&&(l.autoPosition=!0))})),o.forEach(h=>{let l=n.findIndex(f=>f._id===h._id);if(l!==-1){let f=n[l];if(s){f.w=h.w;return}(h.autoPosition||isNaN(h.x)||isNaN(h.y))&&this.findEmptyPosition(h,r),h.autoPosition||(f.x=h.x??f.x,f.y=h.y??f.y,f.w=h.w??f.w,r.push(f)),n.splice(l,1)}})}if(s)this.compact(i,!1);else{if(n.length)if(typeof i=="function")i(e,t,r,n);else{let o=s?1:e/t,u=i==="move"||i==="moveScale",h=i==="scale"||i==="moveScale";n.forEach(l=>{l.x=e===1?0:u?Math.round(l.x*o):Math.min(l.x,e-1),l.w=e===1||t===1?1:h?Math.round(l.w*o)||1:Math.min(l.w,e),r.push(l)}),n=[]}r=a.sort(r,-1),this._inColumnResize=!0,this.nodes=[],r.forEach(o=>{this.addNode(o,!1),delete o._orig})}return this.nodes.forEach(o=>delete o._orig),this.batchUpdate(!1,!s),delete this._inColumnResize,this}cacheLayout(t,e,i=!1){let s=[];return t.forEach((r,n)=>{if(r._id===void 0){let o=r.id?this.nodes.find(u=>u.id===r.id):void 0;r._id=o?._id??d._idSeq++}s[n]={x:r.x,y:r.y,w:r.w,_id:r._id}}),this._layouts=i?[]:this._layouts||[],this._layouts[e]=s,this}cacheOneLayout(t,e){t._id=t._id??d._idSeq++;let i={x:t.x,y:t.y,w:t.w,_id:t._id};(t.autoPosition||t.x===void 0)&&(delete i.x,delete i.y,t.autoPosition&&(i.autoPosition=!0)),this._layouts=this._layouts||[],this._layouts[e]=this._layouts[e]||[];let s=this.findCacheLayout(t,e);return s===-1?this._layouts[e].push(i):this._layouts[e][s]=i,this}findCacheLayout(t,e){return this._layouts?.[e]?.findIndex(i=>i._id===t._id)??-1}removeNodeFromLayoutCache(t){if(this._layouts)for(let e=0;e0||navigator.msMaxTouchPoints>0),v=class{};function N(d,t){if(d.touches.length>1)return;d.cancelable&&d.preventDefault();let e=d.changedTouches[0],i=document.createEvent("MouseEvents");i.initMouseEvent(t,!0,!0,window,1,e.screenX,e.screenY,e.clientX,e.clientY,!1,!1,!1,!1,0,null),d.target.dispatchEvent(i)}function F(d,t){d.cancelable&&d.preventDefault();let e=document.createEvent("MouseEvents");e.initMouseEvent(t,!0,!0,window,1,d.screenX,d.screenY,d.clientX,d.clientY,!1,!1,!1,!1,0,null),d.target.dispatchEvent(e)}function R(d){v.touchHandled||(v.touchHandled=!0,N(d,"mousedown"))}function S(d){v.touchHandled&&N(d,"mousemove")}function z(d){if(!v.touchHandled)return;v.pointerLeaveTimeout&&(window.clearTimeout(v.pointerLeaveTimeout),delete v.pointerLeaveTimeout);let t=!!c.dragElement;N(d,"mouseup"),t||N(d,"click"),v.touchHandled=!1}function D(d){d.pointerType!=="mouse"&&d.target.releasePointerCapture(d.pointerId)}function B(d){c.dragElement&&d.pointerType!=="mouse"&&F(d,"mouseenter")}function U(d){c.dragElement&&d.pointerType!=="mouse"&&(v.pointerLeaveTimeout=window.setTimeout(()=>{delete v.pointerLeaveTimeout,F(d,"mouseleave")},10))}var H=class d{constructor(t,e,i){this.host=t,this.dir=e,this.option=i,this.moving=!1,this._mouseDown=this._mouseDown.bind(this),this._mouseMove=this._mouseMove.bind(this),this._mouseUp=this._mouseUp.bind(this),this._init()}_init(){let t=this.el=document.createElement("div");return t.classList.add("ui-resizable-handle"),t.classList.add(`${d.prefix}${this.dir}`),t.style.zIndex="100",t.style.userSelect="none",this.host.appendChild(this.el),this.el.addEventListener("mousedown",this._mouseDown),y&&(this.el.addEventListener("touchstart",R),this.el.addEventListener("pointerdown",D)),this}destroy(){return this.moving&&this._mouseUp(this.mouseDownEvent),this.el.removeEventListener("mousedown",this._mouseDown),y&&(this.el.removeEventListener("touchstart",R),this.el.removeEventListener("pointerdown",D)),this.host.removeChild(this.el),delete this.el,delete this.host,this}_mouseDown(t){this.mouseDownEvent=t,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),y&&(this.el.addEventListener("touchmove",S),this.el.addEventListener("touchend",z)),t.stopPropagation(),t.preventDefault()}_mouseMove(t){let 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._triggerEvent("start",this.mouseDownEvent),this._triggerEvent("move",t)),t.stopPropagation()}_mouseUp(t){this.moving&&this._triggerEvent("stop",t),document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp,!0),y&&(this.el.removeEventListener("touchmove",S),this.el.removeEventListener("touchend",z)),delete this.moving,delete this.mouseDownEvent,t.stopPropagation(),t.preventDefault()}_triggerEvent(t,e){return this.option[t]&&this.option[t](e),this}};H.prefix="ui-resizable-";var b=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(){delete this._eventRegister}triggerEvent(t,e){if(!this.disabled&&this._eventRegister&&this._eventRegister[t])return this._eventRegister[t](e)}};var k=class d extends b{constructor(t,e={}){super(),this.el=t,this.option=e,this.rectScale={x:1,y:1},this._ui=()=>{let s=this.el.parentElement.getBoundingClientRect(),r={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,top:this.originalRect.top-this.scrolled},n=this.temporalRect||r;return{position:{left:(n.left-s.left)*this.rectScale.x,top:(n.top-s.top)*this.rectScale.y},size:{width:n.width*this.rectScale.x,height:n.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(){this._removeHandlers(),this._setupAutoHide(!1),delete this.el,super.destroy()}updateOption(t){let e=t.handles&&t.handles!==this.option.handles,i=t.autoHide&&t.autoHide!==this.option.autoHide;return Object.keys(t).forEach(s=>this.option[s]=t[s]),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),c.overResizeElement===this&&delete c.overResizeElement),this}_mouseOver(t){c.overResizeElement||c.dragElement||(c.overResizeElement=this,this.el.classList.remove("ui-resizable-autohide"))}_mouseOut(t){c.overResizeElement===this&&(delete c.overResizeElement,this.el.classList.add("ui-resizable-autohide"))}_setupHandlers(){return this.handlers=this.option.handles.split(",").map(t=>t.trim()).map(t=>new H(this.el,t,{start:e=>{this._resizeStart(e)},stop:e=>{this._resizeStop(e)},move:e=>{this._resizing(e,t)}})),this}_resizeStart(t){this.sizeToContent=a.shouldSizeToContent(this.el.gridstackNode,!0),this.originalRect=this.el.getBoundingClientRect(),this.scrollEl=a.getScrollElement(this.el),this.scrollY=this.scrollEl.scrollTop,this.scrolled=0,this.startEvent=t,this._setupHelper(),this._applyChange();let e=a.initEvent(t,{type:"resizestart",target:this.el});return 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();let i=a.initEvent(t,{type:"resize",target:this.el});return this.option.resize&&this.option.resize(i,this._ui()),this.triggerEvent("resize",i),this}_resizeStop(t){let e=a.initEvent(t,{type:"resizestop",target:this.el});return this.option.stop&&this.option.stop(e),this.el.classList.remove("ui-resizable-resizing"),this.triggerEvent("resizestop",e),this._cleanHelper(),delete this.startEvent,delete this.originalRect,delete this.temporalRect,delete this.scrollY,delete this.scrolled,this}_setupHelper(){this.elOriginStyleVal=d._originStyleProp.map(i=>this.el.style[i]),this.parentOriginStylePosition=this.el.parentElement.style.position;let t=this.el.parentElement,e=a.getValuesFromTransformedElement(t);return this.rectScale={x:e.xScale,y:e.yScale},getComputedStyle(this.el.parentElement).position.match(/static/)&&(this.el.parentElement.style.position="relative"),this.el.style.position="absolute",this.el.style.opacity="0.8",this}_cleanHelper(){return d._originStyleProp.forEach((t,e)=>{this.el.style[t]=this.elOriginStyleVal[e]||null}),this.el.parentElement.style.position=this.parentOriginStylePosition||null,this}_getChange(t,e){let i=this.startEvent,s={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,top:this.originalRect.top-this.scrolled},r=t.clientX-i.clientX,n=this.sizeToContent?0:t.clientY-i.clientY;e.indexOf("e")>-1?s.width+=r:e.indexOf("w")>-1&&(s.width-=r,s.left+=r),e.indexOf("s")>-1?s.height+=n:e.indexOf("n")>-1&&(s.height-=n,s.top+=n);let o=this._constrainSize(s.width,s.height);return Math.round(s.width)!==Math.round(o.width)&&(e.indexOf("w")>-1&&(s.left+=s.width-o.width),s.width=o.width),Math.round(s.height)!==Math.round(o.height)&&(e.indexOf("n")>-1&&(s.top+=s.height-o.height),s.height=o.height),s}_constrainSize(t,e){let i=this.option.maxWidth||Number.MAX_SAFE_INTEGER,s=this.option.minWidth/this.rectScale.x||t,r=this.option.maxHeight||Number.MAX_SAFE_INTEGER,n=this.option.minHeight/this.rectScale.y||e,o=Math.min(i,Math.max(s,t)),u=Math.min(r,Math.max(n,e));return{width:o,height:u}}_applyChange(){let t={left:0,top:0,width:0,height:0};if(this.el.style.position==="absolute"){let e=this.el.parentElement,{left:i,top:s}=e.getBoundingClientRect();t={left:i,top:s,width:0,height:0}}return this.temporalRect?(Object.keys(this.temporalRect).forEach(e=>{let i=this.temporalRect[e],s=e==="width"||e==="left"?this.rectScale.x:e==="height"||e==="top"?this.rectScale.y:1;this.el.style[e]=(i-t[e])*s+"px"}),this):this}_removeHandlers(){return this.handlers.forEach(t=>t.destroy()),delete this.handlers,this}};k._originStyleProp=["width","height","position","left","top","opacity","zIndex"];var X='input,textarea,button,select,option,[contenteditable="true"],.ui-resizable-handle',T=class d extends b{constructor(t,e={}){super(),this.el=t,this.option=e,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0};let i=e.handle.substring(1);this.dragEl=t.classList.contains(i)?t:t.querySelector(e.handle)||t,this._mouseDown=this._mouseDown.bind(this),this._mouseMove=this._mouseMove.bind(this),this._mouseUp=this._mouseUp.bind(this),this.enable()}on(t,e){super.on(t,e)}off(t){super.off(t)}enable(){this.disabled!==!1&&(super.enable(),this.dragEl.addEventListener("mousedown",this._mouseDown),y&&(this.dragEl.addEventListener("touchstart",R),this.dragEl.addEventListener("pointerdown",D)),this.el.classList.remove("ui-draggable-disabled"))}disable(t=!1){this.disabled!==!0&&(super.disable(),this.dragEl.removeEventListener("mousedown",this._mouseDown),y&&(this.dragEl.removeEventListener("touchstart",R),this.dragEl.removeEventListener("pointerdown",D)),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.helper,delete this.option,super.destroy()}updateOption(t){return Object.keys(t).forEach(e=>this.option[e]=t[e]),this}_mouseDown(t){if(!c.mouseHandled)return t.button!==0||t.target.closest(X)||this.option.cancel&&t.target.closest(this.option.cancel)||(this.mouseDownEvent=t,delete this.dragging,delete c.dragElement,delete c.dropElement,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),y&&(this.dragEl.addEventListener("touchmove",S),this.dragEl.addEventListener("touchend",z)),t.preventDefault(),document.activeElement&&document.activeElement.blur(),c.mouseHandled=!0),!0}_callDrag(t){if(!this.dragging)return;let e=a.initEvent(t,{target:this.el,type:"drag"});this.option.drag&&this.option.drag(e,this.ui()),this.triggerEvent("drag",e)}_mouseMove(t){let e=this.mouseDownEvent;if(this.dragging)if(this._dragFollow(t),c.pauseDrag){let i=Number.isInteger(c.pauseDrag)?c.pauseDrag:100;this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>this._callDrag(t),i)}else this._callDrag(t);else if(Math.abs(t.x-e.x)+Math.abs(t.y-e.y)>3){this.dragging=!0,c.dragElement=this;let i=this.el.gridstackNode?.grid;i?c.dropElement=i.el.ddElement.ddDroppable:delete c.dropElement,this.helper=this._createHelper(t),this._setupHelperContainmentStyle(),this.dragTransform=a.getValuesFromTransformedElement(this.helperContainment),this.dragOffset=this._getDragOffset(t,this.el,this.helperContainment);let s=a.initEvent(t,{target:this.el,type:"dragstart"});this._setupHelperStyle(t),this.option.start&&this.option.start(s,this.ui()),this.triggerEvent("dragstart",s)}return!0}_mouseUp(t){if(document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp,!0),y&&(this.dragEl.removeEventListener("touchmove",S,!0),this.dragEl.removeEventListener("touchend",z,!0)),this.dragging){delete this.dragging,c.dropElement?.el===this.el.parentElement&&delete c.dropElement,this.helperContainment.style.position=this.parentOriginStylePosition||null,this.helper===this.el?this._removeHelperStyle():this.helper.remove();let e=a.initEvent(t,{target:this.el,type:"dragstop"});this.option.stop&&this.option.stop(e),this.triggerEvent("dragstop",e),c.dropElement&&c.dropElement.drop(t)}delete this.helper,delete this.mouseDownEvent,delete c.dragElement,delete c.dropElement,delete c.mouseHandled,t.preventDefault()}_createHelper(t){let e=this.el;return typeof this.option.helper=="function"?e=this.option.helper(t):this.option.helper==="clone"&&(e=a.cloneNode(this.el)),document.body.contains(e)||a.appendTo(e,this.option.appendTo==="parent"?this.el.parentElement:this.option.appendTo),e===this.el&&(this.dragElementOriginStyle=d.originStyleProp.map(i=>this.el.style[i])),e}_setupHelperStyle(t){this.helper.classList.add("ui-draggable-dragging");let e=this.helper.style;return e.pointerEvents="none",e.width=this.dragOffset.width+"px",e.height=this.dragOffset.height+"px",e.willChange="left, top",e.position="fixed",this._dragFollow(t),e.transition="none",setTimeout(()=>{this.helper&&(e.transition=null)},0),this}_removeHelperStyle(){if(this.helper.classList.remove("ui-draggable-dragging"),!this.helper?.gridstackNode?._isAboutToRemove&&this.dragElementOriginStyle){let e=this.helper,i=this.dragElementOriginStyle.transition||null;e.style.transition=this.dragElementOriginStyle.transition="none",d.originStyleProp.forEach(s=>e.style[s]=this.dragElementOriginStyle[s]||null),setTimeout(()=>e.style.transition=i,50)}return delete this.dragElementOriginStyle,this}_dragFollow(t){let e={left:0,top:0},i=this.helper.style,s=this.dragOffset;i.left=(t.clientX+s.offsetLeft-e.left)*this.dragTransform.xScale+"px",i.top=(t.clientY+s.offsetTop-e.top)*this.dragTransform.yScale+"px"}_setupHelperContainmentStyle(){return this.helperContainment=this.helper.parentElement,this.helper.style.position!=="fixed"&&(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,r=0;i&&(s=this.dragTransform.xOffset,r=this.dragTransform.yOffset);let n=e.getBoundingClientRect();return{left:n.left,top:n.top,offsetLeft:-t.clientX+n.left-s,offsetTop:-t.clientY+n.top-r,width:n.width*this.dragTransform.xScale,height:n.height*this.dragTransform.yScale}}ui(){let e=this.el.parentElement.getBoundingClientRect(),i=this.helper.getBoundingClientRect();return{position:{top:(i.top-e.top)*this.dragTransform.yScale,left:(i.left-e.left)*this.dragTransform.xScale}}}};T.originStyleProp=["transition","pointerEvents","position","left","top","minWidth","willChange"];var L=class extends b{constructor(t,e={}){super(),this.el=t,this.option=e,this._mouseEnter=this._mouseEnter.bind(this),this._mouseLeave=this._mouseLeave.bind(this),this.enable(),this._setupAccept()}on(t,e){super.on(t,e)}off(t){super.off(t)}enable(){this.disabled!==!1&&(super.enable(),this.el.classList.add("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"),this.el.addEventListener("mouseenter",this._mouseEnter),this.el.addEventListener("mouseleave",this._mouseLeave),y&&(this.el.addEventListener("pointerenter",B),this.el.addEventListener("pointerleave",U)))}disable(t=!1){this.disabled!==!0&&(super.disable(),this.el.classList.remove("ui-droppable"),t||this.el.classList.add("ui-droppable-disabled"),this.el.removeEventListener("mouseenter",this._mouseEnter),this.el.removeEventListener("mouseleave",this._mouseLeave),y&&(this.el.removeEventListener("pointerenter",B),this.el.removeEventListener("pointerleave",U)))}destroy(){this.disable(!0),this.el.classList.remove("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"),super.destroy()}updateOption(t){return Object.keys(t).forEach(e=>this.option[e]=t[e]),this._setupAccept(),this}_mouseEnter(t){if(!c.dragElement||!this._canDrop(c.dragElement.el))return;t.preventDefault(),t.stopPropagation(),c.dropElement&&c.dropElement!==this&&c.dropElement._mouseLeave(t,!0),c.dropElement=this;let e=a.initEvent(t,{target:this.el,type:"dropover"});this.option.over&&this.option.over(e,this._ui(c.dragElement)),this.triggerEvent("dropover",e),this.el.classList.add("ui-droppable-over")}_mouseLeave(t,e=!1){if(!c.dragElement||c.dropElement!==this)return;t.preventDefault(),t.stopPropagation();let i=a.initEvent(t,{target:this.el,type:"dropout"});if(this.option.out&&this.option.out(i,this._ui(c.dragElement)),this.triggerEvent("dropout",i),c.dropElement===this&&(delete c.dropElement,!e)){let s,r=this.el.parentElement;for(;!s&&r;)s=r.ddElement?.ddDroppable,r=r.parentElement;s&&s._mouseEnter(t)}}drop(t){t.preventDefault();let e=a.initEvent(t,{target:this.el,type:"drop"});this.option.drop&&this.option.drop(e,this._ui(c.dragElement)),this.triggerEvent("drop",e)}_canDrop(t){return t&&(!this.accept||this.accept(t))}_setupAccept(){return this.option.accept?(typeof this.option.accept=="string"?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()}}};var A=class d{static init(t){return t.ddElement||(t.ddElement=new d(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 T(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 k(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 L(this.el,t),this}cleanDroppable(){return this.ddDroppable&&(this.ddDroppable.destroy(),delete this.ddDroppable),this}};var O=class{resizable(t,e,i,s){return this._getDDElements(t).forEach(r=>{if(e==="disable"||e==="enable")r.ddResizable&&r.ddResizable[e]();else if(e==="destroy")r.ddResizable&&r.cleanResizable();else if(e==="option")r.setupResizable({[i]:s});else{let o=r.el.gridstackNode.grid,u=r.el.getAttribute("gs-resize-handles")||o.opts.resizable.handles||"e,s,se";u==="all"&&(u="n,e,s,w,se,sw,ne,nw");let h=!o.opts.alwaysShowResizeHandle;r.setupResizable({...o.opts.resizable,handles:u,autoHide:h,start:e.start,stop:e.stop,resize:e.resize})}}),this}draggable(t,e,i,s){return this._getDDElements(t).forEach(r=>{if(e==="disable"||e==="enable")r.ddDraggable&&r.ddDraggable[e]();else if(e==="destroy")r.ddDraggable&&r.cleanDraggable();else if(e==="option")r.setupDraggable({[i]:s});else{let n=r.el.gridstackNode.grid;r.setupDraggable({...n.opts.draggable,start:e.start,stop:e.stop,drag:e.drag})}}),this}dragIn(t,e){return this._getDDElements(t).forEach(i=>i.setupDraggable(e)),this}droppable(t,e,i,s){return typeof e.accept=="function"&&!e._accept&&(e._accept=e.accept,e.accept=r=>e._accept(r)),this._getDDElements(t).forEach(r=>{e==="disable"||e==="enable"?r.ddDroppable&&r.ddDroppable[e]():e==="destroy"?r.ddDroppable&&r.cleanDroppable():e==="option"?r.setupDroppable({[i]:s}):r.setupDroppable(e)}),this}isDroppable(t){return!!(t&&t.ddElement&&t.ddElement.ddDroppable&&!t.ddElement.ddDroppable.disabled)}isDraggable(t){return!!(t&&t.ddElement&&t.ddElement.ddDraggable&&!t.ddElement.ddDraggable.disabled)}isResizable(t){return!!(t&&t.ddElement&&t.ddElement.ddResizable&&!t.ddElement.ddResizable.disabled)}on(t,e,i){return this._getDDElements(t).forEach(s=>s.on(e,r=>{i(r,c.dragElement?c.dragElement.el:r.target,c.dragElement?c.dragElement.helper:null)})),this}off(t,e){return this._getDDElements(t).forEach(i=>i.off(e)),this}_getDDElements(t,e=!0){let i=a.getElements(t);if(!i.length)return[];let s=i.map(r=>r.ddElement||(e?A.init(r):null));return e||s.filter(r=>r),s}};var m=new O,E=class d{static init(t={},e=".grid-stack"){if(typeof document>"u")return null;let i=d.getGridElement(e);return i?(i.gridstack||(i.gridstack=new d(i,a.cloneDeep(t))),i.gridstack):(console.error(typeof e=="string"?'GridStack.initAll() no grid was found with selector "'+e+`" - element missing or wrong selector ? +Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.`:"GridStack.init() no grid element was passed."),null)}static initAll(t={},e=".grid-stack"){let i=[];return typeof document>"u"||(d.getGridElements(e).forEach(s=>{s.gridstack||(s.gridstack=new d(s,a.cloneDeep(t))),i.push(s.gridstack)}),i.length===0&&console.error('GridStack.initAll() no grid was found with selector "'+e+`" - element missing or wrong selector ? +Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.`)),i}static addGrid(t,e={}){if(!t)return null;let i=t;if(i.gridstack){let n=i.gridstack;return e&&(n.opts={...n.opts,...e}),e.children!==void 0&&n.load(e.children),n}if(!t.classList.contains("grid-stack")||d.addRemoveCB)if(d.addRemoveCB)i=d.addRemoveCB(t,e,!0,!0);else{let n=document.implementation.createHTMLDocument("");n.body.innerHTML=`
`,i=n.body.children[0],t.appendChild(i)}return d.init(e,i)}static registerEngine(t){d.engineClass=t}get placeholder(){if(!this._placeholder){let t=document.createElement("div");t.className="placeholder-content",this.opts.placeholderText&&(t.innerHTML=this.opts.placeholderText),this._placeholder=document.createElement("div"),this._placeholder.classList.add(this.opts.placeholderClass,_.itemClass,this.opts.itemClass),this.placeholder.appendChild(t)}return this._placeholder}constructor(t,e={}){this.el=t,this.opts=e,this._gsEventHandler={},this._extraDragRow=0,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0},t.gridstack=this,e=e||{},t.classList.contains("grid-stack")||this.el.classList.add("grid-stack"),e.row&&(e.minRow=e.maxRow=e.row,delete e.row);let i=a.toNumber(t.getAttribute("gs-row"));e.column==="auto"&&delete e.column,e.alwaysShowResizeHandle!==void 0&&(e._alwaysShowResizeHandle=e.alwaysShowResizeHandle);let s=e.columnOpts?.breakpoints,r=e;if(r.oneColumnModeDomSort&&(delete r.oneColumnModeDomSort,console.log("warning: Gridstack oneColumnModeDomSort no longer supported. Use GridStackOptions.columnOpts instead.")),r.oneColumnSize||r.disableOneColumnMode===!1){let f=r.oneColumnSize||768;delete r.oneColumnSize,delete r.disableOneColumnMode,e.columnOpts=e.columnOpts||{},s=e.columnOpts.breakpoints=e.columnOpts.breakpoints||[];let g=s.find(p=>p.c===1);g?g.w=f:(g={c:1,w:f},s.push(g,{c:12,w:f+1}))}let n=e.columnOpts;n&&(!n.columnWidth&&!n.breakpoints?.length?(delete e.columnOpts,s=void 0):n.columnMax=n.columnMax||12),s?.length>1&&s.sort((f,g)=>(g.w||0)-(f.w||0));let o={...a.cloneDeep(_),column:a.toNumber(t.getAttribute("gs-column"))||_.column,minRow:i||a.toNumber(t.getAttribute("gs-min-row"))||_.minRow,maxRow:i||a.toNumber(t.getAttribute("gs-max-row"))||_.maxRow,staticGrid:a.toBool(t.getAttribute("gs-static"))||_.staticGrid,draggable:{handle:(e.handleClass?"."+e.handleClass:e.handle?e.handle:"")||_.draggable.handle},removableOptions:{accept:e.itemClass||_.removableOptions.accept,decline:_.removableOptions.decline}};t.getAttribute("gs-animate")&&(o.animate=a.toBool(t.getAttribute("gs-animate"))),e=a.defaults(e,o),this._initMargin(),this.checkDynamicColumn(),this.el.classList.add("gs-"+e.column),e.rtl==="auto"&&(e.rtl=t.style.direction==="rtl"),e.rtl&&this.el.classList.add("grid-stack-rtl");let u=this.el.parentElement?.parentElement,h=u?.classList.contains(_.itemClass)?u.gridstackNode:void 0;h&&(h.subGrid=this,this.parentGridItem=h,this.el.classList.add("grid-stack-nested"),h.el.classList.add("grid-stack-sub-grid")),this._isAutoCellHeight=e.cellHeight==="auto",this._isAutoCellHeight||e.cellHeight==="initial"?this.cellHeight(void 0,!1):(typeof e.cellHeight=="number"&&e.cellHeightUnit&&e.cellHeightUnit!==_.cellHeightUnit&&(e.cellHeight=e.cellHeight+e.cellHeightUnit,delete e.cellHeightUnit),this.cellHeight(e.cellHeight,!1)),e.alwaysShowResizeHandle==="mobile"&&(e.alwaysShowResizeHandle=y),this._styleSheetClass="gs-id-"+x._idSeq++,this.el.classList.add(this._styleSheetClass),this._setStaticClass();let l=e.engineClass||d.engineClass||x;if(this.engine=new l({column:this.getColumn(),float:e.float,maxRow:e.maxRow,onChange:f=>{let g=0;this.engine.nodes.forEach(p=>{g=Math.max(g,p.y+p.h)}),f.forEach(p=>{let w=p.el;w&&(p._removeDOM?(w&&w.remove(),delete p._removeDOM):this._writePosAttr(w,p))}),this._updateStyles(!1,g)}}),this._updateStyles(!1,0),e.auto&&(this.batchUpdate(),this.getGridItems().forEach(f=>this._prepareElement(f)),this.batchUpdate(!1)),e.children){let f=e.children;delete e.children,f.length&&this.load(f)}this.setAnimation(e.animate),e.subGridDynamic&&!c.pauseDrag&&(c.pauseDrag=!0),e.draggable?.pause!==void 0&&(c.pauseDrag=e.draggable.pause),this._setupRemoveDrop(),this._setupAcceptWidget(),this._updateResizeEvent()}addWidget(t,e){function i(o){return o.el!==void 0||o.x!==void 0||o.y!==void 0||o.w!==void 0||o.h!==void 0||o.content!==void 0}let s,r;if(typeof t=="string"){let o=document.implementation.createHTMLDocument("");o.body.innerHTML=t,s=o.body.children[0]}else if(arguments.length===0||arguments.length===1&&i(t))if(r=e=t,r?.el)s=r.el;else if(d.addRemoveCB)s=d.addRemoveCB(this.el,e,!0,!1);else{let o=e?.content||"",u=document.implementation.createHTMLDocument("");u.body.innerHTML=`
${o}
`,s=u.body.children[0]}else s=t;if(!s)return;if(r=s.gridstackNode,r&&s.parentElement===this.el&&this.engine.nodes.find(o=>o._id===r._id))return s;let n=this._readAttr(s);return e=a.cloneDeep(e)||{},a.defaults(e,n),r=this.engine.prepareNode(e),this._writeAttr(s,e),this._insertNotAppend?this.el.prepend(s):this.el.appendChild(s),this.makeWidget(s,e),s}makeSubGrid(t,e,i,s=!0){let r=t.gridstackNode;if(r||(r=this.makeWidget(t).gridstackNode),r.subGrid?.el)return r.subGrid;let n,o=this;for(;o&&!n;)n=o.opts?.subGridOpts,o=o.parentGridItem?.grid;e=a.cloneDeep({...n||{},children:void 0,...e||r.subGridOpts||{}}),r.subGridOpts=e;let u;e.column==="auto"&&(u=!0,e.column=Math.max(r.w||1,i?.w||1),delete e.columnOpts);let h=r.el.querySelector(".grid-stack-item-content"),l,f;if(s){if(this._removeDD(r.el),f={...r,x:0,y:0},a.removeInternalForSave(f),delete f.subGridOpts,r.content&&(f.content=r.content,delete r.content),d.addRemoveCB)l=d.addRemoveCB(this.el,f,!0,!1);else{let p=document.implementation.createHTMLDocument("");p.body.innerHTML='
',l=p.body.children[0],l.appendChild(h),p.body.innerHTML='
',h=p.body.children[0],r.el.appendChild(h)}this._prepareDragDropByNode(r)}if(i){let p=u?e.column:r.w,w=r.h+i.h,M=r.el.style;M.transition="none",this.update(r.el,{w:p,h:w}),setTimeout(()=>M.transition=null)}let g=r.subGrid=d.addGrid(h,e);return i?._moving&&(g._isTemp=!0),u&&(g._autoColumn=!0),s&&g.addWidget(l,f),i&&(i._moving?window.setTimeout(()=>a.simulateMouseEvent(i._event,"mouseenter",g.el),0):g.addWidget(r.el,r)),g}removeAsSubGrid(t){let e=this.parentGridItem?.grid;e&&(e.batchUpdate(),e.removeWidget(this.parentGridItem.el,!0,!0),this.engine.nodes.forEach(i=>{i.x+=this.parentGridItem.x,i.y+=this.parentGridItem.y,e.addWidget(i.el,i)}),e.batchUpdate(!1),this.parentGridItem&&delete this.parentGridItem.subGrid,delete this.parentGridItem,t&&window.setTimeout(()=>a.simulateMouseEvent(t._event,"mouseenter",e.el),0))}save(t=!0,e=!1,i=d.saveCB){let s=this.engine.save(t,i);if(s.forEach(r=>{if(t&&r.el&&!r.subGrid&&!i){let n=r.el.querySelector(".grid-stack-item-content");r.content=n?n.innerHTML:void 0,r.content||delete r.content}else if(!t&&!i&&delete r.content,r.subGrid?.el){let n=r.subGrid.save(t,e,i);r.subGridOpts=e?n:{children:n},delete r.subGrid}delete r.el}),e){let r=a.cloneDeep(this.opts);r.marginBottom===r.marginTop&&r.marginRight===r.marginLeft&&r.marginTop===r.marginRight&&(r.margin=r.marginTop,delete r.marginTop,delete r.marginRight,delete r.marginBottom,delete r.marginLeft),r.rtl===(this.el.style.direction==="rtl")&&(r.rtl="auto"),this._isAutoCellHeight&&(r.cellHeight="auto"),this._autoColumn&&(r.column="auto");let n=r._alwaysShowResizeHandle;return delete r._alwaysShowResizeHandle,n!==void 0?r.alwaysShowResizeHandle=n:delete r.alwaysShowResizeHandle,a.removeInternalAndSame(r,_),r.children=s,r}return s}load(t,e=d.addRemoveCB||!0){t=a.cloneDeep(t);let i=this.getColumn(),s=t.filter(l=>(l.x===void 0||l.y===void 0)&&!a.find(this.engine.nodes,l.id));s.length&&s.length!==t.length?t=t.filter(l=>!a.find(s,l.id)):s=[];let r=t.some(l=>l.x!==void 0||l.y!==void 0);r&&(t=a.sort(t,-1)),this._insertNotAppend=r,t.some(l=>(l.x||0)+(l.w||1)>i)&&(this._ignoreLayoutsNodeChange=!0,this.engine.cacheLayout(t,12,!0));let n=d.addRemoveCB;typeof e=="function"&&(d.addRemoveCB=e);let o=[];this.batchUpdate();let u=!this.engine.nodes.length;u&&this.setAnimation(!1),e&&[...this.engine.nodes].forEach(f=>{if(!f.id)return;a.find(t,f.id)||(d.addRemoveCB&&d.addRemoveCB(this.el,f,!1,!1),o.push(f),this.removeWidget(f.el,!0,!1))});let h=[];return this.engine.nodes=this.engine.nodes.filter(l=>a.find(t,l.id)?(h.push(l),!1):!0),t.forEach(l=>{let f=a.find(h,l.id);if(f){if(a.shouldSizeToContent(f)&&(l.h=f.h),this.engine.nodeBoundFix(l),(l.autoPosition||l.x===void 0||l.y===void 0)&&(l.w=l.w||f.w,l.h=l.h||f.h,this.engine.findEmptyPosition(l)),this.engine.nodes.push(f),a.samePos(f,l)&&this.moveNode(f,{...l,forceCollide:!0}),this.update(f.el,l),l.subGridOpts?.children){let g=f.el.querySelector(".grid-stack");g&&g.gridstack&&(g.gridstack.load(l.subGridOpts.children),this._insertNotAppend=!0)}}else e&&this.addWidget(l)}),e&&s.forEach(l=>this.addWidget(l)),this.engine.removedNodes=o,this.batchUpdate(!1),delete this._ignoreLayoutsNodeChange,delete this._insertNotAppend,n?d.addRemoveCB=n:delete d.addRemoveCB,u&&this.opts?.animate&&setTimeout(()=>{this.opts&&this.setAnimation(this.opts.animate)}),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&&this.opts.cellHeight!=="auto"&&(!t||!this.opts.cellHeightUnit||this.opts.cellHeightUnit==="px"))return this.opts.cellHeight;if(this.opts.cellHeightUnit==="rem")return this.opts.cellHeight*parseFloat(getComputedStyle(document.documentElement).fontSize);if(this.opts.cellHeightUnit==="em")return this.opts.cellHeight*parseFloat(getComputedStyle(this.el).fontSize);if(this.opts.cellHeightUnit==="cm")return this.opts.cellHeight*(96/2.54);if(this.opts.cellHeightUnit==="mm")return this.opts.cellHeight*(96/2.54)/10;let e=this.el.querySelector("."+this.opts.itemClass);if(e){let s=a.toNumber(e.getAttribute("gs-h"))||1;return Math.round(e.offsetHeight/s)}let i=parseInt(this.el.getAttribute("gs-current-row"));return i?Math.round(this.el.getBoundingClientRect().height/i):this.opts.cellHeight}cellHeight(t,e=!0){if(e&&t!==void 0&&this._isAutoCellHeight!==(t==="auto")&&(this._isAutoCellHeight=t==="auto",this._updateResizeEvent()),(t==="initial"||t==="auto")&&(t=void 0),t===void 0){let s=-this.opts.marginRight-this.opts.marginLeft+this.opts.marginTop+this.opts.marginBottom;t=this.cellWidth()+s}let i=a.parseHeight(t);return this.opts.cellHeightUnit===i.unit&&this.opts.cellHeight===i.h?this:(this.opts.cellHeightUnit=i.unit,this.opts.cellHeight=i.h,this.resizeToContentCheck(),e&&this._updateStyles(!0),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(){let t=this.opts.columnOpts;if(!t||!t.columnWidth&&!t.breakpoints?.length)return!1;let e=this.getColumn(),i=e,s=this._widthOrContainer(!0);if(t.columnWidth)i=Math.min(Math.round(s/t.columnWidth)||1,t.columnMax);else{i=t.columnMax;let r=0;for(;rn.c===i);return this.column(i,r?.layout||t.layout),!0}return!1}compact(t="compact",e=!0){return this.engine.compact(t,e),this._triggerChangeEvent(),this}column(t,e="moveScale"){if(!t||t<1||this.opts.column===t)return this;let i=this.getColumn();return this.opts.column=t,this.engine?(this.engine.column=t,this.el.classList.remove("gs-"+i),this.el.classList.add("gs-"+t),this.engine.columnChanged(i,t,e),this._isAutoCellHeight&&this.cellHeight(),this.resizeToContentCheck(!0),this._ignoreLayoutsNodeChange=!0,this._triggerChangeEvent(),delete this._ignoreLayoutsNodeChange,this):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))}destroy(t=!0){if(this.el)return this.offAll(),this._updateResizeEvent(!0),this.setStatic(!0,!1),this.setAnimation(!1),t?this.el.parentNode.removeChild(this.el):(this.removeAll(t),this.el.classList.remove(this._styleSheetClass),this.el.removeAttribute("gs-current-row")),this._removeStylesheet(),this.parentGridItem&&delete this.parentGridItem.subGrid,delete this.parentGridItem,delete this.opts,delete this._placeholder,delete this.engine,delete this.el.gridstack,delete this.el,this}float(t){return this.opts.float!==t&&(this.opts.float=this.engine.float=t,this._triggerChangeEvent()),this}getFloat(){return this.engine.float}getCellFromPixel(t,e=!1){let i=this.el.getBoundingClientRect(),s;e?s={top:i.top+document.documentElement.scrollTop,left:i.left}:s={top:this.el.offsetTop,left:this.el.offsetLeft};let r=t.left-s.left,n=t.top-s.top,o=i.width/this.getColumn(),u=i.height/parseInt(this.el.getAttribute("gs-current-row"));return{x:Math.floor(r/o),y:Math.floor(n/u)}}getRow(){return Math.max(this.engine.getRow(),this.opts.minRow)}isAreaEmpty(t,e,i,s){return this.engine.isAreaEmpty(t,e,i,s)}makeWidget(t,e){let i=d.getElement(t);this._prepareElement(i,!0,e);let s=i.gridstackNode;return this._updateContainerHeight(),s.subGridOpts&&this.makeSubGrid(i,s.subGridOpts,void 0,!1),this.opts.column===1&&(this._ignoreLayoutsNodeChange=!0),this._triggerAddEvent(),this._triggerChangeEvent(),delete this._ignoreLayoutsNodeChange,i}on(t,e){return t.indexOf(" ")!==-1?(t.split(" ").forEach(s=>this.on(s,e)),this):(t==="change"||t==="added"||t==="removed"||t==="enable"||t==="disable"?(t==="enable"||t==="disable"?this._gsEventHandler[t]=s=>e(s):this._gsEventHandler[t]=s=>e(s,s.detail),this.el.addEventListener(t,this._gsEventHandler[t])):t==="drag"||t==="dragstart"||t==="dragstop"||t==="resizestart"||t==="resize"||t==="resizestop"||t==="dropped"||t==="resizecontent"?this._gsEventHandler[t]=e:console.error("GridStack.on("+t+") event not supported"),this)}off(t){return t.indexOf(" ")!==-1?(t.split(" ").forEach(i=>this.off(i)),this):((t==="change"||t==="added"||t==="removed"||t==="enable"||t==="disable")&&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 d.getElements(t).forEach(s=>{if(s.parentElement&&s.parentElement!==this.el)return;let r=s.gridstackNode;r||(r=this.engine.nodes.find(n=>s===n.el)),r&&(e&&d.addRemoveCB&&d.addRemoveCB(this.el,r,!1,!1),delete s.gridstackNode,this._removeDD(s),this.engine.removeNode(r,e,i),e&&s.parentElement&&s.remove())}),i&&(this._triggerRemoveEvent(),this._triggerChangeEvent()),this}removeAll(t=!0,e=!0){return this.engine.nodes.forEach(i=>{t&&d.addRemoveCB&&d.addRemoveCB(this.el,i,!1,!1),delete i.el.gridstackNode,this.opts.staticGrid||this._removeDD(i.el)}),this.engine.removeAll(t,e),e&&this._triggerRemoveEvent(),this}setAnimation(t){return t?this.el.classList.add("grid-stack-animate"):this.el.classList.remove("grid-stack-animate"),this}hasAnimationCSS(){return this.el.classList.contains("grid-stack-animate")}setStatic(t,e=!0,i=!0){return!!this.opts.staticGrid===t?this:(t?this.opts.staticGrid=!0:delete this.opts.staticGrid,this._setupRemoveDrop(),this._setupAcceptWidget(),this.engine.nodes.forEach(s=>{this._prepareDragDropByNode(s),s.subGrid&&i&&s.subGrid.setStatic(t,e,i)}),e&&this._setStaticClass(),this)}update(t,e){if(arguments.length>2){console.warn("gridstack.ts: `update(el, x, y, w, h)` is deprecated. Use `update(el, {x, w, content, ...})`. It will be removed soon");let i=arguments,s=1;return e={x:i[s++],y:i[s++],w:i[s++],h:i[s++]},this.update(t,e)}return d.getElements(t).forEach(i=>{let s=i?.gridstackNode;if(!s)return;let r=a.cloneDeep(e);this.engine.nodeBoundFix(r),delete r.autoPosition,delete r.id;let n=["x","y","w","h"],o;if(n.some(l=>r[l]!==void 0&&r[l]!==s[l])&&(o={},n.forEach(l=>{o[l]=r[l]!==void 0?r[l]:s[l],delete r[l]})),!o&&(r.minW||r.minH||r.maxW||r.maxH)&&(o={}),r.content!==void 0){let l=i.querySelector(".grid-stack-item-content");l&&l.innerHTML!==r.content&&(l.innerHTML=r.content,s.subGrid?.el&&(l.appendChild(s.subGrid.el),s.subGrid.opts.styleInHead||s.subGrid._updateStyles(!0))),delete r.content}let u=!1,h=!1;for(let l in r)l[0]!=="_"&&s[l]!==r[l]&&(s[l]=r[l],u=!0,h=h||!this.opts.staticGrid&&(l==="noResize"||l==="noMove"||l==="locked"));if(a.sanitizeMinMax(s),o){let l=o.w!==void 0&&o.w!==s.w;this.moveNode(s,o),this.resizeToContentCheck(l,s)}(o||u)&&this._writeAttr(i,s),h&&this._prepareDragDropByNode(s)}),this}moveNode(t,e){this.engine.cleanNodes().beginUpdate(t).moveNode(t,e),this._updateContainerHeight(),this._triggerChangeEvent(),this.engine.endUpdate()}resizeToContent(t){if(!t||(t.classList.remove("size-to-content-max"),!t.clientHeight))return;let e=t.gridstackNode;if(!e)return;let i=e.grid;if(!i||t.parentElement!==i.el)return;let s=i.getCellHeight(!0);if(!s)return;let r=e.h?e.h*s:t.clientHeight,n;if(e.resizeToContentParent&&(n=t.querySelector(e.resizeToContentParent)),n||(n=t.querySelector(d.resizeToContentParent)),!n)return;let o=t.clientHeight-n.clientHeight,u=e.h?e.h*s-o:n.clientHeight,h;if(e.subGrid)h=e.subGrid.getRow()*e.subGrid.getCellHeight(!0);else{let g=n.firstElementChild;if(!g){console.error(`Error: GridStack.resizeToContent() widget id:${e.id} '${d.resizeToContentParent}'.firstElementChild is null, make sure to have a div like container. Skipping sizing.`);return}h=g.getBoundingClientRect().height||u}if(u===h)return;r+=h-u;let l=Math.ceil(r/s),f=Number.isInteger(e.sizeToContent)?e.sizeToContent:0;f&&l>f&&(l=f,t.classList.add("size-to-content-max")),e.minH&&le.maxH&&(l=e.maxH),l!==e.h&&(i._ignoreLayoutsNodeChange=!0,i.moveNode(e,{h:l}),delete i._ignoreLayoutsNodeChange)}resizeToContentCBCheck(t){d.resizeToContentCB?d.resizeToContentCB(t):this.resizeToContent(t)}margin(t){if(!(typeof t=="string"&&t.split(" ").length>1)){let i=a.parseHeight(t);if(this.opts.marginUnit===i.unit&&this.opts.margin===i.h)return}return this.opts.margin=t,this.opts.marginTop=this.opts.marginBottom=this.opts.marginLeft=this.opts.marginRight=void 0,this._initMargin(),this._updateStyles(!0),this}getMargin(){return this.opts.margin}willItFit(t){if(arguments.length>1){console.warn("gridstack.ts: `willItFit(x,y,w,h,autoPosition)` is deprecated. Use `willItFit({x, y,...})`. It will be removed soon");let e=arguments,i=0,s={x:e[i++],y:e[i++],w:e[i++],h:e[i++],autoPosition:e[i++]};return this.willItFit(s)}return this.engine.willItFit(t)}_triggerChangeEvent(){if(this.engine.batchMode)return this;let t=this.engine.getDirtyNodes(!0);return t&&t.length&&(this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(t),this._triggerEvent("change",t)),this.engine.saveInitial(),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(e=>{delete e._dirty});let 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){let t=[...this.engine.removedNodes];this.engine.removedNodes=[],this._triggerEvent("removed",t)}return this}_triggerEvent(t,e){let i=e?new CustomEvent(t,{bubbles:!1,detail:e}):new Event(t);return this.el.dispatchEvent(i),this}_removeStylesheet(){if(this._styles){let t=this.opts.styleInHead?void 0:this.el.parentNode;a.removeStylesheet(this._styleSheetClass,t),delete this._styles}return this}_updateStyles(t=!1,e){if(t&&this._removeStylesheet(),e===void 0&&(e=this.getRow()),this._updateContainerHeight(),this.opts.cellHeight===0)return this;let i=this.opts.cellHeight,s=this.opts.cellHeightUnit,r=`.${this._styleSheetClass} > .${this.opts.itemClass}`;if(!this._styles){let n=this.opts.styleInHead?void 0:this.el.parentNode;if(this._styles=a.createStylesheet(this._styleSheetClass,n,{nonce:this.opts.nonce}),!this._styles)return this;this._styles._max=0,a.addCSSRule(this._styles,r,`height: ${i}${s}`);let o=this.opts.marginTop+this.opts.marginUnit,u=this.opts.marginBottom+this.opts.marginUnit,h=this.opts.marginRight+this.opts.marginUnit,l=this.opts.marginLeft+this.opts.marginUnit,f=`${r} > .grid-stack-item-content`,g=`.${this._styleSheetClass} > .grid-stack-placeholder > .placeholder-content`;a.addCSSRule(this._styles,f,`top: ${o}; right: ${h}; bottom: ${u}; left: ${l};`),a.addCSSRule(this._styles,g,`top: ${o}; right: ${h}; bottom: ${u}; left: ${l};`),a.addCSSRule(this._styles,`${r} > .ui-resizable-n`,`top: ${o};`),a.addCSSRule(this._styles,`${r} > .ui-resizable-s`,`bottom: ${u}`),a.addCSSRule(this._styles,`${r} > .ui-resizable-ne`,`right: ${h}`),a.addCSSRule(this._styles,`${r} > .ui-resizable-e`,`right: ${h}`),a.addCSSRule(this._styles,`${r} > .ui-resizable-se`,`right: ${h}; bottom: ${u}`),a.addCSSRule(this._styles,`${r} > .ui-resizable-nw`,`left: ${l}`),a.addCSSRule(this._styles,`${r} > .ui-resizable-w`,`left: ${l}`),a.addCSSRule(this._styles,`${r} > .ui-resizable-sw`,`left: ${l}; bottom: ${u}`)}if(e=e||this._styles._max,e>this._styles._max){let n=o=>i*o+s;for(let o=this._styles._max+1;o<=e;o++)a.addCSSRule(this._styles,`${r}[gs-y="${o}"]`,`top: ${n(o)}`),a.addCSSRule(this._styles,`${r}[gs-h="${o+1}"]`,`height: ${n(o+1)}`);this._styles._max=e}return this}_updateContainerHeight(){if(!this.engine||this.engine.batchMode)return this;let t=this.parentGridItem,e=this.getRow()+this._extraDragRow,i=this.opts.cellHeight,s=this.opts.cellHeightUnit;if(!i)return this;if(!t){let r=a.parseHeight(getComputedStyle(this.el).minHeight);if(r.h>0&&r.unit===s){let n=Math.floor(r.h/i);e1?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);let i={autoPosition:"gs-auto-position",noResize:"gs-no-resize",noMove:"gs-no-move",locked:"gs-locked",id:"gs-id"};for(let s in i)e[s]?t.setAttribute(i[s],String(e[s])):t.removeAttribute(i[s]);return this}_readAttr(t,e=!0){let i={};i.x=a.toNumber(t.getAttribute("gs-x")),i.y=a.toNumber(t.getAttribute("gs-y")),i.w=a.toNumber(t.getAttribute("gs-w")),i.h=a.toNumber(t.getAttribute("gs-h")),i.autoPosition=a.toBool(t.getAttribute("gs-auto-position")),i.noResize=a.toBool(t.getAttribute("gs-no-resize")),i.noMove=a.toBool(t.getAttribute("gs-no-move")),i.locked=a.toBool(t.getAttribute("gs-locked")),i.id=t.getAttribute("gs-id"),i.maxW=a.toNumber(t.getAttribute("gs-max-w")),i.minW=a.toNumber(t.getAttribute("gs-min-w")),i.maxH=a.toNumber(t.getAttribute("gs-max-h")),i.minH=a.toNumber(t.getAttribute("gs-min-h")),e&&(i.w===1&&t.removeAttribute("gs-w"),i.h===1&&t.removeAttribute("gs-h"),i.maxW&&t.removeAttribute("gs-max-w"),i.minW&&t.removeAttribute("gs-min-w"),i.maxH&&t.removeAttribute("gs-max-h"),i.minH&&t.removeAttribute("gs-min-h"));for(let s in i){if(!i.hasOwnProperty(s))return;!i[s]&&i[s]!==0&&delete i[s]}return i}_setStaticClass(){let 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(){if(!this.el?.clientWidth||this.prevWidth===this.el.clientWidth)return;this.prevWidth=this.el.clientWidth,this.batchUpdate();let t=!1;return this._autoColumn&&this.parentGridItem?this.opts.column!==this.parentGridItem.w&&(this.column(this.parentGridItem.w,"none"),t=!0):t=this.checkDynamicColumn(),this._isAutoCellHeight&&this.cellHeight(),this.engine.nodes.forEach(e=>{e.subGrid&&e.subGrid.onResize()}),this._skipInitialResize||this.resizeToContentCheck(t),delete this._skipInitialResize,this.batchUpdate(!1),this}resizeToContentCheck(t=!1,e=void 0){if(this.engine){if(t&&this.hasAnimationCSS())return setTimeout(()=>this.resizeToContentCheck(!1,e),310);if(e)a.shouldSizeToContent(e)&&this.resizeToContentCBCheck(e.el);else if(this.engine.nodes.some(i=>a.shouldSizeToContent(i))){let i=[...this.engine.nodes];this.batchUpdate(),i.forEach(s=>{a.shouldSizeToContent(s)&&this.resizeToContentCBCheck(s.el)}),this.batchUpdate(!1)}this._gsEventHandler.resizecontent&&this._gsEventHandler.resizecontent(null,e?[e]:this.engine.nodes)}}_updateResizeEvent(t=!1){let e=!this.parentGridItem&&(this._isAutoCellHeight||this.opts.sizeToContent||this.opts.columnOpts||this.engine.nodes.find(i=>i.sizeToContent));return!t&&e&&!this.resizeObserver?(this._sizeThrottle=a.throttle(()=>this.onResize(),this.opts.cellHeightThrottle),this.resizeObserver=new ResizeObserver(()=>this._sizeThrottle()),this.resizeObserver.observe(this.el),this._skipInitialResize=!0):(t||!e)&&this.resizeObserver&&(this.resizeObserver.disconnect(),delete this.resizeObserver,delete this._sizeThrottle),this}static getElement(t=".grid-stack-item"){return a.getElement(t)}static getElements(t=".grid-stack-item"){return a.getElements(t)}static getGridElement(t){return d.getElement(t)}static getGridElements(t){return a.getElements(t)}_initMargin(){let t,e=0,i=[];return typeof this.opts.margin=="string"&&(i=this.opts.margin.split(" ")),i.length===2?(this.opts.marginTop=this.opts.marginBottom=i[0],this.opts.marginLeft=this.opts.marginRight=i[1]):i.length===4?(this.opts.marginTop=i[0],this.opts.marginRight=i[1],this.opts.marginBottom=i[2],this.opts.marginLeft=i[3]):(t=a.parseHeight(this.opts.margin),this.opts.marginUnit=t.unit,e=this.opts.margin=t.h),this.opts.marginTop===void 0?this.opts.marginTop=e:(t=a.parseHeight(this.opts.marginTop),this.opts.marginTop=t.h,delete this.opts.margin),this.opts.marginBottom===void 0?this.opts.marginBottom=e:(t=a.parseHeight(this.opts.marginBottom),this.opts.marginBottom=t.h,delete this.opts.margin),this.opts.marginRight===void 0?this.opts.marginRight=e:(t=a.parseHeight(this.opts.marginRight),this.opts.marginRight=t.h,delete this.opts.margin),this.opts.marginLeft===void 0?this.opts.marginLeft=e:(t=a.parseHeight(this.opts.marginLeft),this.opts.marginLeft=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),this}static getDD(){return m}static setupDragIn(t,e,i=document){e?.pause!==void 0&&(c.pauseDrag=e.pause),e={...$,...e||{}};let s=typeof t=="string"?a.getElements(t,i):t;s.length&&s?.forEach(r=>{m.isDraggable(r)||m.dragIn(r,e)})}movable(t,e){return this.opts.staticGrid?this:(d.getElements(t).forEach(i=>{let s=i.gridstackNode;s&&(e?delete s.noMove:s.noMove=!0,this._prepareDragDropByNode(s))}),this)}resizable(t,e){return this.opts.staticGrid?this:(d.getElements(t).forEach(i=>{let s=i.gridstackNode;s&&(e?delete s.noResize:s.noResize=!0,this._prepareDragDropByNode(s))}),this)}disable(t=!0){if(!this.opts.staticGrid)return this.enableMove(!1,t),this.enableResize(!1,t),this._triggerEvent("disable"),this}enable(t=!0){if(!this.opts.staticGrid)return this.enableMove(!0,t),this.enableResize(!0,t),this._triggerEvent("enable"),this}enableMove(t,e=!0){return this.opts.staticGrid?this:(t?delete this.opts.disableDrag:this.opts.disableDrag=!0,this.engine.nodes.forEach(i=>{this._prepareDragDropByNode(i),i.subGrid&&e&&i.subGrid.enableMove(t,e)}),this)}enableResize(t,e=!0){return this.opts.staticGrid?this:(t?delete this.opts.disableResize:this.opts.disableResize=!0,this.engine.nodes.forEach(i=>{this._prepareDragDropByNode(i),i.subGrid&&e&&i.subGrid.enableResize(t,e)}),this)}_removeDD(t){return m.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 m.droppable(this.el,"destroy"),this;let t,e,i=(s,r,n)=>{let o=r.gridstackNode;if(!o)return;if(n=n||r,!o.grid?.el){n.style.transform=`scale(${1/this.dragTransform.xScale},${1/this.dragTransform.yScale})`;let g=n.getBoundingClientRect();n.style.left=g.x+(this.dragTransform.xScale-1)*(s.clientX-g.x)/this.dragTransform.xScale+"px",n.style.top=g.y+(this.dragTransform.yScale-1)*(s.clientY-g.y)/this.dragTransform.yScale+"px",n.style.transformOrigin="0px 0px"}let u=this.el.getBoundingClientRect(),{top:h,left:l}=n.getBoundingClientRect();l-=u.left,h-=u.top;let f={position:{top:h*this.dragTransform.xScale,left:l*this.dragTransform.yScale}};if(o._temporaryRemoved){if(o.x=Math.max(0,Math.round(l/e)),o.y=Math.max(0,Math.round(h/t)),delete o.autoPosition,this.engine.nodeBoundFix(o),!this.engine.willItFit(o)){if(o.autoPosition=!0,!this.engine.willItFit(o)){m.off(r,"drag");return}o._willFitPos&&(a.copyPos(o,o._willFitPos),delete o._willFitPos)}this._onStartMoving(n,s,f,o,e,t)}else this._dragOrResize(n,s,f,o,e,t)};return m.droppable(this.el,{accept:s=>{let r=s.gridstackNode||this._readAttr(s,!1);if(r?.grid===this)return!0;if(!this.opts.acceptWidgets)return!1;let n=!0;if(typeof this.opts.acceptWidgets=="function")n=this.opts.acceptWidgets(s);else{let o=this.opts.acceptWidgets===!0?".grid-stack-item":this.opts.acceptWidgets;n=s.matches(o)}if(n&&r&&this.opts.maxRow){let o={w:r.w,h:r.h,minW:r.minW,minH:r.minH};n=this.engine.willItFit(o)}return n}}).on(this.el,"dropover",(s,r,n)=>{let o=r.gridstackNode;if(o?.grid===this&&!o._temporaryRemoved)return!1;o?.grid&&o.grid!==this&&!o._temporaryRemoved&&o.grid._leave(r,n),e=this.cellWidth(),t=this.getCellHeight(!0),o||(o=this._readAttr(r,!1)),o.grid||(o._isExternal=!0,r.gridstackNode=o),n=n||r;let u=o.w||Math.round(n.offsetWidth/e)||1,h=o.h||Math.round(n.offsetHeight/t)||1;return o.grid&&o.grid!==this?(r._gridstackNodeOrig||(r._gridstackNodeOrig=o),r.gridstackNode=o={...o,w:u,h,grid:this},delete o.x,delete o.y,this.engine.cleanupNode(o).nodeBoundFix(o),o._initDD=o._isExternal=o._temporaryRemoved=!0):(o.w=u,o.h=h,o._temporaryRemoved=!0),d._itemRemoving(o.el,!1),m.on(r,"drag",i),i(s,r,n),!1}).on(this.el,"dropout",(s,r,n)=>{let o=r.gridstackNode;return o&&(!o.grid||o.grid===this)&&(this._leave(r,n),this._isTemp&&this.removeAsSubGrid(o)),!1}).on(this.el,"drop",(s,r,n)=>{let o=r.gridstackNode;if(o?.grid===this&&!o._isExternal)return!1;let u=!!this.placeholder.parentElement;this.placeholder.remove();let h=u&&this.opts.animate;h&&this.setAnimation(!1);let l=r._gridstackNodeOrig;if(delete r._gridstackNodeOrig,u&&l?.grid&&l.grid!==this){let g=l.grid;g.engine.removeNodeFromLayoutCache(l),g.engine.removedNodes.push(l),g._triggerRemoveEvent()._triggerChangeEvent(),g.parentGridItem&&!g.engine.nodes.length&&g.opts.subGridDynamic&&g.removeAsSubGrid()}if(!o||(u&&(this.engine.cleanupNode(o),o.grid=this),delete o.grid._isTemp,m.off(r,"drag"),n!==r?(n.remove(),r.gridstackNode=l,u&&(r=r.cloneNode(!0))):(r.remove(),this._removeDD(r)),!u))return!1;r.gridstackNode=o,o.el=r;let f=o.subGrid?.el?.gridstack;return a.copyPos(o,this._readAttr(this.placeholder)),a.removePositioningStyles(r),this.el.appendChild(r),this._prepareElement(r,!0,o),f&&(f.parentGridItem=o,f.opts.styleInHead||f._updateStyles(!0)),this._updateContainerHeight(),this.engine.addedNodes.push(o),this._triggerAddEvent(),this._triggerChangeEvent(),this.engine.endUpdate(),this._gsEventHandler.dropped&&this._gsEventHandler.dropped({...s,type:"dropped"},l&&l.grid?l:void 0,o),h&&setTimeout(()=>{this.opts&&this.setAnimation(this.opts.animate)}),!1}),this}static _itemRemoving(t,e){let 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(typeof this.opts.removable!="string")return this;let t=document.querySelector(this.opts.removable);return t?(!this.opts.staticGrid&&!m.isDroppable(t)&&m.droppable(t,this.opts.removableOptions).on(t,"dropover",(e,i)=>d._itemRemoving(i,!0)).on(t,"dropout",(e,i)=>d._itemRemoving(i,!1)),this):this}_prepareDragDropByNode(t){let e=t.el,i=t.noMove||this.opts.disableDrag,s=t.noResize||this.opts.disableResize;if(this.opts.staticGrid||i&&s)return t._initDD&&(this._removeDD(e),delete t._initDD),e.classList.add("ui-draggable-disabled","ui-resizable-disabled"),this;if(!t._initDD){let r,n,o=(l,f)=>{this._gsEventHandler[l.type]&&this._gsEventHandler[l.type](l,l.target),r=this.cellWidth(),n=this.getCellHeight(!0),this._onStartMoving(e,l,f,t,r,n)},u=(l,f)=>{this._dragOrResize(e,l,f,t,r,n)},h=l=>{this.placeholder.remove(),delete t._moving,delete t._event,delete t._lastTried;let f=t.w!==t._orig.w,g=l.target;if(!(!g.gridstackNode||g.gridstackNode.grid!==this)){if(t.el=g,t._isAboutToRemove){let p=e.gridstackNode.grid;p._gsEventHandler[l.type]&&p._gsEventHandler[l.type](l,g),p.engine.nodes.push(t),p.removeWidget(e,!0,!0)}else a.removePositioningStyles(g),t._temporaryRemoved?(a.copyPos(t,t._orig),this._writePosAttr(g,t),this.engine.addNode(t)):this._writePosAttr(g,t),this._gsEventHandler[l.type]&&this._gsEventHandler[l.type](l,g);this._extraDragRow=0,this._updateContainerHeight(),this._triggerChangeEvent(),this.engine.endUpdate(),l.type==="resizestop"&&(Number.isInteger(t.sizeToContent)&&(t.sizeToContent=t.h),this.resizeToContentCheck(f,t))}};m.draggable(e,{start:o,stop:h,drag:u}).resizable(e,{start:o,stop:h,resize:u}),t._initDD=!0}return m.draggable(e,i?"disable":"enable").resizable(e,s?"disable":"enable"),this}_onStartMoving(t,e,i,s,r,n){if(this.engine.cleanNodes().beginUpdate(s),this._writePosAttr(this.placeholder,s),this.el.appendChild(this.placeholder),s.grid?.el)this.dragTransform=a.getValuesFromTransformedElement(t);else if(this.placeholder&&this.placeholder.closest(".grid-stack")){let o=this.placeholder.closest(".grid-stack");this.dragTransform=a.getValuesFromTransformedElement(o)}else this.dragTransform={xScale:1,xOffset:0,yScale:1,yOffset:0};s.el=this.placeholder,s._lastUiPosition=i.position,s._prevYPix=i.position.top,s._moving=e.type==="dragstart",delete s._lastTried,e.type==="dropover"&&s._temporaryRemoved&&(this.engine.addNode(s),s._moving=!0),this.engine.cacheRects(r,n,this.opts.marginTop,this.opts.marginRight,this.opts.marginBottom,this.opts.marginLeft),e.type==="resizestart"&&(m.resizable(t,"option","minWidth",r*(s.minW||1)).resizable(t,"option","minHeight",n*(s.minH||1)),s.maxW&&m.resizable(t,"option","maxWidth",r*s.maxW),s.maxH&&m.resizable(t,"option","maxHeight",n*s.maxH))}_dragOrResize(t,e,i,s,r,n){let o={...s._orig},u,h=this.opts.marginLeft,l=this.opts.marginRight,f=this.opts.marginTop,g=this.opts.marginBottom,p=Math.round(n*.1),w=Math.round(r*.1);if(h=Math.min(h,w),l=Math.min(l,w),f=Math.min(f,p),g=Math.min(g,p),e.type==="drag"){if(s._temporaryRemoved)return;let C=i.position.top-s._prevYPix;s._prevYPix=i.position.top,this.opts.draggable.scroll!==!1&&a.updateScrollPosition(t,i.position,C);let P=i.position.left+(i.position.left>s._lastUiPosition.left?-l:h),Y=i.position.top+(i.position.top>s._lastUiPosition.top?-g:f);o.x=Math.round(P/r),o.y=Math.round(Y/n);let q=this._extraDragRow;if(this.engine.collide(s,o)){let G=this.getRow(),I=Math.max(0,o.y+s.h-G);this.opts.maxRow&&G+I>this.opts.maxRow&&(I=Math.max(0,this.opts.maxRow-G)),this._extraDragRow=I}else this._extraDragRow=0;if(this._extraDragRow!==q&&this._updateContainerHeight(),s.x===o.x&&s.y===o.y)return}else if(e.type==="resize"){if(o.x<0||(a.updateScrollResize(e,t,n),o.w=Math.round((i.size.width-h)/r),o.h=Math.round((i.size.height-f)/n),s.w===o.w&&s.h===o.h)||s._lastTried&&s._lastTried.w===o.w&&s._lastTried.h===o.h)return;let C=i.position.left+h,P=i.position.top+f;o.x=Math.round(C/r),o.y=Math.round(P/n),u=!0}s._event=e,s._lastTried=o;let M={x:i.position.left+h,y:i.position.top+f,w:(i.size?i.size.width:s.w*r)-h-l,h:(i.size?i.size.height:s.h*n)-f-g};if(this.engine.moveNodeCheck(s,{...o,cellWidth:r,cellHeight:n,rect:M,resizing:u})){s._lastUiPosition=i.position,this.engine.cacheRects(r,n,f,l,g,h),delete s._skipDown,u&&s.subGrid&&s.subGrid.onResize(),this._extraDragRow=0,this._updateContainerHeight();let C=e.target;this._writePosAttr(C,s),this._gsEventHandler[e.type]&&this._gsEventHandler[e.type](e,C)}}_leave(t,e){let i=t.gridstackNode;i&&(e=e||t,e.style.transform="scale(1)",m.off(t,"drag"),!i._temporaryRemoved&&(i._temporaryRemoved=!0,this.engine.removeNode(i),i.el=i._isExternal&&e?e:t,this.opts.removable===!0&&d._itemRemoving(t,!0),t._gridstackNodeOrig?(t.gridstackNode=t._gridstackNodeOrig,delete t._gridstackNodeOrig):i._isExternal&&(delete i.el,delete t.gridstackNode,this.engine.restoreInitial())))}commit(){return W(this,this.batchUpdate(!1),"commit","batchUpdate","5.2"),this}};E.resizeToContentParent=".grid-stack-item-content";E.Utils=a;E.Engine=x;E.GDRev="10.1.2";function j({columns:d=12}){return{grid:null,gridItems:this.$wire.entangle("gridItems"),addItem:function(t,e){this.grid.addWidget({w:12,id:t,content:e})},removeAll:function(){this.grid.removeAll(),this.gridItems=[]},init:function(){this.grid=E.init({cellHeight:80,column:d,acceptWidgets:!0,removable:"#trash",alwaysShowResizeHandle:!0,disableOneColumnMode:!0}),this.grid.load(this.gridItems);let t=this;this.grid.on("removed",function(e,i){let s=[];i.forEach(function(r){s=t.gridItems.filter(function(n){return n.id!==r.id})}),t.gridItems=s}),this.grid.on("added",function(e,i){let s=[];i.forEach(function(r){let n={id:r.id,content:r.content,w:r.w,x:r.x,y:r.y};s.push(n)}),t.gridItems=t.gridItems.concat(s)}),this.grid.on("change",function(e,i){t.gridItems.forEach(function(s,r){i.forEach(function(n){n.id===s.id&&(t.gridItems[r].x=n.x,t.gridItems[r].w=n.w,t.gridItems[r].y=n.y)})})})}}}export{j as default}; /*! Bundled license information: gridstack/dist/gridstack.js: diff --git a/resources/js/index.js b/resources/js/index.js index cde7a1c..2326119 100644 --- a/resources/js/index.js +++ b/resources/js/index.js @@ -1,6 +1,8 @@ import {GridStack} from 'gridstack'; -export default function gridStackDashboard() { +export default function gridStackDashboard({ + columns = 12 + }) { return { grid: null, gridItems: this.$wire.entangle('gridItems'), @@ -15,6 +17,7 @@ export default function gridStackDashboard() { init: function () { this.grid = GridStack.init({ cellHeight: 80, + column: columns, acceptWidgets: true, removable: '#trash', alwaysShowResizeHandle: true, diff --git a/resources/views/pages/dashboard.blade.php b/resources/views/pages/dashboard.blade.php index f734b15..8886d1f 100644 --- a/resources/views/pages/dashboard.blade.php +++ b/resources/views/pages/dashboard.blade.php @@ -1,6 +1,7 @@ @php use Filament\Support\Facades\FilamentAsset; use Filament\Widgets\WidgetConfiguration; + $columns = $this->getColumns(); @endphp @@ -10,7 +11,7 @@ x-ignore ax-load ax-load-src="{{ FilamentAsset::getAlpineComponentSrc('filament-gridstack-dashboard-script', 'invaders-xx/filament-gridstack-dashboard') }}" - x-data="gridStackDashboard()" + x-data="gridStackDashboard({ columns:{{ $columns }} })" x-load-css="[@js(FilamentAsset::getStyleHref('filament-gridstack-dashboard-styles', package: 'invaders-xx/filament-gridstack-dashboard'))]" class="text-center" > @@ -86,7 +87,7 @@ class="border-danger-500 bg-danger-500 flex items-center border p-6 text-center" @endif
@foreach ($this->buildGridItemsForDesign() as $row => $widgets) - + @foreach ($widgets as $widgetKey => $widget) @php $widgetClass = $normalizeWidgetClass($widget['id']); diff --git a/src/Filament/Pages/Dashboard.php b/src/Filament/Pages/Dashboard.php index d37d39f..6b135cd 100644 --- a/src/Filament/Pages/Dashboard.php +++ b/src/Filament/Pages/Dashboard.php @@ -33,9 +33,9 @@ public static function getNavigationSort(): ?int return GridstackDashboardPlugin::get()->getNavigationSort() ?? parent::getNavigationSort(); } - public function getColumns(): int|array + public function getColumns(): int { - return 12; + return GridstackDashboardPlugin::get()->getColumns() ?? 12; } public function saveLayout(): void diff --git a/src/GridstackDashboardPlugin.php b/src/GridstackDashboardPlugin.php index e6cab60..24d342d 100644 --- a/src/GridstackDashboardPlugin.php +++ b/src/GridstackDashboardPlugin.php @@ -23,6 +23,8 @@ class GridstackDashboardPlugin implements Plugin protected int|Closure|null $navigationSort = -200; + protected int|Closure|null $columns = 12; + public static function make(): static { return app(static::class); @@ -63,6 +65,13 @@ public function defaultGrid(array|Closure $grid): static return $this; } + public function columns(int|Closure $columns): static + { + $this->columns = $columns; + + return $this; + } + public function navigationSort(int|Closure $navigationSort): static { $this->navigationSort = $navigationSort; @@ -109,6 +118,11 @@ public function getNavigationIcon(): string|Htmlable|null return $this->evaluate($this->navigationIcon); } + public function getColumns(): int + { + return $this->evaluate($this->columns); + } + public function boot(Panel $panel): void { }