@alekstar79/draggable-resizable-container 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +227 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.es.js +1 -1
- package/dist/index.umd.js +6 -7
- package/dist/index.umd.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.css
CHANGED
|
@@ -1 +1,227 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Base styles for Container Manager library
|
|
3
|
+
* These styles provide basic functionality and can be overridden
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* Container base styles */
|
|
7
|
+
.container {
|
|
8
|
+
position: absolute;
|
|
9
|
+
background: white;
|
|
10
|
+
border: 2px solid #e2e8f0;
|
|
11
|
+
border-radius: 8px;
|
|
12
|
+
box-shadow: 0 4px 6px rgba(0, 0, 0, .1);
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
resize: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* Drag handle base styles */
|
|
18
|
+
.drag-handle {
|
|
19
|
+
position: absolute;
|
|
20
|
+
top: 0;
|
|
21
|
+
left: 0;
|
|
22
|
+
right: 0;
|
|
23
|
+
height: 24px;
|
|
24
|
+
background: #f7fafc;
|
|
25
|
+
border-bottom: 1px solid #e2e8f0;
|
|
26
|
+
cursor: move;
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
justify-content: center;
|
|
30
|
+
user-select: none;
|
|
31
|
+
-webkit-user-select: none;
|
|
32
|
+
-moz-user-select: none;
|
|
33
|
+
-ms-user-select: none;
|
|
34
|
+
-webkit-touch-callout: none;
|
|
35
|
+
-webkit-tap-highlight-color: transparent;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* Container title with ellipsis */
|
|
39
|
+
.container-title {
|
|
40
|
+
font-weight: 600;
|
|
41
|
+
font-size: .9rem;
|
|
42
|
+
flex: 1;
|
|
43
|
+
white-space: nowrap;
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
text-overflow: ellipsis;
|
|
46
|
+
min-width: 0; /* Important for flexbox truncation */
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* Container content area */
|
|
50
|
+
.container-content {
|
|
51
|
+
position: absolute;
|
|
52
|
+
top: 40px;
|
|
53
|
+
left: 0;
|
|
54
|
+
right: 0;
|
|
55
|
+
bottom: 0;
|
|
56
|
+
padding: 16px;
|
|
57
|
+
overflow: auto;
|
|
58
|
+
box-sizing: border-box;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* Mode indicators */
|
|
62
|
+
.container[data-mode="pinned"] {
|
|
63
|
+
border-color: #e53e3e;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.container[data-mode="snap"] {
|
|
67
|
+
border-color: #38a169;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.container[data-mode="smooth"] {
|
|
71
|
+
border-color: #3182ce;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Enhanced resize handles for all directions
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
/* Direction-specific handle sizes and interactions */
|
|
79
|
+
.resize-n,
|
|
80
|
+
.resize-s {
|
|
81
|
+
height: 12px;
|
|
82
|
+
cursor: ns-resize;
|
|
83
|
+
left: 0;
|
|
84
|
+
right: 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.resize-e,
|
|
88
|
+
.resize-w {
|
|
89
|
+
width: 12px;
|
|
90
|
+
cursor: ew-resize;
|
|
91
|
+
top: 0;
|
|
92
|
+
bottom: 0;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.resize-ne,
|
|
96
|
+
.resize-nw,
|
|
97
|
+
.resize-se,
|
|
98
|
+
.resize-sw {
|
|
99
|
+
width: 16px;
|
|
100
|
+
height: 16px;
|
|
101
|
+
background: transparent; /* Changed from #4299e1 to transparent */
|
|
102
|
+
border-radius: 2px;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.resize-n { top: 0; }
|
|
106
|
+
.resize-s { bottom: 0; }
|
|
107
|
+
.resize-e { right: 0; }
|
|
108
|
+
.resize-w { left: 0; }
|
|
109
|
+
|
|
110
|
+
.resize-ne {
|
|
111
|
+
top: 0;
|
|
112
|
+
right: 0;
|
|
113
|
+
cursor: nesw-resize;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.resize-nw {
|
|
117
|
+
top: 0;
|
|
118
|
+
left: 0;
|
|
119
|
+
cursor: nwse-resize;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.resize-se {
|
|
123
|
+
bottom: 0;
|
|
124
|
+
right: 0;
|
|
125
|
+
cursor: nwse-resize;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.resize-sw {
|
|
129
|
+
bottom: 0;
|
|
130
|
+
left: 0;
|
|
131
|
+
cursor: nesw-resize;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/* Hover effects for better usability */
|
|
135
|
+
.resize-handle:hover {
|
|
136
|
+
background: rgba(66, 153, 225, .3);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/* Corner handles hover effects - changed background to match other handles */
|
|
140
|
+
.resize-ne:hover,
|
|
141
|
+
.resize-nw:hover,
|
|
142
|
+
.resize-se:hover,
|
|
143
|
+
.resize-sw:hover {
|
|
144
|
+
background: rgba(66, 153, 225, .3); /* Changed from #4299e1 to rgba */
|
|
145
|
+
transform: scale(1.1);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* Base styles for resize handles */
|
|
149
|
+
.resize-handle {
|
|
150
|
+
position: absolute;
|
|
151
|
+
background: transparent;
|
|
152
|
+
user-select: none;
|
|
153
|
+
-webkit-user-select: none;
|
|
154
|
+
-moz-user-select: none;
|
|
155
|
+
-ms-user-select: none;
|
|
156
|
+
transition: background-color 0.2s ease;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/* Handle content layout */
|
|
160
|
+
.handle-content {
|
|
161
|
+
display: flex;
|
|
162
|
+
justify-content: space-between;
|
|
163
|
+
align-items: center;
|
|
164
|
+
width: 100%;
|
|
165
|
+
padding: 0 8px;
|
|
166
|
+
box-sizing: border-box;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/* Mode controls container */
|
|
170
|
+
.mode-controls-container {
|
|
171
|
+
display: flex;
|
|
172
|
+
gap: 6px;
|
|
173
|
+
align-items: center;
|
|
174
|
+
flex-shrink: 0; /* Prevent shrinking */
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/* Mode buttons base styles */
|
|
178
|
+
.mode-btn {
|
|
179
|
+
width: 32px;
|
|
180
|
+
height: 32px;
|
|
181
|
+
border: none;
|
|
182
|
+
border-radius: 8px;
|
|
183
|
+
cursor: pointer;
|
|
184
|
+
font-size: 14px;
|
|
185
|
+
transition: all .3s cubic-bezier(.4, 0, .2, 1);
|
|
186
|
+
display: flex;
|
|
187
|
+
align-items: center;
|
|
188
|
+
justify-content: center;
|
|
189
|
+
background: transparent;
|
|
190
|
+
color: #6b7280;
|
|
191
|
+
position: relative;
|
|
192
|
+
overflow: hidden;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.mode-btn:hover {
|
|
196
|
+
transform: scale(1.2);
|
|
197
|
+
background: rgba(0, 0, 0, .05);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.mode-btn:active {
|
|
201
|
+
transform: scale(1.1);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/* Focus styles for accessibility */
|
|
205
|
+
.mode-btn:focus-visible {
|
|
206
|
+
outline: 2px solid #3b82f6;
|
|
207
|
+
outline-offset: 2px;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/* Custom scrollbar for containers */
|
|
211
|
+
.container-content::-webkit-scrollbar {
|
|
212
|
+
width: 6px;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.container-content::-webkit-scrollbar-track {
|
|
216
|
+
background: #f3f4f6;
|
|
217
|
+
border-radius: 3px;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.container-content::-webkit-scrollbar-thumb {
|
|
221
|
+
background: #9ca3af;
|
|
222
|
+
border-radius: 3px;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.container-content::-webkit-scrollbar-thumb:hover {
|
|
226
|
+
background: #6b7280;
|
|
227
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Exports all public API for the container manager library
|
|
4
4
|
*/
|
|
5
5
|
export type { AutoAdjustConfig, Boundaries, ContainerConfig, ContainerManagerInterface, ContainerEvent, ContainerState, DirectionMode, Plugin, ResizeConfig, MovementMode } from './core/types';
|
|
6
|
-
export type { StateInterface } from './utils';
|
|
7
|
-
export type {
|
|
6
|
+
export type { StateInterface, TemplateConfig } from './utils';
|
|
7
|
+
export type { SavedContainerState } from './plugins';
|
|
8
8
|
export { ContainerManager } from './core/ContainerManager';
|
|
9
9
|
export { ContainerInitializer, ContentCreator, TemplateLoader, NotificationSystem, StatsManager, getState, getTemplateLoader, initializeTemplateSystem } from './utils';
|
|
10
10
|
export { LoggingPlugin, EdgeDockingPlugin, SnappingPlugin, StatePersistencePlugin } from './plugins';
|
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
var Z = Object.defineProperty;
|
|
2
2
|
var _ = (c, t, e) => t in c ? Z(c, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[t] = e;
|
|
3
3
|
var a = (c, t, e) => _(c, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import Q, { reactive as $, computed as tt, effect as x, batch as k } from "@alekstar79/reactive-event-system";
|
package/dist/index.umd.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
(function(l,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("@alekstar79/reactive-event-system"),require("@alekstar79/utility")):typeof define=="function"&&define.amd?define(["exports","@alekstar79/reactive-event-system","@alekstar79/utility"],d):(l=typeof globalThis<"u"?globalThis:l||self,d(l.ContainerManager={},l.ReactiveEventSystem,l.utility))})(this,function(l,d,u){"use strict";var
|
|
2
|
-
/*$vite$:1*/`,document.head.appendChild(B);class F{constructor(t){a(this,"container");this.container=t||this.createContainer()}createContainer(){const t=document.querySelector(".notifications");if(t)return t;const e=document.createElement("div");return e.className="notifications",document.body.appendChild(e),e}show(t,e="info"){const i=document.createElement("li"),s=this.removeToast.bind(this,i);i.innerHTML=this.getToastHTML(t,e),i.className=`toast ${e}`,i.timeoutId=window.setTimeout(s,4e3);const r=i.querySelector(".icon");r&&r.addEventListener("click",s),this.container.appendChild(i)}getToastHTML(t,e){return`
|
|
1
|
+
(function(l,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("@alekstar79/reactive-event-system"),require("@alekstar79/utility")):typeof define=="function"&&define.amd?define(["exports","@alekstar79/reactive-event-system","@alekstar79/utility"],d):(l=typeof globalThis<"u"?globalThis:l||self,d(l.ContainerManager={},l.ReactiveEventSystem,l.utility))})(this,function(l,d,u){"use strict";var ut=Object.defineProperty;var mt=(l,d,u)=>d in l?ut(l,d,{enumerable:!0,configurable:!0,writable:!0,value:u}):l[d]=u;var a=(l,d,u)=>mt(l,typeof d!="symbol"?d+"":d,u);class B{constructor(t){a(this,"container");this.container=t||this.createContainer()}createContainer(){const t=document.querySelector(".notifications");if(t)return t;const e=document.createElement("div");return e.className="notifications",document.body.appendChild(e),e}show(t,e="info"){const i=document.createElement("li"),s=this.removeToast.bind(this,i);i.innerHTML=this.getToastHTML(t,e),i.className=`toast ${e}`,i.timeoutId=window.setTimeout(s,4e3);const r=i.querySelector(".icon");r&&r.addEventListener("click",s),this.container.appendChild(i)}getToastHTML(t,e){return`
|
|
3
2
|
<div class="column">
|
|
4
3
|
<i class="fa-solid ${{success:"fa-circle-check",error:"fa-circle-xmark",warning:"fa-triangle-exclamation",info:"fa-circle-info"}[e]}"></i>
|
|
5
4
|
<span>${t}</span>
|
|
6
5
|
</div>
|
|
7
6
|
<i class="icon fa-solid fa-xmark"></i>
|
|
8
|
-
`}removeToast(t){t.classList.add("hide"),t.timeoutId&&clearTimeout(t.timeoutId),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t)},300)}clear(){for(;this.container.firstChild;)this.container.removeChild(this.container.firstChild)}}new
|
|
7
|
+
`}removeToast(t){t.classList.add("hide"),t.timeoutId&&clearTimeout(t.timeoutId),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t)},300)}clear(){for(;this.container.firstChild;)this.container.removeChild(this.container.firstChild)}}new B;class q{static createContainerElement(t,e,i,s,r){const o=document.createElement("div");return o.className="container advanced-container new",o.style.position="absolute",o.style.width=`${t}px`,o.style.height=`${e}px`,i!==void 0&&(o.style.left=`${i}px`),s!==void 0&&(o.style.top=`${s}px`),r&&(o.style.borderColor=r),o}}class J{constructor(t){a(this,"templateLoader");this.templateLoader=t}async createContent(t,e){try{const i=e.classList.contains("container-content");let s;if(i?s=e:(s=e.querySelector(".container-content"),s||(s=document.createElement("div"),s.className="container-content",e.appendChild(s))),s.innerHTML="",typeof t=="string")s.innerHTML=t;else if(t instanceof HTMLElement)s.appendChild(t);else if(t.template)try{s.innerHTML=await this.templateLoader.loadTemplate(t.template)}catch(r){console.error(`[ContentCreator] Failed to load template: ${t.template}`,r),s.innerHTML=`<div class="template-error">Failed to load template: ${t.template}</div>`}return s}catch(i){throw console.error("[ContentCreator] Error creating content:",i),i}}setTemplateLoader(t){this.templateLoader=t}}class Z{constructor(){a(this,"globalStatsElement",null)}initialize(t){this.globalStatsElement=t}showContainerStats(t){this.globalStatsElement&&this.updateStatsPanel(this.generateContainerStatsHTML(t))}showGlobalStats(t){this.globalStatsElement&&this.updateStatsPanel(this.generateGlobalStatsHTML(t))}generateContainerStatsHTML(t){const e=t.hasSnapping&&t.step!==void 0?`<div class="stat-item">
|
|
9
8
|
<span class="stat-label">Step:</span>
|
|
10
9
|
<span class="stat-value">${t.step}</span>
|
|
11
10
|
</div>`:"";return`
|
|
@@ -39,7 +38,7 @@
|
|
|
39
38
|
<div class="stat-item">
|
|
40
39
|
<span class="stat-label">With Snapping:</span>
|
|
41
40
|
<span class="stat-value">${t.snappingCount}</span>
|
|
42
|
-
</div>`}updateStatsPanel(t){this.globalStatsElement&&(this.globalStatsElement.innerHTML=t)}}var tt=Object.defineProperty,et=(h,t,e)=>t in h?tt(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,v=(h,t,e)=>et(h,typeof t!="symbol"?t+"":t,e);class P{constructor(){v(this,"templates",new Map),v(this,"lastUpdated",new Map)}register(t){if(!t.name.trim())throw new Error("Template name cannot be empty");this.templates.set(t.name,t),this.lastUpdated.set(t.name,Date.now())}async registerBulk(t){for(const[e,i]of Object.entries(t))this.register({name:e,source:i})}get(t){return this.templates.get(t)}has(t){return this.templates.has(t)}remove(t){this.templates.delete(t),this.lastUpdated.delete(t)}list(){return Array.from(this.templates.keys())}clear(){this.templates.clear(),this.lastUpdated.clear()}getMetadata(t){var e;return(e=this.templates.get(t))==null?void 0:e.metadata}}class it{constructor(t=36e5){v(this,"cache",new Map),v(this,"ttl"),this.ttl=t}set(t,e){this.cache.set(t,{content:e,timestamp:Date.now()})}get(t){const e=this.cache.get(t);return e?this.ttl<=0||Date.now()-e.timestamp>this.ttl?(this.cache.delete(t),null):e.content:null}has(t){return this.get(t)!==null}clear(){this.cache.clear()}size(){return this.cache.size}}class O{constructor(t,e={}){v(this,"cache"),v(this,"config"),v(this,"metrics"),v(this,"retryQueue",new Map),v(this,"registry"),this.registry=t??new P,this.cache=new it(e==null?void 0:e.cacheTTL),this.config=this.normalizeConfig(e),this.metrics={totalLoads:0,totalHits:0,totalMisses:0,totalErrors:0,averageLoadTime:0,cacheHitRate:0}}normalizeConfig(t={}){var i;const e=t||{};return{environment:e.environment==="auto"?typeof process<"u"&&((i=process.env)==null?void 0:i.NODE_ENV)==="production"?"production":"development":e.environment??"development",cache:e.cache??!0,cacheTTL:e.cacheTTL??36e5,enableMetrics:e.enableMetrics??!0,onError:e.onError??(()=>{}),onWarn:e.onWarn??(()=>{}),fallbackTemplate:e.fallbackTemplate??'<div class="template-error">Template load failed</div>'}}async loadTemplate(t,e=2){const i=performance.now(),s=this.retryQueue.get(t)??0;if(this.metrics.totalLoads++,this.config.cache){const o=this.cache.get(t);if(o)return this.metrics.totalHits++,this.updateCacheHitRate(),o}this.metrics.totalMisses++;const r=this.registry.get(t);if(!r){const o=this.createError(`Template "${t}" not found. Available: ${this.registry.list().join(", ")}`,t,s);return this.metrics.totalErrors++,this.config.onError(o),this.config.fallbackTemplate}try{let o=typeof r.source=="function"?await r.source():r.source;if(typeof o!="string"){const c=this.createError("Template source must return a string, got "+typeof o,t,s);return this.metrics.totalErrors++,this.config.onError(c),this.config.fallbackTemplate}return this.config.cache&&this.cache.set(t,o),this.retryQueue.delete(t),this.recordLoadTime(i),o}catch(o){const c=o instanceof Error?o:new Error(String(o));if(s<e)return this.retryQueue.set(t,s+1),this.config.onWarn(`Retrying template "${t}" (attempt ${s+1}/${e})`),await new Promise(m=>setTimeout(m,100*Math.pow(2,s))),this.loadTemplate(t,e);const g=this.createError(`Failed to load template "${t}": ${c.message}`,t,s);return this.metrics.totalErrors++,this.config.onError(g),this.retryQueue.delete(t),this.config.fallbackTemplate}}async loadTemplates(t){const e={};return await Promise.all(t.map(async i=>{e[i]=await this.loadTemplate(i)})),e}getMetrics(){return{...this.metrics}}clearCache(){this.cache.clear()}resetMetrics(){this.metrics={totalLoads:0,totalHits:0,totalMisses:0,totalErrors:0,averageLoadTime:0,cacheHitRate:0}}has(t){return this.registry.has(t)}list(){return this.registry.list()}info(t){return this.registry.get(t)}createError(t,e,i){return Object.assign(new Error(t),{name:"TemplateLoadError",templateName:e,timestamp:new Date,retryCount:i})}recordLoadTime(t){if(this.config.enableMetrics){const e=performance.now()-t,i=this.metrics.averageLoadTime*(this.metrics.totalLoads-1)+e;this.metrics.averageLoadTime=i/this.metrics.totalLoads}}updateCacheHitRate(){this.config.enableMetrics&&(this.metrics.cacheHitRate=this.metrics.totalHits/this.metrics.totalLoads)}}let f;async function st(h=[]){const t=new P;let e={};try{e=Object.assign({"../demo/templates/media.html":()=>Promise.resolve().then(()=>lt).then(s=>s.default),"../demo/templates/stats.html":()=>Promise.resolve().then(()=>dt).then(s=>s.default),"../demo/templates/tasks.html":()=>Promise.resolve().then(()=>gt).then(s=>s.default)});const i={};Object.entries(e).forEach(([s,r])=>{var c;const o=(c=s.split("/").pop())==null?void 0:c.replace(/\.html$/,"");o&&(i[o]=async()=>typeof r=="function"?await r():String(r))}),await t.registerBulk(i)}catch(i){console.error("[TemplateLoader] Failed to load templates:",i),h.forEach(({name:s,source:r})=>{t.register({name:s,source:r})})}return new O(t,{environment:"development",cache:!0,cacheTTL:36e5,enableMetrics:!0,fallbackTemplate:'<div class="template-error">Template not found</div>',onError:i=>console.error(`[TemplateLoader Error] ${i.templateName}:`,i.message),onWarn:i=>console.warn(`[TemplateLoader] ${i}`)})}function nt(){const h=new P;return new O(h,{environment:"production",cache:!0,cacheTTL:36e5,enableMetrics:!1,onWarn:t=>console.warn(`[TemplateLoader] ${t}`),onError:t=>{console.warn(`Template load failed: ${t.templateName}`)}})}async function at(){return f||(typeof process<"u"&&process.env&&process.env.NODE_ENV==="development"?f=await st():(f=nt(),f.registry.register({name:"media",source:async()=>(await fetch("./templates/media.html")).text(),metadata:{version:"1.0",description:"Media card",cached:!0}}),f.registry.register({name:"userProfile",source:'<div class="user-profile"><h2>Profile</h2></div>',metadata:{version:"1.0",description:"User profile card",cached:!0}})),f)}function rt(){if(!f)throw new Error("Template system not initialized. Call initializeTemplateSystem() first.");return f}function ot(h,[t,e]){return e?{...h,[t]:e}:h}class Q{constructor(t){a(this,"source","cursor");a(this,"element",null);a(this,"top",!1);a(this,"right",!1);a(this,"bottom",!1);a(this,"left",!1);a(this,"edge",null);Object.assign(this,t)}}class W{constructor(){a(this,"listeners",{})}on(t,e){return this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(e),()=>{var i;(i=this.off)==null||i.call(this,t,e)}}emit(t,e){var i;(i=this.listeners[t])==null||i.forEach(s=>{try{s(e)}catch(r){console.error(`Error in event listener for ${String(t)}:`,r)}})}off(t,e){var i;(i=this.listeners[t])==null||i.delete(e)}destroy(){this.listeners={}}}class ct{constructor(t=50,e,i=null){a(this,"root");a(this,"edgeThreshold");a(this,"targets",new Set);a(this,"currentEdges",new Map);a(this,"rafId",null);a(this,"isActive",!1);a(this,"callbacks",new Set);a(this,"currentMousePos",{x:0,y:0});a(this,"currentCursorEdge",{top:!1,right:!1,bottom:!1,left:!1,edge:null});this.edgeThreshold=t,this.targets=e instanceof Set?e:new Set(e),this.root=i,e&&e.forEach(s=>this.targets.add(s)),this.checkBoundaries=this.checkBoundaries.bind(this)}start(){this.isActive||(this.isActive=!0,this.setupMouseTracking(),this.checkBoundaries())}stop(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.isActive=!1}addTarget(t){this.targets.add(t)}removeTarget(t){this.targets.delete(t),this.currentEdges.delete(t)}onChange(t){return this.callbacks.add(t),()=>{this.callbacks.delete(t)}}getCursorEdgeInfo(){return{...this.currentCursorEdge}}setEdgeThreshold(t){if(t<0)throw new Error("Edge threshold must be non-negative");this.edgeThreshold=t}setupMouseTracking(){document.addEventListener("mousemove",t=>{this.currentMousePos={x:t.clientX,y:t.clientY}})}getViewportSize(){return this.root?{width:this.root.clientWidth,height:this.root.clientHeight}:{width:window.innerWidth,height:window.innerHeight}}getRelativeRect(t){const e=t.getBoundingClientRect();if(!this.root)return e;const i=this.root.getBoundingClientRect();return{x:e.left-i.left,y:e.top-i.top,top:e.top-i.top,bottom:e.bottom-i.top,left:e.left-i.left,right:e.right-i.left,height:e.height,width:e.width,toJSON:()=>{}}}getCursorPosition(){if(!this.root)return this.currentMousePos;const t=this.root.getBoundingClientRect();return{x:this.currentMousePos.x-t.left,y:this.currentMousePos.y-t.top}}checkBoundaries(){this.targets.forEach(e=>{const i=this.checkElementBoundaries(e),s=this.currentEdges.get(e);(!s||this.hasEdgeChanged(s,i))&&(this.currentEdges.set(e,i),this.notifyCallbacks(new Q({...i,source:"element",element:e})))});const t=this.checkCursorBoundaries();this.hasEdgeChanged(this.currentCursorEdge,t)&&(this.currentCursorEdge=t,this.notifyCallbacks(new Q({...t,source:"cursor",element:null}))),this.isActive&&(this.rafId=requestAnimationFrame(this.checkBoundaries))}getCursorBoundingClientRect(){const{x:t,y:e}=this.getCursorPosition();return{x:t,y:e,top:e,bottom:e,left:t,right:t,width:0,height:0,toJSON:()=>{}}}checkElementBoundaries(t){const{width:e,height:i}=this.getViewportSize(),s=this.getRelativeRect(t),r={top:s.top<this.edgeThreshold,right:s.right>e-this.edgeThreshold,bottom:s.bottom>i-this.edgeThreshold,left:s.left<this.edgeThreshold,edge:null};return this.determineEdge(r,s,e,i),r}checkCursorBoundaries(){const t=this.getCursorBoundingClientRect(),e=window.innerWidth,i=window.innerHeight,s={top:t.top<this.edgeThreshold,right:t.right>e-this.edgeThreshold,bottom:t.bottom>i-this.edgeThreshold,left:t.left<this.edgeThreshold,edge:null};return this.determineEdge(s,t,e,i),s}hasEdgeChanged(t,e){return t.top!==e.top||t.right!==e.right||t.bottom!==e.bottom||t.left!==e.left}determineEdge(t,e,i,s){const r=[];if(t.top&&r.push("top"),t.right&&r.push("right"),t.bottom&&r.push("bottom"),t.left&&r.push("left"),r.length===0)t.edge=null;else if(r.length===1)t.edge=r[0];else{const o={top:e.top,right:i-e.right,bottom:s-e.bottom,left:e.left};t.edge=r.reduce((c,g)=>o[g]<o[c]?g:c)}}notifyCallbacks(t){this.callbacks.forEach(e=>{try{e(t)}catch(i){console.error("Error in boundary change callback:",i)}})}destroy(){this.stop(),this.callbacks.clear()}}const E=class E extends ct{constructor(e,i){super(e,i);a(this,"lastEdge",{});a(this,"emitter",null);this.onChange(this.onBoundaryChange.bind(this)),this.start()}static init(e,i){return E.instance??(E.instance=new E(e,i))}changed({edge:e,source:i,element:s}){return e!==this.lastEdge.edge||i!==this.lastEdge.source||s!==this.lastEdge.element}onBoundaryChange({edge:e,source:i,element:s}){this.changed({edge:e,source:i,element:s})&&(this.lastEdge=Object.entries({edge:e,source:i,element:s}).reduce(ot,{}),s?e?this.onEdgeEnter({edge:e,source:i,element:s}):this.onEdgeLeave(this.lastEdge):e?this.onCursorEnter({edge:e,source:i}):this.onCursorLeave(this.lastEdge))}onEdgeEnter(e){var i;(i=this.emitter)==null||i.emit("edge:enter",e)}onEdgeLeave(e){var i;(i=this.emitter)==null||i.emit("edge:leave",e)}onCursorEnter(e){var i;(i=this.emitter)==null||i.emit("cursor:enter",e)}onCursorLeave(e){var i;(i=this.emitter)==null||i.emit("cursor:leave",e)}setEmitter(e){this.emitter=e}on(e,i){var s;(s=this.emitter)==null||s.on(e,i)}getCurrentEdge(){return this.lastEdge}};a(E,"instance");let H=E;function ht(h={},t=[]){const e=H.init(h.edgeThreshold,t);return h.emitter&&e.setEmitter(h.emitter instanceof W?h.emitter:new W),e}const p=class p{constructor(){a(this,"draggable",[])}zIndex(t){return`${p.highestZIndex+this.draggable.findIndex(e=>e===t)}`}push(t){return this.draggable=[...new Set([...this.draggable,t])],this}remove(t){return this.draggable=this.draggable.filter(e=>e!==t),this}sort(t){return this.draggable.sort((e,i)=>e===t?1:i===t?-1:0),this}};a(p,"inatance"),a(p,"highestZIndex",1e3),a(p,"init",()=>p.inatance??(p.inatance=new p));let $=p;function j(){return{width:window.innerWidth||document.documentElement.clientWidth,height:window.innerHeight||document.documentElement.clientHeight}}function X(){return $.init()}const S=class S{constructor(t,e={}){a(this,"dragStream");a(this,"resizeStream");a(this,"stateChangeStream");a(this,"eventEmitter");a(this,"pluginEventEmitter");a(this,"config");a(this,"container");a(this,"dragHandle");a(this,"resizeHandles",new Map);a(this,"installedPlugins",new Set);a(this,"reactiveEffects",[]);a(this,"isDragging",!1);a(this,"isResizing",!1);a(this,"resizeDirection",null);a(this,"startX",0);a(this,"startY",0);a(this,"startState");a(this,"resizeObserver",null);a(this,"parentResizeObserver",null);a(this,"zIndexState");a(this,"reactiveState",d.reactive({x:0,y:0,width:0,height:0,mode:"smooth",draggingDirection:"all"}));a(this,"constrainedState",d.computed(()=>{var s;const t=this.reactiveState;if(!this.config)return{...t};let e={...t};const{boundaries:i}=this.config;if(e.width=u.clamp(t.width,i.minWidth||S.MINWIDTH,i.maxWidth||1/0),e.height=u.clamp(t.height,i.minHeight||S.MINHEIGHT,i.maxHeight||1/0),this.shouldConstrainToViewport()){const r=j();e.x=u.clamp(t.x,0,r.width-e.width),e.y=u.clamp(t.y,0,r.height-e.height)}return(s=this.config)!=null&&s.constrainToParent&&(e=this.constrainToParent(e)),e}));a(this,"domUpdateEffect",d.effect(()=>{var e;const t=this.constrainedState.value;this.container&&(this.container.style.left=`${t.x}px`,this.container.style.top=`${t.y}px`,this.container.style.width=`${t.width}px`,this.container.style.height=`${t.height}px`,(e=this.eventEmitter)==null||e.emit("stateChange",{type:"stateChange",state:{...t},mode:this.reactiveState.mode,element:this.container}))}));this.config=u.deepMerge({_uid:"",mode:"smooth",constrainToViewport:!1,draggingDirection:"all",constrainToParent:!1,boundaries:{minWidth:S.MINWIDTH,minHeight:S.MINHEIGHT},autoAdjust:{enabled:!1,width:!1,height:!1},resize:{enabled:!0,directions:["se"]}},e),this.container=t,this.zIndexState=X();const i=this.getCurrentState();this.reactiveState.x=i.x,this.reactiveState.y=i.y,this.reactiveState.width=i.width,this.reactiveState.height=i.height,this.reactiveState.mode=this.config.mode,this.reactiveState.draggingDirection=this.config.draggingDirection,this.eventEmitter=new d({enableMetrics:!0}),this.pluginEventEmitter=new d({enableMetrics:!0}),this.stateChangeStream=this.eventEmitter.stream("stateChange"),this.dragStream=this.eventEmitter.stream("drag"),this.resizeStream=this.eventEmitter.stream("resize"),this.startState=this.getState(),this.setupEventMiddleware(),this.initializeHandles(),this.bindEvents(),this.setupResizeObservers(),this.setupReactiveMonitoring()}setupResizeObservers(){var t;this.shouldConstrainToViewport()&&this.setupViewportResizeObserver(),(t=this.config.autoAdjust)!=null&&t.enabled&&this.setupParentResizeObserver()}shouldConstrainToViewport(){return!this.config.constrainToParent||this.config.constrainToViewport}setupViewportResizeObserver(){let t=null;this.resizeObserver=new ResizeObserver(()=>{t&&cancelAnimationFrame(t),t=requestAnimationFrame(()=>{this.handleViewportResize()})}),this.resizeObserver.observe(document.body)}handleViewportResize(){if(!this.shouldConstrainToViewport())return;const t=j(),i={...this.getState()};let s=!1;i.x+i.width>t.width&&(i.x=Math.max(0,t.width-i.width),s=!0),i.y+i.height>t.height&&(i.y=Math.max(0,t.height-i.height),s=!0),i.x<0&&(i.x=0,s=!0),i.y<0&&(i.y=0,s=!0),s&&(this.setState(i),this.eventEmitter.emit("viewportResize",{type:"viewportResize",state:this.getState(),mode:this.reactiveState.mode,element:this.container}))}setupParentResizeObserver(){const t=this.container.parentElement;t&&(this.parentResizeObserver=new ResizeObserver(e=>{for(const i of e)this.handleParentResize(i)}),this.parentResizeObserver.observe(t))}handleParentResize(t){const{autoAdjust:e}=this.config;if(!(e!=null&&e.enabled))return;const i=t.contentRect,r={...this.getState()};let o=!1;if(e.width){const c=this.getMaxWidthConstraint(),g=Math.min(i.width,c);Math.abs(r.width-g)>1&&(r.width=g,o=!0)}if(e.height){const c=this.getMaxHeightConstraint(),g=Math.min(i.height,c);Math.abs(r.height-g)>1&&(r.height=g,o=!0)}o&&(this.setState(r),this.eventEmitter.emit("autoAdjust",{type:"autoAdjust",state:this.getState(),mode:this.reactiveState.mode,element:this.container}))}initializeHandles(){var t;this.initializeDragHandle(),(t=this.config.resize)!=null&&t.enabled&&this.initializeResizeHandles()}initializeDragHandle(){this.dragHandle=this.container.querySelector("[data-drag-handle]"),this.dragHandle?this.dragHandle.setAttribute("oncontextmenu","return false"):(this.dragHandle=document.createElement("div"),this.dragHandle.className="drag-handle",this.dragHandle.setAttribute("data-drag-handle","true"),this.dragHandle.setAttribute("oncontextmenu","return false"),this.container.prepend(this.dragHandle))}initializeResizeHandles(){var e;(((e=this.config.resize)==null?void 0:e.directions)||["se"]).forEach(i=>{const s=this.createResizeHandle(i);this.resizeHandles.set(i,s),this.container.appendChild(s)})}createResizeHandle(t){const e=document.createElement("div");return e.className=`resize-handle resize-${t}`,e.setAttribute("data-resize-handle",t),e.setAttribute("data-resize-direction",t),e.addEventListener("contextmenu",this.onContextMenu),this.applyResizeHandleStyles(e,t),e}applyResizeHandleStyles(t,e){const i={n:"ns-resize",s:"ns-resize",e:"ew-resize",w:"ew-resize",ne:"nesw-resize",nw:"nwse-resize",se:"nwse-resize",sw:"nesw-resize"};t.style.position="absolute",t.style.cursor=i[e],this.positionResizeHandle(t,e)}positionResizeHandle(t,e){switch(e){case"n":t.style.top="0",t.style.left="0",t.style.right="0",t.style.height="12px";break;case"s":t.style.bottom="0",t.style.left="0",t.style.right="0",t.style.height="12px";break;case"e":t.style.right="0",t.style.top="0",t.style.bottom="0",t.style.width="12px";break;case"w":t.style.left="0",t.style.top="0",t.style.bottom="0",t.style.width="12px";break;case"ne":t.style.top="0",t.style.right="0",t.style.width="12px",t.style.height="12px";break;case"nw":t.style.top="0",t.style.left="0",t.style.width="12px",t.style.height="12px";break;case"se":t.style.bottom="0",t.style.right="0",t.style.width="12px",t.style.height="12px";break;case"sw":t.style.bottom="0",t.style.left="0",t.style.width="12px",t.style.height="12px";break}}bindEvents(){var t;this.onDragStart=this.onDragStart.bind(this),this.onDragMove=this.onDragMove.bind(this),this.onDragEnd=this.onDragEnd.bind(this),this.onResizeStart=this.onResizeStart.bind(this),this.onResizeMove=this.onResizeMove.bind(this),this.onResizeEnd=this.onResizeEnd.bind(this),this.onContextMenu=this.onContextMenu.bind(this),this.hasPluginByName("SnappingPlugin")||(this.dragHandle.addEventListener("mousedown",this.onDragStart),this.dragHandle.addEventListener("touchstart",this.onDragStart)),(t=this.config.resize)!=null&&t.enabled&&this.resizeHandles.forEach((e,i)=>{e.addEventListener("mousedown",s=>this.onResizeStart(s,i)),e.addEventListener("touchstart",s=>this.onResizeStart(s,i))}),this.dragHandle.addEventListener("contextmenu",this.onContextMenu)}applyMovementMode(t,e){const i={...this.startState};return this.reactiveState.mode==="smooth"&&(i.x=this.startState.x+t,i.y=this.startState.y+e),i}calculateResizeState(t,e,i){const s={...this.startState};switch(i){case"e":s.width=this.startState.width+t;break;case"w":s.width=this.startState.width-t,s.x=this.startState.x+t;break;case"n":s.height=this.startState.height-e,s.y=this.startState.y+e;break;case"s":s.height=this.startState.height+e;break;case"ne":s.width=this.startState.width+t,s.height=this.startState.height-e,s.y=this.startState.y+e;break;case"nw":s.width=this.startState.width-t,s.height=this.startState.height-e,s.x=this.startState.x+t,s.y=this.startState.y+e;break;case"se":s.width=this.startState.width+t,s.height=this.startState.height+e;break;case"sw":s.width=this.startState.width-t,s.height=this.startState.height+e,s.x=this.startState.x+t;break}return s}constrainToParent(t){const e=this.container.parentElement;if(!e)return t;const i=e.getBoundingClientRect();if(i.width===0||i.height===0)return t;const s=Math.max(0,i.width-t.width),r=Math.max(0,i.height-t.height),o=i.width-t.x,c=i.height-t.y;return{x:u.clamp(t.x,0,s),y:u.clamp(t.y,0,r),width:u.clamp(t.width,0,o),height:u.clamp(t.height,0,c)}}getMaxWidthConstraint(){const{boundaries:t}=this.config;let e=t.maxWidth||1/0;if(this.config.constrainToParent&&this.container.parentElement){const i=this.container.parentElement.getBoundingClientRect().width;e=Math.min(e,i)}return e}getMaxHeightConstraint(){const{boundaries:t}=this.config;let e=t.maxHeight||1/0;if(this.config.constrainToParent&&this.container.parentElement){const i=this.container.parentElement.getBoundingClientRect().height;e=Math.min(e,i)}return e}onContextMenu(t){t.preventDefault(),t.stopPropagation()}hasPluginByName(t){return Array.from(this.installedPlugins).some(e=>e.constructor.name===t)}getCurrentState(){const t=this.container.getBoundingClientRect(),e=window.getComputedStyle(this.container),i=parseFloat(e.width)||t.width,s=parseFloat(e.height)||t.height;return{x:t.left,y:t.top,width:i,height:s}}setupEventMiddleware(){this.eventEmitter.use("*",(t,e)=>(typeof window<"u"&&window.DEBUG_CONTAINER_MANAGER&&console.log(`[ContainerManager] ${e}:`,t),t)),this.eventEmitter.use("dragStart",(t,e)=>{if(this.reactiveState.mode==="pinned")throw new Error("Cannot drag in pinned mode");return t}),this.eventEmitter.use("drag",(t,e)=>t)}setupReactiveMonitoring(){const t=d.effect(()=>{const{state:i}=this.stateChangeStream});this.reactiveEffects.push(t);const e=d.effect(()=>{const i=this.eventEmitter.getMetrics();i.state.errorCount>10&&console.warn("[ContainerManager] High error count in event system:",i.state.errorCount)});this.reactiveEffects.push(e)}on(t,e){this.eventEmitter.on(t,e)}off(t,e){this.eventEmitter.off(t,e)}waitFor(t,e){return this.eventEmitter.waitFor(t,e)}getStream(t){return this.eventEmitter.stream(t)}pipe(t,e,i){return this.eventEmitter.pipe(t,e,i)}getEventMetrics(){return this.eventEmitter.getMetrics()}emitPluginEvent(t,e){this.pluginEventEmitter.emit(t,e)}onPluginEvent(t,e){this.pluginEventEmitter.on(t,e)}offPluginEvent(t,e){this.pluginEventEmitter.off(t,e)}usePluginMiddleware(t,e){return this.pluginEventEmitter.use(t,e)}onDragStart(t){if(this.reactiveState.mode==="pinned")return;t.preventDefault(),this.bringToFront(),this.isDragging=!0;const e=t instanceof MouseEvent?t.clientX:t.touches[0].clientX,i=t instanceof MouseEvent?t.clientY:t.touches[0].clientY;this.startX=e,this.startY=i,this.startState=this.getState(),this.eventEmitter.emit("dragStart",{type:"drag",state:this.getState(),mode:this.reactiveState.mode,element:this.container}),document.addEventListener("mousemove",this.onDragMove),document.addEventListener("mouseup",this.onDragEnd),document.addEventListener("touchmove",this.onDragMove),document.addEventListener("touchend",this.onDragEnd)}onDragMove(t){if(!this.isDragging)return;const{clientX:e,clientY:i}=this.directionResolver(t instanceof MouseEvent?t.clientX:t.touches[0].clientX,t instanceof MouseEvent?t.clientY:t.touches[0].clientY),s=e-this.startX,r=i-this.startY,o=this.applyMovementMode(s,r);this.setState(o),this.eventEmitter.emit("drag",{type:"drag",state:this.getState(),mode:this.reactiveState.mode,element:this.container})}onDragEnd(){this.isDragging=!1,document.removeEventListener("mousemove",this.onDragMove),document.removeEventListener("mouseup",this.onDragEnd),document.removeEventListener("touchmove",this.onDragMove),document.removeEventListener("touchend",this.onDragEnd),this.eventEmitter.emit("dragEnd",{type:"drag",state:this.getState(),mode:this.reactiveState.mode,element:this.container})}onResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.bringToFront(),this.isResizing=!0,this.resizeDirection=e;const i=t instanceof MouseEvent?t.clientX:t.touches[0].clientX,s=t instanceof MouseEvent?t.clientY:t.touches[0].clientY;this.startX=i,this.startY=s,this.startState=this.getState(),document.addEventListener("mousemove",this.onResizeMove),document.addEventListener("mouseup",this.onResizeEnd),document.addEventListener("touchmove",this.onResizeMove),document.addEventListener("touchend",this.onResizeEnd),this.eventEmitter.emit("resizeStart",{type:"resize",state:this.getState(),mode:this.reactiveState.mode,element:this.container,direction:e})}onResizeMove(t){if(!this.isResizing||!this.resizeDirection)return;const e=t instanceof MouseEvent?t.clientX:t.touches[0].clientX,i=t instanceof MouseEvent?t.clientY:t.touches[0].clientY,s=e-this.startX,r=i-this.startY,o=this.calculateResizeState(s,r,this.resizeDirection);this.setState(o),this.eventEmitter.emit("resize",{type:"resize",state:this.getState(),mode:this.reactiveState.mode,direction:this.resizeDirection,element:this.container})}onResizeEnd(){this.isResizing=!1,this.resizeDirection=null,document.removeEventListener("mousemove",this.onResizeMove),document.removeEventListener("mouseup",this.onResizeEnd),document.removeEventListener("touchmove",this.onResizeMove),document.removeEventListener("touchend",this.onResizeEnd),this.eventEmitter.emit("resizeEnd",{type:"resize",state:this.getState(),mode:this.reactiveState.mode,element:this.container})}setDirection(t){this.reactiveState.draggingDirection=t,this.emitPluginEvent("directionChanged",{direction:t})}getDirection(){return this.reactiveState.draggingDirection}directionResolver(t,e){const i=this.reactiveState.draggingDirection,s=i==="vertical",r=i==="horizontal";return{clientX:s?this.startX:t,clientY:r?this.startY:e}}getMode(){return this.reactiveState.mode}setMode(t){this.reactiveState.mode=t,this.eventEmitter.emit("modeChange",{type:"modeChange",state:this.getState(),mode:this.reactiveState.mode,element:this.container})}setBoundaries(t){this.config.boundaries={...this.config.boundaries,...t}}getState(){return{x:this.reactiveState.x,y:this.reactiveState.y,width:this.reactiveState.width,height:this.reactiveState.height}}setState(t){t.height!==void 0&&(this.reactiveState.height=t.height),t.width!==void 0&&(this.reactiveState.width=t.width),t.x!==void 0&&(this.reactiveState.x=t.x),t.y!==void 0&&(this.reactiveState.y=t.y),this.applyStateToDOM()}applyStateToDOM(){const t=this.getState();this.container.style.left=`${t.x}px`,this.container.style.top=`${t.y}px`,this.container.style.width=`${t.width}px`,this.container.style.height=`${t.height}px`}bringToFront(){const{_uid:t}=this.config;this.container.style.zIndex=this.zIndexState.sort(t).zIndex(t)}getContainer(){return this.container}setAutoAdjust(t){var e;this.config.autoAdjust={...this.config.autoAdjust,...t},this.parentResizeObserver&&(this.parentResizeObserver.disconnect(),this.parentResizeObserver=null),(e=this.config.autoAdjust)!=null&&e.enabled&&this.setupParentResizeObserver()}setResizeConfig(t){var e;this.config.resize={...this.config.resize,...t},this.resizeHandles.forEach(i=>i.remove()),this.resizeHandles.clear(),(e=this.config.resize)!=null&&e.enabled&&(this.initializeResizeHandles(),this.bindEvents())}setConstrainToParent(t){this.config.constrainToParent=t,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.shouldConstrainToViewport()&&this.setupViewportResizeObserver()}setConstrainToViewport(t){this.config.constrainToViewport=t,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.shouldConstrainToViewport()&&this.setupViewportResizeObserver()}recalculateForParent(){if(!this.config.constrainToParent||!this.container.parentElement)return;const t=this.container.parentElement.getBoundingClientRect(),e=this.getState();if(t.width===0||t.height===0)return;const i=e.width,s=e.height,r=Math.min(i,t.width),o=Math.min(s,t.height),c=e.x,g=e.y,m=Math.min(c,t.width-r),w=Math.min(g,t.height-o);this.setState({x:m,y:w,width:r,height:o}),this.eventEmitter.emit("parentRecalculated",{type:"parentRecalculated",state:this.getState(),mode:this.reactiveState.mode,element:this.container})}use(t,e){if(this.installedPlugins.has(t))return this;try{t.install(this,e),this.installedPlugins.add(t)}catch(i){console.error("[ContainerManager] Failed to install plugin:",i)}return this}hasPlugin(t){return this.installedPlugins.has(t)}getInstalledPlugins(){return Array.from(this.installedPlugins)}destroy(){this.reactiveEffects.forEach(t=>t()),this.reactiveEffects=[],this.stateChangeStream.destroy(),this.dragStream.destroy(),this.resizeStream.destroy(),this.eventEmitter.destroy(),this.pluginEventEmitter.destroy(),this.domUpdateEffect(),this.dragHandle.removeEventListener("mousedown",this.onDragStart),this.dragHandle.removeEventListener("touchstart",this.onDragStart),this.dragHandle.removeEventListener("contextmenu",this.onContextMenu),this.resizeHandles.forEach((t,e)=>{t.removeEventListener("mousedown",i=>this.onResizeStart(i,e)),t.removeEventListener("touchstart",i=>this.onResizeStart(i,e))}),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.parentResizeObserver&&(this.parentResizeObserver.disconnect(),this.parentResizeObserver=null),this.installedPlugins.clear(),this.zIndexState.remove(this.config._uid)}};a(S,"MINWIDTH",200),a(S,"MINHEIGHT",45);let I=S;const L=class L{constructor(t={}){a(this,"reactiveState",d.reactive({snapStep:10,enabled:!0,isActive:!1,lastPosition:null}));a(this,"manager");a(this,"startState",null);a(this,"startX",0);a(this,"startY",0);this.reactiveState.snapStep=t.snapStep??10,this.reactiveState.enabled=t.enabled??!0,this.onDragMove=this.onDragMove.bind(this),this.onDragEnd=this.onDragEnd.bind(this)}get pluginId(){return L._pluginId}install(t,e){this.manager=t,e&&(this.reactiveState.snapStep=e.snapStep??this.reactiveState.snapStep,this.reactiveState.enabled=e.enabled??this.reactiveState.enabled),this.overrideDragMethods(),this.addPluginMethods()}overrideDragMethods(){if(!this.manager)return;const t=this.manager.getContainer().querySelector(".drag-handle");t&&(t.onmousedown=e=>{this.onDragStart(e)},t.ontouchstart=e=>{this.onDragStart(e)})}onDragStart(t){var s,r;if(!this.manager||this.manager.getMode()==="pinned")return;t.preventDefault(),(r=(s=this.manager).bringToFront)==null||r.call(s),this.reactiveState.isActive=!0;const e=t instanceof MouseEvent?t.clientX:t.touches[0].clientX,i=t instanceof MouseEvent?t.clientY:t.touches[0].clientY;this.startX=e,this.startY=i,this.startState=this.manager.getState(),this.reactiveState.lastPosition={x:this.startState.x,y:this.startState.y},document.addEventListener("mousemove",this.onDragMove),document.addEventListener("mouseup",this.onDragEnd),document.addEventListener("touchmove",this.onDragMove),document.addEventListener("touchend",this.onDragEnd),this.manager.emitPluginEvent("dragStart",{type:"drag",state:this.startState,mode:this.manager.getMode()})}onDragMove(t){if(!this.reactiveState.isActive||!this.manager||!this.startState)return;const{clientX:e,clientY:i}=this.manager.directionResolver(t instanceof MouseEvent?t.clientX:t.touches[0].clientX,t instanceof MouseEvent?t.clientY:t.touches[0].clientY);let s=e-this.startX,r=i-this.startY;if(this.reactiveState.enabled){const g=this.applySnapping(s,r);s=g.deltaX,r=g.deltaY}const o={x:this.startState.x+s,y:this.startState.y+r,width:this.startState.width,height:this.startState.height},c=this.manager.config;c!=null&&c.constrainToViewport&&this.constrainToViewport(o),this.manager.setState(o),this.reactiveState.lastPosition={x:o.x,y:o.y},this.manager.emitPluginEvent("drag",{type:"drag",state:o,mode:this.manager.getMode()})}onDragEnd(){this.manager&&(this.reactiveState.isActive=!1,this.reactiveState.lastPosition=null,this.startState=null,document.removeEventListener("mousemove",this.onDragMove),document.removeEventListener("mouseup",this.onDragEnd),document.removeEventListener("touchmove",this.onDragMove),document.removeEventListener("touchend",this.onDragEnd),this.manager.emitPluginEvent("dragEnd",{type:"drag",state:this.manager.getState(),mode:this.manager.getMode()}))}applySnapping(t,e){return{deltaX:this.snapToGrid(t,this.reactiveState.snapStep),deltaY:this.snapToGrid(e,this.reactiveState.snapStep)}}snapToGrid(t,e){return Math.round(t/e)*e}constrainToViewport(t){const e=window.innerWidth||document.documentElement.clientWidth,i=window.innerHeight||document.documentElement.clientHeight;t.x=Math.max(0,Math.min(t.x,e-t.width)),t.y=Math.max(0,Math.min(t.y,i-t.height))}addPluginMethods(){this.manager.setSnapStep=t=>{this.reactiveState.snapStep=t,this.manager.emitPluginEvent("snapStepChanged",{snapStep:t})},this.manager.setSnappingEnabled=t=>{this.reactiveState.enabled=t,this.manager.emitPluginEvent("snappingEnabledChanged",{enabled:t})},this.manager.getSnappingConfig=()=>({snapStep:this.reactiveState.snapStep,enabled:this.reactiveState.enabled})}destroy(){this.reactiveState.isActive=!1,this.reactiveState.lastPosition=null}};a(L,"_pluginId",Symbol("SnappingPlugin"));let A=L;const R=class R{constructor(t={}){a(this,"dockedContainers",new Map);a(this,"occupiedEdges",new Map);a(this,"tracker",ht({emitter:!0,edgeThreshold:20}));a(this,"manager");a(this,"edgeThreshold");this.edgeThreshold=t.edgeThreshold??30,this.occupiedEdges.set("top",null),this.occupiedEdges.set("bottom",null),this.occupiedEdges.set("left",null),this.occupiedEdges.set("right",null)}get pluginId(){return R._pluginId}install(t){this.manager=t,this.tracker.addTarget(this.manager.getContainer()),this.tracker.on("edge:enter",e=>{e.source==="element"&&e.element===this.manager.getContainer()&&this.handleEdgeEnter(e.edge)}),this.tracker.on("edge:leave",e=>{e.source==="element"&&e.element===this.manager.getContainer()&&this.handleEdgeLeave(e.edge)}),this.attachEventHandlers()}handleEdgeEnter(t){const e=this.manager.getContainer();this.isEdgeOccupied(t)?e.classList.add("edge-dock-hint",`edge-dock-hint-${t}`,"edge-dock-blocked"):e.classList.add("edge-dock-hint",`edge-dock-hint-${t}`)}handleEdgeLeave(t){this.manager.getContainer().classList.remove("edge-dock-hint",`edge-dock-hint-${t}`,"edge-dock-blocked")}isEdgeOccupied(t){return this.occupiedEdges.get(t)!==null}attachEventHandlers(){const t=this.manager.getContainer();t.addEventListener("mouseenter",this.onMouseEnter.bind(this)),t.addEventListener("mouseleave",this.onMouseLeave.bind(this)),this.manager.on("dragStart",e=>{this.onDragStart(e.element)}),this.manager.on("drag",e=>{this.onDrag(e.element)}),this.manager.on("dragEnd",e=>{this.onDragEnd(e.element)})}onMouseEnter(){const t=this.manager.getContainer();this.isContainerDocked(t)&&t.classList.add("edge-docked-visible")}onMouseLeave(){const t=this.manager.getContainer();this.isContainerDocked(t)&&t.classList.remove("edge-docked-visible")}onDragStart(t){t.classList.remove("edge-dock-hint","edge-dock-blocked","edge-docked-visible","edge-dock-hint-top","edge-dock-hint-bottom","edge-dock-hint-left","edge-dock-hint-right");const e=this.dockedContainers.get(t);e&&this.undockContainer(t,e)}onDrag(t){const e=t.getBoundingClientRect(),i=this.getClosestEdge(e);this.updateEdgeHints(t,i)}onDragEnd(t){const e=t.getBoundingClientRect(),i=this.getClosestEdge(e);t.classList.remove("edge-dock-hint","edge-dock-blocked","edge-dock-hint-top","edge-dock-hint-bottom","edge-dock-hint-left","edge-dock-hint-right"),i&&!this.isEdgeOccupied(i)&&this.dockContainer(t,i)}updateEdgeHints(t,e){t.classList.remove("edge-dock-hint","edge-dock-blocked","edge-dock-hint-top","edge-dock-hint-bottom","edge-dock-hint-left","edge-dock-hint-right"),e&&(this.isEdgeOccupied(e)?t.classList.add("edge-dock-hint",`edge-dock-hint-${e}`,"edge-dock-blocked"):t.classList.add("edge-dock-hint",`edge-dock-hint-${e}`))}getClosestEdge(t){const e=t.top,i=t.left,s=window.innerHeight-t.bottom,r=window.innerWidth-t.right,c=Object.entries({top:e,bottom:s,left:i,right:r}).filter(([g,m])=>m>=-this.edgeThreshold&&m<=this.edgeThreshold).sort((g,m)=>g[1]-m[1]);return c.length>0?c[0][0]:null}dockContainer(t,e){const i=window.getComputedStyle(t),s=t.getBoundingClientRect(),r={x:s.left,y:s.top};this.dockedContainers.set(t,{element:t,edge:e,screenPosition:r,originalPosition:{top:parseFloat(i.top)||s.top,left:parseFloat(i.left)||s.left,width:s.width,height:s.height,transform:i.transform,position:i.position}}),this.occupiedEdges.set(e,t),t.style.top="",t.style.bottom="",t.style.left="",t.style.right="",t.style.width="",t.style.height="",t.style.transform="",t.classList.add("edge-docked",`edge-docked-${e}`),this.applyEdgePositioning(t,e,r),t.setAttribute("data-docked","true"),t.setAttribute("data-docked-edge",e)}applyEdgePositioning(t,e,i){const s=t.getBoundingClientRect();switch(e){case"top":t.style.left=`${i.x}px`,t.style.width=`${s.width}px`;break;case"bottom":t.style.left=`${i.x}px`,t.style.width=`${s.width}px`;break;case"left":t.style.top=`${i.y}px`,t.style.height=`${s.height}px`;break;case"right":t.style.top=`${i.y}px`,t.style.height=`${s.height}px`;break}}undockContainer(t,e){this.dockedContainers.delete(t),this.occupiedEdges.set(e.edge,null),t.classList.remove("edge-docked","edge-docked-visible","edge-docked-top","edge-docked-bottom","edge-docked-left","edge-docked-right"),t.removeAttribute("data-docked"),t.removeAttribute("data-docked-edge"),t.style.top="",t.style.bottom="",t.style.left="",t.style.right="",t.style.width="",t.style.height="",t.style.transform="",t.style.position="",this.restoreOriginalPosition(t,e)}restoreOriginalPosition(t,e){this.manager.setState({x:e.screenPosition.x,y:e.screenPosition.y,width:e.originalPosition.width,height:e.originalPosition.height})}getDockedContainer(t){const e=this.occupiedEdges.get(t);return e&&this.dockedContainers.get(e)||null}isContainerDocked(t){return this.dockedContainers.has(t)}getContainerDockEdge(t){const e=this.dockedContainers.get(t);return e?e.edge:null}destroy(){const t=this.manager.getContainer();t.removeEventListener("mouseenter",this.onMouseEnter.bind(this)),t.removeEventListener("mouseleave",this.onMouseLeave.bind(this)),this.dockedContainers.forEach((e,i)=>{this.undockContainer(i,e)}),this.dockedContainers.clear(),this.occupiedEdges.forEach((e,i)=>{this.occupiedEdges.set(i,null)})}};a(R,"_pluginId",Symbol("EdgeDockingPlugin"));let N=R;const n=class n{constructor(){a(this,"manager");a(this,"containerId");a(this,"storable",!0);a(this,"autoSaveEffect")}get pluginId(){return n._pluginId}static get containerStates(){return n.reactiveState.containerStates}static get closedQueue(){return n.reactiveState.closedQueue}static get storableContainers(){return n.reactiveState.storableContainers}install(t,e){if(this.manager=t,this.containerId=e==null?void 0:e.containerId,this.storable=(e==null?void 0:e.storable)??!0,!this.containerId){console.warn("[StatePersistencePlugin] containerId is required for state persistence");return}n.containers.push({manager:t,containerId:this.containerId,storable:this.storable}),this.storable&&n.registerContainer(this.containerId),n.isGlobalEventsInitialized||(n.initializeGlobalEvents(),n.isGlobalEventsInitialized=!0),this.storable&&this.setupAutoSaveEffect(),this.bindContainerEvents()}setupAutoSaveEffect(){if(!this.manager||!this.containerId)return;const t=u.debounce(()=>{this.storable&&this.saveState()},300);this.autoSaveEffect=d.effect(()=>{this.manager.getState(),this.manager.getMode(),t()})}bindContainerEvents(){this.manager&&(this.manager.on("dragStart",()=>{}),this.manager.on("dragEnd",()=>{this.storable&&this.saveState()}),this.manager.on("resizeEnd",()=>{this.storable&&this.saveState()}),this.manager.onPluginEvent("maximizeChanged",()=>{this.storable&&this.saveState()}),this.manager.onPluginEvent("directionChanged",()=>{this.storable&&this.saveState()}))}static initializeGlobalEvents(){window.addEventListener("beforeunload",()=>{n.saveAllContainers()}),document.addEventListener("visibilitychange",()=>{document.hidden&&n.saveAllContainers()}),window.addEventListener("resize",u.debounce(()=>{n.saveAllContainers()},500))}static registerContainer(t){try{n.storableContainers.includes(t)||(n.storableContainers.push(t),n.saveContainersToStorage())}catch(e){console.error("[StatePersistencePlugin] Failed to register container:",e)}}static saveContainersToStorage(){try{localStorage.setItem(n.STORABLE_CONTAINERS_KEY,JSON.stringify(n.storableContainers))}catch(t){console.error("[StatePersistencePlugin] Failed to save containers:",t)}}static getContainers(){try{const t=localStorage.getItem(n.STORABLE_CONTAINERS_KEY);return t?JSON.parse(t):[]}catch(t){return console.error("[StatePersistencePlugin] Failed to parse containers:",t),[]}}static isStorableContainer(t){return n.getContainers().includes(t)}static getAllStates(){try{const t=localStorage.getItem(n.STORAGE_KEY);return t?JSON.parse(t):{}}catch(t){return console.error("[StatePersistencePlugin] Failed to parse stored states:",t),{}}}static addToClosedQueue(t){if(!n.isStorableContainer(t)){console.log(`[StatePersistencePlugin] Skipping closed queue for non-storable container: ${t}`);return}if(!n.getContainerState(t)){console.error(`[StatePersistencePlugin] Cannot add ${t} to closed queue: state not found`);return}const i=n.closedQueue,s=i.indexOf(t);s>-1&&i.splice(s,1),i.push(t),n.saveClosedQueueToStorage()}static saveClosedQueueToStorage(){try{localStorage.setItem(n.CLOSED_QUEUE_KEY,JSON.stringify(n.closedQueue))}catch(t){console.error("[StatePersistencePlugin] Failed to save closed queue:",t)}}static getClosedQueue(){try{const t=localStorage.getItem(n.CLOSED_QUEUE_KEY);return t?JSON.parse(t):[]}catch(t){return console.error("[StatePersistencePlugin] Failed to parse closed queue:",t),[]}}saveState(){!this.manager||!this.containerId||!this.storable||d.batch(()=>{var z;n.reactiveState.isSaving=!0,n.reactiveState.pendingChanges=!0;const t=this.manager.getContainer(),e=t.dataset.maximized==="true",i=this.manager.getState(),s=this.manager.getMode(),r=this.manager.getDirection(),o=t.dataset.containerType||"unknown",c=t.dataset.title,g=t.dataset.color,m=t.dataset.useSnapping==="true",w=(z=this.manager.config)==null?void 0:z.resize,y=t.parentElement,T=y&&y!==document.body?y.id||`parent-${this.containerId}`:void 0,C={...i,mode:s,draggingDirection:r,isMaximized:e,containerType:o,title:c,color:g,useSnapping:m,isClosed:!1,parentElementId:T,closedTimestamp:0,resize:w,storable:!0};n.reactiveState.containerStates[this.containerId]=C;const b=n.getAllStates();b[this.containerId]=C,localStorage.setItem(n.STORAGE_KEY,JSON.stringify(b)),n.reactiveState.lastSaved=Date.now(),n.reactiveState.isSaving=!1})}static saveContainerStateBeforeClose(t,e){var U,K,q;if(!n.isStorableContainer(e)){n.containers=n.containers.filter(M=>M.containerId!==e);return}const s=t.getState(),r=t.getMode(),o=t.getContainer(),c=t.getDirection(),g=o.dataset.maximized==="true",m=o.dataset.containerType||"unknown",w=o.dataset.title,y=o.dataset.color,T=o.dataset.useSnapping==="true",C=(U=t.config)==null?void 0:U.resize,b=((K=t.isEdgeDocked)==null?void 0:K.call(t))||!1,z=((q=t.getDockEdge)==null?void 0:q.call(t))||null,k=o.parentElement,ut=k&&k!==document.body?k.id||`parent-${e}`:void 0,G={...s,mode:r,draggingDirection:c,isMaximized:g,isEdgeDocked:b,dockEdge:z||void 0,containerType:m,title:w,color:y,useSnapping:T,isClosed:!0,parentElementId:ut,closedTimestamp:Date.now(),resize:C,storable:!0},V=n.getAllStates();V[e]=G;try{localStorage.setItem(n.STORAGE_KEY,JSON.stringify(V))}catch(M){console.error("[StatePersistencePlugin] Failed to save to localStorage:",M)}n.reactiveState.containerStates[e]=G,n.containers=n.containers.filter(M=>M.containerId!==e),n.addToClosedQueue(e)}static saveAllContainers(){d.batch(()=>{const t=n.getAllStates();n.containers.filter(e=>!("storable"in e&&e.storable===!1)).forEach(({manager:e,containerId:i})=>{var k;const s=e.getState(),r=e.getMode(),o=e.getContainer(),c=e.getDirection(),g=o.dataset.maximized==="true",m=o.dataset.containerType||"unknown",w=o.dataset.title,y=o.dataset.color,T=o.dataset.useSnapping==="true",C=(k=e.config)==null?void 0:k.resize,b=o.parentElement,z=b&&b!==document.body?b.id||`parent-${i}`:void 0;t[i]={...s,mode:r,draggingDirection:c,isMaximized:g,containerType:m,title:w,color:y,useSnapping:T,isClosed:!1,parentElementId:z,closedTimestamp:0,resize:C,storable:!0}}),n.reactiveState.containerStates=t,localStorage.setItem(n.STORAGE_KEY,JSON.stringify(t)),n.reactiveState.lastSaved=Date.now()})}static popLastClosedContainer(){try{const t=n.closedQueue;if(t.length===0)return null;const e=t.pop();return n.saveClosedQueueToStorage(),e}catch(t){return console.error("[StatePersistencePlugin] Failed to pop last closed container:",t),null}}static hasClosedContainers(){return n.closedQueue.length>0}static getContainerState(t){try{const e=n.containerStates[t];if(e)return e;const s=n.getAllStates()[t];return s?(n.reactiveState.containerStates[t]=s,s):null}catch(e){return console.error("[StatePersistencePlugin] Failed to get container state:",e),null}}static getAllContainerStates(){return n.getAllStates()}static hasContainerState(t){return n.getContainerState(t)!==null}static updateContainerState(t,e){try{const i=n.getAllStates(),s=i[t];if(s){const r={...s,...e};i[t]=r,localStorage.setItem(n.STORAGE_KEY,JSON.stringify(i)),n.reactiveState.containerStates[t]=r}else{console.warn(`[StatePersistencePlugin] No state found for container ${t}, creating new state`);const r={x:0,y:0,width:300,height:200,mode:"smooth",draggingDirection:"all",isMaximized:!1,containerType:"unknown",isClosed:!1,storable:n.isStorableContainer(t),...e};i[t]=r,localStorage.setItem(n.STORAGE_KEY,JSON.stringify(i)),n.reactiveState.containerStates[t]=r}}catch(i){console.error("[StatePersistencePlugin] Failed to update container state:",i)}}static clearStorage(){d.batch(()=>{n.reactiveState.containerStates={},n.closedQueue.length=0,n.storableContainers.length=0,n.reactiveState.isSaving=!1,n.reactiveState.lastSaved=null,n.reactiveState.pendingChanges=!1}),localStorage.removeItem(n.STORAGE_KEY),localStorage.removeItem(n.CLOSED_QUEUE_KEY),localStorage.removeItem(n.STORABLE_CONTAINERS_KEY),n.containers=[]}static initializeReactiveState(){try{const t=n.getAllStates(),e=n.getClosedQueue(),i=n.getContainers();d.batch(()=>{n.reactiveState.containerStates=t,n.closedQueue.length=0,n.closedQueue.push(...e),n.storableContainers.length=0,n.storableContainers.push(...i)})}catch(t){console.error("[StatePersistencePlugin] Failed to initialize reactive state:",t)}}static getMetrics(){return{totalContainers:Object.keys(n.containerStates).length,demoContainers:n.storableContainers.length,closedContainers:n.closedQueue.length,lastSaved:n.reactiveState.lastSaved,isSaving:n.reactiveState.isSaving}}static debugStorage(){console.log("[StatePersistencePlugin] === START DEBUG INFO ===");try{const t=localStorage.getItem(n.STORAGE_KEY);if(t){const s=JSON.parse(t);console.log(`[StatePersistencePlugin] Number of states: ${Object.keys(s).length}`),console.log("[StatePersistencePlugin] State keys:",Object.keys(s));for(const[r,o]of Object.entries(s))console.log(`[StatePersistencePlugin] State ${r}:`,{storable:o.storable,isClosed:o.isClosed,title:o.title})}const e=localStorage.getItem(n.CLOSED_QUEUE_KEY);console.log("[StatePersistencePlugin] Closed queue:",e?JSON.parse(e):[]);const i=localStorage.getItem(n.STORABLE_CONTAINERS_KEY);console.log("[StatePersistencePlugin] Storable containers:",i?JSON.parse(i):[])}catch(t){console.error("[StatePersistencePlugin] Debug error:",t)}console.log("[StatePersistencePlugin] === END DEBUG INFO ===")}destroy(){this.autoSaveEffect&&(this.autoSaveEffect(),this.autoSaveEffect=void 0),this.containerId&&(n.containers=n.containers.filter(t=>t.containerId!==this.containerId))}};a(n,"_pluginId",Symbol("StatePersistencePlugin")),a(n,"STORAGE_KEY","containerManagerState"),a(n,"CLOSED_QUEUE_KEY","containerManagerClosedQueue"),a(n,"STORABLE_CONTAINERS_KEY","containerManagerStorableContainers"),a(n,"reactiveState",d.reactive({isSaving:!1,lastSaved:null,pendingChanges:!1,containerStates:{},closedQueue:[],storableContainers:[]})),a(n,"isGlobalEventsInitialized",!1),a(n,"containers",[]);let x=n;x.initializeReactiveState();const D=class D{constructor(){a(this,"manager");a(this,"containerName","");a(this,"notificationSystem",null)}get pluginId(){return D._pluginId}install(t,e){this.manager=t,this.containerName=(e==null?void 0:e.containerName)||`Container-${Math.random().toString(36).substring(2,11)}`,this.notificationSystem=e==null?void 0:e.notificationSystem,this.bindEvents()}bindEvents(){this.manager&&(this.logResize=u.debounce(this.logResize.bind(this),250),this.logDrag=u.debounce(this.logDrag.bind(this),250),this.logViewportResize=u.debounce(this.logViewportResize.bind(this),250),this.logSnapStep=u.debounce(this.logSnapStep.bind(this),250),this.manager.on("modeChange",t=>{this.logModeChange(t.mode)}),this.manager.on("resize",t=>{this.logResize(t.state)}),this.manager.on("resizeEnd",t=>{this.logResize(t.state)}),this.manager.on("drag",t=>{this.logDrag(t.state)}),this.manager.on("dragEnd",t=>{this.logDrag(t.state)}),this.manager.on("viewportResize",t=>{this.logViewportResize(t.state)}),this.manager.onPluginEvent("snappingEnabledChanged",t=>{this.logSnappingEnabled(t.enabled)}),this.manager.onPluginEvent("snapStepChanged",t=>{this.logSnapStep(t.snapStep)}),this.manager.onPluginEvent("directionChanged",t=>{this.logDirectionChange(t.direction)}))}logResize(t){const e=`Resized to ${Math.round(t.width)}×${Math.round(t.height)}`;this.showNotification(e,"info")}logDrag(t){const e=`Moved to (${Math.round(t.x)}, ${Math.round(t.y)})`;this.showNotification(e,"info")}logModeChange(t){const e=`Mode changed to ${t}`;this.showNotification(e,"warning")}logViewportResize(t){const e=`Adjusted position to (${Math.round(t.x)}, ${Math.round(t.y)}) due to window resize`;this.showNotification(e,"info")}logSnappingEnabled(t){const e=`Snapping ${t?"enabled":"disabled"}`;this.showNotification(e,t?"success":"warning")}logSnapStep(t){const e=`Snap step changed to ${t}px`;this.showNotification(e,"info")}logDirectionChange(t){const e=`Drag direction: ${t}`;this.showNotification(e,"info")}showNotification(t,e){if(this.notificationSystem){const i=`${this.containerName}: ${t}`;this.notificationSystem.show(i,e)}}};a(D,"_pluginId",Symbol("LoggingPlugin"));let Y=D;const lt=Object.freeze(Object.defineProperty({__proto__:null,default:`<div class="media-content">
|
|
41
|
+
</div>`}updateStatsPanel(t){this.globalStatsElement&&(this.globalStatsElement.innerHTML=t)}}var _=Object.defineProperty,tt=(h,t,e)=>t in h?_(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,v=(h,t,e)=>tt(h,typeof t!="symbol"?t+"":t,e);class P{constructor(){v(this,"templates",new Map),v(this,"lastUpdated",new Map)}register(t){if(!t.name.trim())throw new Error("Template name cannot be empty");this.templates.set(t.name,t),this.lastUpdated.set(t.name,Date.now())}async registerBulk(t){for(const[e,i]of Object.entries(t))this.register({name:e,source:i})}get(t){return this.templates.get(t)}has(t){return this.templates.has(t)}remove(t){this.templates.delete(t),this.lastUpdated.delete(t)}list(){return Array.from(this.templates.keys())}clear(){this.templates.clear(),this.lastUpdated.clear()}getMetadata(t){var e;return(e=this.templates.get(t))==null?void 0:e.metadata}}class et{constructor(t=36e5){v(this,"cache",new Map),v(this,"ttl"),this.ttl=t}set(t,e){this.cache.set(t,{content:e,timestamp:Date.now()})}get(t){const e=this.cache.get(t);return e?this.ttl<=0||Date.now()-e.timestamp>this.ttl?(this.cache.delete(t),null):e.content:null}has(t){return this.get(t)!==null}clear(){this.cache.clear()}size(){return this.cache.size}}class O{constructor(t,e={}){v(this,"cache"),v(this,"config"),v(this,"metrics"),v(this,"retryQueue",new Map),v(this,"registry"),this.registry=t??new P,this.cache=new et(e==null?void 0:e.cacheTTL),this.config=this.normalizeConfig(e),this.metrics={totalLoads:0,totalHits:0,totalMisses:0,totalErrors:0,averageLoadTime:0,cacheHitRate:0}}normalizeConfig(t={}){var i;const e=t||{};return{environment:e.environment==="auto"?typeof process<"u"&&((i=process.env)==null?void 0:i.NODE_ENV)==="production"?"production":"development":e.environment??"development",cache:e.cache??!0,cacheTTL:e.cacheTTL??36e5,enableMetrics:e.enableMetrics??!0,onError:e.onError??(()=>{}),onWarn:e.onWarn??(()=>{}),fallbackTemplate:e.fallbackTemplate??'<div class="template-error">Template load failed</div>'}}async loadTemplate(t,e=2){const i=performance.now(),s=this.retryQueue.get(t)??0;if(this.metrics.totalLoads++,this.config.cache){const o=this.cache.get(t);if(o)return this.metrics.totalHits++,this.updateCacheHitRate(),o}this.metrics.totalMisses++;const r=this.registry.get(t);if(!r){const o=this.createError(`Template "${t}" not found. Available: ${this.registry.list().join(", ")}`,t,s);return this.metrics.totalErrors++,this.config.onError(o),this.config.fallbackTemplate}try{let o=typeof r.source=="function"?await r.source():r.source;if(typeof o!="string"){const c=this.createError("Template source must return a string, got "+typeof o,t,s);return this.metrics.totalErrors++,this.config.onError(c),this.config.fallbackTemplate}return this.config.cache&&this.cache.set(t,o),this.retryQueue.delete(t),this.recordLoadTime(i),o}catch(o){const c=o instanceof Error?o:new Error(String(o));if(s<e)return this.retryQueue.set(t,s+1),this.config.onWarn(`Retrying template "${t}" (attempt ${s+1}/${e})`),await new Promise(m=>setTimeout(m,100*Math.pow(2,s))),this.loadTemplate(t,e);const g=this.createError(`Failed to load template "${t}": ${c.message}`,t,s);return this.metrics.totalErrors++,this.config.onError(g),this.retryQueue.delete(t),this.config.fallbackTemplate}}async loadTemplates(t){const e={};return await Promise.all(t.map(async i=>{e[i]=await this.loadTemplate(i)})),e}getMetrics(){return{...this.metrics}}clearCache(){this.cache.clear()}resetMetrics(){this.metrics={totalLoads:0,totalHits:0,totalMisses:0,totalErrors:0,averageLoadTime:0,cacheHitRate:0}}has(t){return this.registry.has(t)}list(){return this.registry.list()}info(t){return this.registry.get(t)}createError(t,e,i){return Object.assign(new Error(t),{name:"TemplateLoadError",templateName:e,timestamp:new Date,retryCount:i})}recordLoadTime(t){if(this.config.enableMetrics){const e=performance.now()-t,i=this.metrics.averageLoadTime*(this.metrics.totalLoads-1)+e;this.metrics.averageLoadTime=i/this.metrics.totalLoads}}updateCacheHitRate(){this.config.enableMetrics&&(this.metrics.cacheHitRate=this.metrics.totalHits/this.metrics.totalLoads)}}let f;async function it(h=[]){const t=new P;let e={};try{e=Object.assign({"../demo/templates/media.html":()=>Promise.resolve().then(()=>ht).then(s=>s.default),"../demo/templates/stats.html":()=>Promise.resolve().then(()=>lt).then(s=>s.default),"../demo/templates/tasks.html":()=>Promise.resolve().then(()=>dt).then(s=>s.default)});const i={};Object.entries(e).forEach(([s,r])=>{var c;const o=(c=s.split("/").pop())==null?void 0:c.replace(/\.html$/,"");o&&(i[o]=async()=>typeof r=="function"?await r():String(r))}),await t.registerBulk(i)}catch(i){console.error("[TemplateLoader] Failed to load templates:",i),h.forEach(({name:s,source:r})=>{t.register({name:s,source:r})})}return new O(t,{environment:"development",cache:!0,cacheTTL:36e5,enableMetrics:!0,fallbackTemplate:'<div class="template-error">Template not found</div>',onError:i=>console.error(`[TemplateLoader Error] ${i.templateName}:`,i.message),onWarn:i=>console.warn(`[TemplateLoader] ${i}`)})}function st(){const h=new P;return new O(h,{environment:"production",cache:!0,cacheTTL:36e5,enableMetrics:!1,onWarn:t=>console.warn(`[TemplateLoader] ${t}`),onError:t=>{console.warn(`Template load failed: ${t.templateName}`)}})}async function nt(){return f||(typeof process<"u"&&process.env&&process.env.NODE_ENV==="development"?f=await it():(f=st(),f.registry.register({name:"media",source:async()=>(await fetch("./templates/media.html")).text(),metadata:{version:"1.0",description:"Media card",cached:!0}}),f.registry.register({name:"userProfile",source:'<div class="user-profile"><h2>Profile</h2></div>',metadata:{version:"1.0",description:"User profile card",cached:!0}})),f)}function at(){if(!f)throw new Error("Template system not initialized. Call initializeTemplateSystem() first.");return f}function rt(h,[t,e]){return e?{...h,[t]:e}:h}class F{constructor(t){a(this,"source","cursor");a(this,"element",null);a(this,"top",!1);a(this,"right",!1);a(this,"bottom",!1);a(this,"left",!1);a(this,"edge",null);Object.assign(this,t)}}class Q{constructor(){a(this,"listeners",{})}on(t,e){return this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(e),()=>{var i;(i=this.off)==null||i.call(this,t,e)}}emit(t,e){var i;(i=this.listeners[t])==null||i.forEach(s=>{try{s(e)}catch(r){console.error(`Error in event listener for ${String(t)}:`,r)}})}off(t,e){var i;(i=this.listeners[t])==null||i.delete(e)}destroy(){this.listeners={}}}class ot{constructor(t=50,e,i=null){a(this,"root");a(this,"edgeThreshold");a(this,"targets",new Set);a(this,"currentEdges",new Map);a(this,"rafId",null);a(this,"isActive",!1);a(this,"callbacks",new Set);a(this,"currentMousePos",{x:0,y:0});a(this,"currentCursorEdge",{top:!1,right:!1,bottom:!1,left:!1,edge:null});this.edgeThreshold=t,this.targets=e instanceof Set?e:new Set(e),this.root=i,e&&e.forEach(s=>this.targets.add(s)),this.checkBoundaries=this.checkBoundaries.bind(this)}start(){this.isActive||(this.isActive=!0,this.setupMouseTracking(),this.checkBoundaries())}stop(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.isActive=!1}addTarget(t){this.targets.add(t)}removeTarget(t){this.targets.delete(t),this.currentEdges.delete(t)}onChange(t){return this.callbacks.add(t),()=>{this.callbacks.delete(t)}}getCursorEdgeInfo(){return{...this.currentCursorEdge}}setEdgeThreshold(t){if(t<0)throw new Error("Edge threshold must be non-negative");this.edgeThreshold=t}setupMouseTracking(){document.addEventListener("mousemove",t=>{this.currentMousePos={x:t.clientX,y:t.clientY}})}getViewportSize(){return this.root?{width:this.root.clientWidth,height:this.root.clientHeight}:{width:window.innerWidth,height:window.innerHeight}}getRelativeRect(t){const e=t.getBoundingClientRect();if(!this.root)return e;const i=this.root.getBoundingClientRect();return{x:e.left-i.left,y:e.top-i.top,top:e.top-i.top,bottom:e.bottom-i.top,left:e.left-i.left,right:e.right-i.left,height:e.height,width:e.width,toJSON:()=>{}}}getCursorPosition(){if(!this.root)return this.currentMousePos;const t=this.root.getBoundingClientRect();return{x:this.currentMousePos.x-t.left,y:this.currentMousePos.y-t.top}}checkBoundaries(){this.targets.forEach(e=>{const i=this.checkElementBoundaries(e),s=this.currentEdges.get(e);(!s||this.hasEdgeChanged(s,i))&&(this.currentEdges.set(e,i),this.notifyCallbacks(new F({...i,source:"element",element:e})))});const t=this.checkCursorBoundaries();this.hasEdgeChanged(this.currentCursorEdge,t)&&(this.currentCursorEdge=t,this.notifyCallbacks(new F({...t,source:"cursor",element:null}))),this.isActive&&(this.rafId=requestAnimationFrame(this.checkBoundaries))}getCursorBoundingClientRect(){const{x:t,y:e}=this.getCursorPosition();return{x:t,y:e,top:e,bottom:e,left:t,right:t,width:0,height:0,toJSON:()=>{}}}checkElementBoundaries(t){const{width:e,height:i}=this.getViewportSize(),s=this.getRelativeRect(t),r={top:s.top<this.edgeThreshold,right:s.right>e-this.edgeThreshold,bottom:s.bottom>i-this.edgeThreshold,left:s.left<this.edgeThreshold,edge:null};return this.determineEdge(r,s,e,i),r}checkCursorBoundaries(){const t=this.getCursorBoundingClientRect(),e=window.innerWidth,i=window.innerHeight,s={top:t.top<this.edgeThreshold,right:t.right>e-this.edgeThreshold,bottom:t.bottom>i-this.edgeThreshold,left:t.left<this.edgeThreshold,edge:null};return this.determineEdge(s,t,e,i),s}hasEdgeChanged(t,e){return t.top!==e.top||t.right!==e.right||t.bottom!==e.bottom||t.left!==e.left}determineEdge(t,e,i,s){const r=[];if(t.top&&r.push("top"),t.right&&r.push("right"),t.bottom&&r.push("bottom"),t.left&&r.push("left"),r.length===0)t.edge=null;else if(r.length===1)t.edge=r[0];else{const o={top:e.top,right:i-e.right,bottom:s-e.bottom,left:e.left};t.edge=r.reduce((c,g)=>o[g]<o[c]?g:c)}}notifyCallbacks(t){this.callbacks.forEach(e=>{try{e(t)}catch(i){console.error("Error in boundary change callback:",i)}})}destroy(){this.stop(),this.callbacks.clear()}}const b=class b extends ot{constructor(e,i){super(e,i);a(this,"lastEdge",{});a(this,"emitter",null);this.onChange(this.onBoundaryChange.bind(this)),this.start()}static init(e,i){return b.instance??(b.instance=new b(e,i))}changed({edge:e,source:i,element:s}){return e!==this.lastEdge.edge||i!==this.lastEdge.source||s!==this.lastEdge.element}onBoundaryChange({edge:e,source:i,element:s}){this.changed({edge:e,source:i,element:s})&&(this.lastEdge=Object.entries({edge:e,source:i,element:s}).reduce(rt,{}),s?e?this.onEdgeEnter({edge:e,source:i,element:s}):this.onEdgeLeave(this.lastEdge):e?this.onCursorEnter({edge:e,source:i}):this.onCursorLeave(this.lastEdge))}onEdgeEnter(e){var i;(i=this.emitter)==null||i.emit("edge:enter",e)}onEdgeLeave(e){var i;(i=this.emitter)==null||i.emit("edge:leave",e)}onCursorEnter(e){var i;(i=this.emitter)==null||i.emit("cursor:enter",e)}onCursorLeave(e){var i;(i=this.emitter)==null||i.emit("cursor:leave",e)}setEmitter(e){this.emitter=e}on(e,i){var s;(s=this.emitter)==null||s.on(e,i)}getCurrentEdge(){return this.lastEdge}};a(b,"instance");let H=b;function ct(h={},t=[]){const e=H.init(h.edgeThreshold,t);return h.emitter&&e.setEmitter(h.emitter instanceof Q?h.emitter:new Q),e}const p=class p{constructor(){a(this,"draggable",[])}zIndex(t){return`${p.highestZIndex+this.draggable.findIndex(e=>e===t)}`}push(t){return this.draggable=[...new Set([...this.draggable,t])],this}remove(t){return this.draggable=this.draggable.filter(e=>e!==t),this}sort(t){return this.draggable.sort((e,i)=>e===t?1:i===t?-1:0),this}};a(p,"inatance"),a(p,"highestZIndex",1e3),a(p,"init",()=>p.inatance??(p.inatance=new p));let $=p;function W(){return{width:window.innerWidth||document.documentElement.clientWidth,height:window.innerHeight||document.documentElement.clientHeight}}function X(){return $.init()}const S=class S{constructor(t,e={}){a(this,"dragStream");a(this,"resizeStream");a(this,"stateChangeStream");a(this,"eventEmitter");a(this,"pluginEventEmitter");a(this,"config");a(this,"container");a(this,"dragHandle");a(this,"resizeHandles",new Map);a(this,"installedPlugins",new Set);a(this,"reactiveEffects",[]);a(this,"isDragging",!1);a(this,"isResizing",!1);a(this,"resizeDirection",null);a(this,"startX",0);a(this,"startY",0);a(this,"startState");a(this,"resizeObserver",null);a(this,"parentResizeObserver",null);a(this,"zIndexState");a(this,"reactiveState",d.reactive({x:0,y:0,width:0,height:0,mode:"smooth",draggingDirection:"all"}));a(this,"constrainedState",d.computed(()=>{var s;const t=this.reactiveState;if(!this.config)return{...t};let e={...t};const{boundaries:i}=this.config;if(e.width=u.clamp(t.width,i.minWidth||S.MINWIDTH,i.maxWidth||1/0),e.height=u.clamp(t.height,i.minHeight||S.MINHEIGHT,i.maxHeight||1/0),this.shouldConstrainToViewport()){const r=W();e.x=u.clamp(t.x,0,r.width-e.width),e.y=u.clamp(t.y,0,r.height-e.height)}return(s=this.config)!=null&&s.constrainToParent&&(e=this.constrainToParent(e)),e}));a(this,"domUpdateEffect",d.effect(()=>{var e;const t=this.constrainedState.value;this.container&&(this.container.style.left=`${t.x}px`,this.container.style.top=`${t.y}px`,this.container.style.width=`${t.width}px`,this.container.style.height=`${t.height}px`,(e=this.eventEmitter)==null||e.emit("stateChange",{type:"stateChange",state:{...t},mode:this.reactiveState.mode,element:this.container}))}));this.config=u.deepMerge({_uid:"",mode:"smooth",constrainToViewport:!1,draggingDirection:"all",constrainToParent:!1,boundaries:{minWidth:S.MINWIDTH,minHeight:S.MINHEIGHT},autoAdjust:{enabled:!1,width:!1,height:!1},resize:{enabled:!0,directions:["se"]}},e),this.container=t,this.zIndexState=X();const i=this.getCurrentState();this.reactiveState.x=i.x,this.reactiveState.y=i.y,this.reactiveState.width=i.width,this.reactiveState.height=i.height,this.reactiveState.mode=this.config.mode,this.reactiveState.draggingDirection=this.config.draggingDirection,this.eventEmitter=new d({enableMetrics:!0}),this.pluginEventEmitter=new d({enableMetrics:!0}),this.stateChangeStream=this.eventEmitter.stream("stateChange"),this.dragStream=this.eventEmitter.stream("drag"),this.resizeStream=this.eventEmitter.stream("resize"),this.startState=this.getState(),this.setupEventMiddleware(),this.initializeHandles(),this.bindEvents(),this.setupResizeObservers(),this.setupReactiveMonitoring()}setupResizeObservers(){var t;this.shouldConstrainToViewport()&&this.setupViewportResizeObserver(),(t=this.config.autoAdjust)!=null&&t.enabled&&this.setupParentResizeObserver()}shouldConstrainToViewport(){return!this.config.constrainToParent||this.config.constrainToViewport}setupViewportResizeObserver(){let t=null;this.resizeObserver=new ResizeObserver(()=>{t&&cancelAnimationFrame(t),t=requestAnimationFrame(()=>{this.handleViewportResize()})}),this.resizeObserver.observe(document.body)}handleViewportResize(){if(!this.shouldConstrainToViewport())return;const t=W(),i={...this.getState()};let s=!1;i.x+i.width>t.width&&(i.x=Math.max(0,t.width-i.width),s=!0),i.y+i.height>t.height&&(i.y=Math.max(0,t.height-i.height),s=!0),i.x<0&&(i.x=0,s=!0),i.y<0&&(i.y=0,s=!0),s&&(this.setState(i),this.eventEmitter.emit("viewportResize",{type:"viewportResize",state:this.getState(),mode:this.reactiveState.mode,element:this.container}))}setupParentResizeObserver(){const t=this.container.parentElement;t&&(this.parentResizeObserver=new ResizeObserver(e=>{for(const i of e)this.handleParentResize(i)}),this.parentResizeObserver.observe(t))}handleParentResize(t){const{autoAdjust:e}=this.config;if(!(e!=null&&e.enabled))return;const i=t.contentRect,r={...this.getState()};let o=!1;if(e.width){const c=this.getMaxWidthConstraint(),g=Math.min(i.width,c);Math.abs(r.width-g)>1&&(r.width=g,o=!0)}if(e.height){const c=this.getMaxHeightConstraint(),g=Math.min(i.height,c);Math.abs(r.height-g)>1&&(r.height=g,o=!0)}o&&(this.setState(r),this.eventEmitter.emit("autoAdjust",{type:"autoAdjust",state:this.getState(),mode:this.reactiveState.mode,element:this.container}))}initializeHandles(){var t;this.initializeDragHandle(),(t=this.config.resize)!=null&&t.enabled&&this.initializeResizeHandles()}initializeDragHandle(){this.dragHandle=this.container.querySelector("[data-drag-handle]"),this.dragHandle?this.dragHandle.setAttribute("oncontextmenu","return false"):(this.dragHandle=document.createElement("div"),this.dragHandle.className="drag-handle",this.dragHandle.setAttribute("data-drag-handle","true"),this.dragHandle.setAttribute("oncontextmenu","return false"),this.container.prepend(this.dragHandle))}initializeResizeHandles(){var e;(((e=this.config.resize)==null?void 0:e.directions)||["se"]).forEach(i=>{const s=this.createResizeHandle(i);this.resizeHandles.set(i,s),this.container.appendChild(s)})}createResizeHandle(t){const e=document.createElement("div");return e.className=`resize-handle resize-${t}`,e.setAttribute("data-resize-handle",t),e.setAttribute("data-resize-direction",t),e.addEventListener("contextmenu",this.onContextMenu),this.applyResizeHandleStyles(e,t),e}applyResizeHandleStyles(t,e){const i={n:"ns-resize",s:"ns-resize",e:"ew-resize",w:"ew-resize",ne:"nesw-resize",nw:"nwse-resize",se:"nwse-resize",sw:"nesw-resize"};t.style.position="absolute",t.style.cursor=i[e],this.positionResizeHandle(t,e)}positionResizeHandle(t,e){switch(e){case"n":t.style.top="0",t.style.left="0",t.style.right="0",t.style.height="12px";break;case"s":t.style.bottom="0",t.style.left="0",t.style.right="0",t.style.height="12px";break;case"e":t.style.right="0",t.style.top="0",t.style.bottom="0",t.style.width="12px";break;case"w":t.style.left="0",t.style.top="0",t.style.bottom="0",t.style.width="12px";break;case"ne":t.style.top="0",t.style.right="0",t.style.width="12px",t.style.height="12px";break;case"nw":t.style.top="0",t.style.left="0",t.style.width="12px",t.style.height="12px";break;case"se":t.style.bottom="0",t.style.right="0",t.style.width="12px",t.style.height="12px";break;case"sw":t.style.bottom="0",t.style.left="0",t.style.width="12px",t.style.height="12px";break}}bindEvents(){var t;this.onDragStart=this.onDragStart.bind(this),this.onDragMove=this.onDragMove.bind(this),this.onDragEnd=this.onDragEnd.bind(this),this.onResizeStart=this.onResizeStart.bind(this),this.onResizeMove=this.onResizeMove.bind(this),this.onResizeEnd=this.onResizeEnd.bind(this),this.onContextMenu=this.onContextMenu.bind(this),this.hasPluginByName("SnappingPlugin")||(this.dragHandle.addEventListener("mousedown",this.onDragStart),this.dragHandle.addEventListener("touchstart",this.onDragStart)),(t=this.config.resize)!=null&&t.enabled&&this.resizeHandles.forEach((e,i)=>{e.addEventListener("mousedown",s=>this.onResizeStart(s,i)),e.addEventListener("touchstart",s=>this.onResizeStart(s,i))}),this.dragHandle.addEventListener("contextmenu",this.onContextMenu)}applyMovementMode(t,e){const i={...this.startState};return this.reactiveState.mode==="smooth"&&(i.x=this.startState.x+t,i.y=this.startState.y+e),i}calculateResizeState(t,e,i){const s={...this.startState};switch(i){case"e":s.width=this.startState.width+t;break;case"w":s.width=this.startState.width-t,s.x=this.startState.x+t;break;case"n":s.height=this.startState.height-e,s.y=this.startState.y+e;break;case"s":s.height=this.startState.height+e;break;case"ne":s.width=this.startState.width+t,s.height=this.startState.height-e,s.y=this.startState.y+e;break;case"nw":s.width=this.startState.width-t,s.height=this.startState.height-e,s.x=this.startState.x+t,s.y=this.startState.y+e;break;case"se":s.width=this.startState.width+t,s.height=this.startState.height+e;break;case"sw":s.width=this.startState.width-t,s.height=this.startState.height+e,s.x=this.startState.x+t;break}return s}constrainToParent(t){const e=this.container.parentElement;if(!e)return t;const i=e.getBoundingClientRect();if(i.width===0||i.height===0)return t;const s=Math.max(0,i.width-t.width),r=Math.max(0,i.height-t.height),o=i.width-t.x,c=i.height-t.y;return{x:u.clamp(t.x,0,s),y:u.clamp(t.y,0,r),width:u.clamp(t.width,0,o),height:u.clamp(t.height,0,c)}}getMaxWidthConstraint(){const{boundaries:t}=this.config;let e=t.maxWidth||1/0;if(this.config.constrainToParent&&this.container.parentElement){const i=this.container.parentElement.getBoundingClientRect().width;e=Math.min(e,i)}return e}getMaxHeightConstraint(){const{boundaries:t}=this.config;let e=t.maxHeight||1/0;if(this.config.constrainToParent&&this.container.parentElement){const i=this.container.parentElement.getBoundingClientRect().height;e=Math.min(e,i)}return e}onContextMenu(t){t.preventDefault(),t.stopPropagation()}hasPluginByName(t){return Array.from(this.installedPlugins).some(e=>e.constructor.name===t)}getCurrentState(){const t=this.container.getBoundingClientRect(),e=window.getComputedStyle(this.container),i=parseFloat(e.width)||t.width,s=parseFloat(e.height)||t.height;return{x:t.left,y:t.top,width:i,height:s}}setupEventMiddleware(){this.eventEmitter.use("*",(t,e)=>(typeof window<"u"&&window.DEBUG_CONTAINER_MANAGER&&console.log(`[ContainerManager] ${e}:`,t),t)),this.eventEmitter.use("dragStart",(t,e)=>{if(this.reactiveState.mode==="pinned")throw new Error("Cannot drag in pinned mode");return t}),this.eventEmitter.use("drag",(t,e)=>t)}setupReactiveMonitoring(){const t=d.effect(()=>{const{state:i}=this.stateChangeStream});this.reactiveEffects.push(t);const e=d.effect(()=>{const i=this.eventEmitter.getMetrics();i.state.errorCount>10&&console.warn("[ContainerManager] High error count in event system:",i.state.errorCount)});this.reactiveEffects.push(e)}on(t,e){this.eventEmitter.on(t,e)}off(t,e){this.eventEmitter.off(t,e)}waitFor(t,e){return this.eventEmitter.waitFor(t,e)}getStream(t){return this.eventEmitter.stream(t)}pipe(t,e,i){return this.eventEmitter.pipe(t,e,i)}getEventMetrics(){return this.eventEmitter.getMetrics()}emitPluginEvent(t,e){this.pluginEventEmitter.emit(t,e)}onPluginEvent(t,e){this.pluginEventEmitter.on(t,e)}offPluginEvent(t,e){this.pluginEventEmitter.off(t,e)}usePluginMiddleware(t,e){return this.pluginEventEmitter.use(t,e)}onDragStart(t){if(this.reactiveState.mode==="pinned")return;t.preventDefault(),this.bringToFront(),this.isDragging=!0;const e=t instanceof MouseEvent?t.clientX:t.touches[0].clientX,i=t instanceof MouseEvent?t.clientY:t.touches[0].clientY;this.startX=e,this.startY=i,this.startState=this.getState(),this.eventEmitter.emit("dragStart",{type:"drag",state:this.getState(),mode:this.reactiveState.mode,element:this.container}),document.addEventListener("mousemove",this.onDragMove),document.addEventListener("mouseup",this.onDragEnd),document.addEventListener("touchmove",this.onDragMove),document.addEventListener("touchend",this.onDragEnd)}onDragMove(t){if(!this.isDragging)return;const{clientX:e,clientY:i}=this.directionResolver(t instanceof MouseEvent?t.clientX:t.touches[0].clientX,t instanceof MouseEvent?t.clientY:t.touches[0].clientY),s=e-this.startX,r=i-this.startY,o=this.applyMovementMode(s,r);this.setState(o),this.eventEmitter.emit("drag",{type:"drag",state:this.getState(),mode:this.reactiveState.mode,element:this.container})}onDragEnd(){this.isDragging=!1,document.removeEventListener("mousemove",this.onDragMove),document.removeEventListener("mouseup",this.onDragEnd),document.removeEventListener("touchmove",this.onDragMove),document.removeEventListener("touchend",this.onDragEnd),this.eventEmitter.emit("dragEnd",{type:"drag",state:this.getState(),mode:this.reactiveState.mode,element:this.container})}onResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.bringToFront(),this.isResizing=!0,this.resizeDirection=e;const i=t instanceof MouseEvent?t.clientX:t.touches[0].clientX,s=t instanceof MouseEvent?t.clientY:t.touches[0].clientY;this.startX=i,this.startY=s,this.startState=this.getState(),document.addEventListener("mousemove",this.onResizeMove),document.addEventListener("mouseup",this.onResizeEnd),document.addEventListener("touchmove",this.onResizeMove),document.addEventListener("touchend",this.onResizeEnd),this.eventEmitter.emit("resizeStart",{type:"resize",state:this.getState(),mode:this.reactiveState.mode,element:this.container,direction:e})}onResizeMove(t){if(!this.isResizing||!this.resizeDirection)return;const e=t instanceof MouseEvent?t.clientX:t.touches[0].clientX,i=t instanceof MouseEvent?t.clientY:t.touches[0].clientY,s=e-this.startX,r=i-this.startY,o=this.calculateResizeState(s,r,this.resizeDirection);this.setState(o),this.eventEmitter.emit("resize",{type:"resize",state:this.getState(),mode:this.reactiveState.mode,direction:this.resizeDirection,element:this.container})}onResizeEnd(){this.isResizing=!1,this.resizeDirection=null,document.removeEventListener("mousemove",this.onResizeMove),document.removeEventListener("mouseup",this.onResizeEnd),document.removeEventListener("touchmove",this.onResizeMove),document.removeEventListener("touchend",this.onResizeEnd),this.eventEmitter.emit("resizeEnd",{type:"resize",state:this.getState(),mode:this.reactiveState.mode,element:this.container})}setDirection(t){this.reactiveState.draggingDirection=t,this.emitPluginEvent("directionChanged",{direction:t})}getDirection(){return this.reactiveState.draggingDirection}directionResolver(t,e){const i=this.reactiveState.draggingDirection,s=i==="vertical",r=i==="horizontal";return{clientX:s?this.startX:t,clientY:r?this.startY:e}}getMode(){return this.reactiveState.mode}setMode(t){this.reactiveState.mode=t,this.eventEmitter.emit("modeChange",{type:"modeChange",state:this.getState(),mode:this.reactiveState.mode,element:this.container})}setBoundaries(t){this.config.boundaries={...this.config.boundaries,...t}}getState(){return{x:this.reactiveState.x,y:this.reactiveState.y,width:this.reactiveState.width,height:this.reactiveState.height}}setState(t){t.height!==void 0&&(this.reactiveState.height=t.height),t.width!==void 0&&(this.reactiveState.width=t.width),t.x!==void 0&&(this.reactiveState.x=t.x),t.y!==void 0&&(this.reactiveState.y=t.y),this.applyStateToDOM()}applyStateToDOM(){const t=this.getState();this.container.style.left=`${t.x}px`,this.container.style.top=`${t.y}px`,this.container.style.width=`${t.width}px`,this.container.style.height=`${t.height}px`}bringToFront(){const{_uid:t}=this.config;this.container.style.zIndex=this.zIndexState.sort(t).zIndex(t)}getContainer(){return this.container}setAutoAdjust(t){var e;this.config.autoAdjust={...this.config.autoAdjust,...t},this.parentResizeObserver&&(this.parentResizeObserver.disconnect(),this.parentResizeObserver=null),(e=this.config.autoAdjust)!=null&&e.enabled&&this.setupParentResizeObserver()}setResizeConfig(t){var e;this.config.resize={...this.config.resize,...t},this.resizeHandles.forEach(i=>i.remove()),this.resizeHandles.clear(),(e=this.config.resize)!=null&&e.enabled&&(this.initializeResizeHandles(),this.bindEvents())}setConstrainToParent(t){this.config.constrainToParent=t,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.shouldConstrainToViewport()&&this.setupViewportResizeObserver()}setConstrainToViewport(t){this.config.constrainToViewport=t,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.shouldConstrainToViewport()&&this.setupViewportResizeObserver()}recalculateForParent(){if(!this.config.constrainToParent||!this.container.parentElement)return;const t=this.container.parentElement.getBoundingClientRect(),e=this.getState();if(t.width===0||t.height===0)return;const i=e.width,s=e.height,r=Math.min(i,t.width),o=Math.min(s,t.height),c=e.x,g=e.y,m=Math.min(c,t.width-r),y=Math.min(g,t.height-o);this.setState({x:m,y,width:r,height:o}),this.eventEmitter.emit("parentRecalculated",{type:"parentRecalculated",state:this.getState(),mode:this.reactiveState.mode,element:this.container})}use(t,e){if(this.installedPlugins.has(t))return this;try{t.install(this,e),this.installedPlugins.add(t)}catch(i){console.error("[ContainerManager] Failed to install plugin:",i)}return this}hasPlugin(t){return this.installedPlugins.has(t)}getInstalledPlugins(){return Array.from(this.installedPlugins)}destroy(){this.reactiveEffects.forEach(t=>t()),this.reactiveEffects=[],this.stateChangeStream.destroy(),this.dragStream.destroy(),this.resizeStream.destroy(),this.eventEmitter.destroy(),this.pluginEventEmitter.destroy(),this.domUpdateEffect(),this.dragHandle.removeEventListener("mousedown",this.onDragStart),this.dragHandle.removeEventListener("touchstart",this.onDragStart),this.dragHandle.removeEventListener("contextmenu",this.onContextMenu),this.resizeHandles.forEach((t,e)=>{t.removeEventListener("mousedown",i=>this.onResizeStart(i,e)),t.removeEventListener("touchstart",i=>this.onResizeStart(i,e))}),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.parentResizeObserver&&(this.parentResizeObserver.disconnect(),this.parentResizeObserver=null),this.installedPlugins.clear(),this.zIndexState.remove(this.config._uid)}};a(S,"MINWIDTH",200),a(S,"MINHEIGHT",45);let I=S;const L=class L{constructor(t={}){a(this,"reactiveState",d.reactive({snapStep:10,enabled:!0,isActive:!1,lastPosition:null}));a(this,"manager");a(this,"startState",null);a(this,"startX",0);a(this,"startY",0);this.reactiveState.snapStep=t.snapStep??10,this.reactiveState.enabled=t.enabled??!0,this.onDragMove=this.onDragMove.bind(this),this.onDragEnd=this.onDragEnd.bind(this)}get pluginId(){return L._pluginId}install(t,e){this.manager=t,e&&(this.reactiveState.snapStep=e.snapStep??this.reactiveState.snapStep,this.reactiveState.enabled=e.enabled??this.reactiveState.enabled),this.overrideDragMethods(),this.addPluginMethods()}overrideDragMethods(){if(!this.manager)return;const t=this.manager.getContainer().querySelector(".drag-handle");t&&(t.onmousedown=e=>{this.onDragStart(e)},t.ontouchstart=e=>{this.onDragStart(e)})}onDragStart(t){var s,r;if(!this.manager||this.manager.getMode()==="pinned")return;t.preventDefault(),(r=(s=this.manager).bringToFront)==null||r.call(s),this.reactiveState.isActive=!0;const e=t instanceof MouseEvent?t.clientX:t.touches[0].clientX,i=t instanceof MouseEvent?t.clientY:t.touches[0].clientY;this.startX=e,this.startY=i,this.startState=this.manager.getState(),this.reactiveState.lastPosition={x:this.startState.x,y:this.startState.y},document.addEventListener("mousemove",this.onDragMove),document.addEventListener("mouseup",this.onDragEnd),document.addEventListener("touchmove",this.onDragMove),document.addEventListener("touchend",this.onDragEnd),this.manager.emitPluginEvent("dragStart",{type:"drag",state:this.startState,mode:this.manager.getMode()})}onDragMove(t){if(!this.reactiveState.isActive||!this.manager||!this.startState)return;const{clientX:e,clientY:i}=this.manager.directionResolver(t instanceof MouseEvent?t.clientX:t.touches[0].clientX,t instanceof MouseEvent?t.clientY:t.touches[0].clientY);let s=e-this.startX,r=i-this.startY;if(this.reactiveState.enabled){const g=this.applySnapping(s,r);s=g.deltaX,r=g.deltaY}const o={x:this.startState.x+s,y:this.startState.y+r,width:this.startState.width,height:this.startState.height},c=this.manager.config;c!=null&&c.constrainToViewport&&this.constrainToViewport(o),this.manager.setState(o),this.reactiveState.lastPosition={x:o.x,y:o.y},this.manager.emitPluginEvent("drag",{type:"drag",state:o,mode:this.manager.getMode()})}onDragEnd(){this.manager&&(this.reactiveState.isActive=!1,this.reactiveState.lastPosition=null,this.startState=null,document.removeEventListener("mousemove",this.onDragMove),document.removeEventListener("mouseup",this.onDragEnd),document.removeEventListener("touchmove",this.onDragMove),document.removeEventListener("touchend",this.onDragEnd),this.manager.emitPluginEvent("dragEnd",{type:"drag",state:this.manager.getState(),mode:this.manager.getMode()}))}applySnapping(t,e){return{deltaX:this.snapToGrid(t,this.reactiveState.snapStep),deltaY:this.snapToGrid(e,this.reactiveState.snapStep)}}snapToGrid(t,e){return Math.round(t/e)*e}constrainToViewport(t){const e=window.innerWidth||document.documentElement.clientWidth,i=window.innerHeight||document.documentElement.clientHeight;t.x=Math.max(0,Math.min(t.x,e-t.width)),t.y=Math.max(0,Math.min(t.y,i-t.height))}addPluginMethods(){this.manager.setSnapStep=t=>{this.reactiveState.snapStep=t,this.manager.emitPluginEvent("snapStepChanged",{snapStep:t})},this.manager.setSnappingEnabled=t=>{this.reactiveState.enabled=t,this.manager.emitPluginEvent("snappingEnabledChanged",{enabled:t})},this.manager.getSnappingConfig=()=>({snapStep:this.reactiveState.snapStep,enabled:this.reactiveState.enabled})}destroy(){this.reactiveState.isActive=!1,this.reactiveState.lastPosition=null}};a(L,"_pluginId",Symbol("SnappingPlugin"));let A=L;const R=class R{constructor(t={}){a(this,"dockedContainers",new Map);a(this,"occupiedEdges",new Map);a(this,"tracker",ct({emitter:!0,edgeThreshold:20}));a(this,"manager");a(this,"edgeThreshold");this.edgeThreshold=t.edgeThreshold??30,this.occupiedEdges.set("top",null),this.occupiedEdges.set("bottom",null),this.occupiedEdges.set("left",null),this.occupiedEdges.set("right",null)}get pluginId(){return R._pluginId}install(t){this.manager=t,this.tracker.addTarget(this.manager.getContainer()),this.tracker.on("edge:enter",e=>{e.source==="element"&&e.element===this.manager.getContainer()&&this.handleEdgeEnter(e.edge)}),this.tracker.on("edge:leave",e=>{e.source==="element"&&e.element===this.manager.getContainer()&&this.handleEdgeLeave(e.edge)}),this.attachEventHandlers()}handleEdgeEnter(t){const e=this.manager.getContainer();this.isEdgeOccupied(t)?e.classList.add("edge-dock-hint",`edge-dock-hint-${t}`,"edge-dock-blocked"):e.classList.add("edge-dock-hint",`edge-dock-hint-${t}`)}handleEdgeLeave(t){this.manager.getContainer().classList.remove("edge-dock-hint",`edge-dock-hint-${t}`,"edge-dock-blocked")}isEdgeOccupied(t){return this.occupiedEdges.get(t)!==null}attachEventHandlers(){const t=this.manager.getContainer();t.addEventListener("mouseenter",this.onMouseEnter.bind(this)),t.addEventListener("mouseleave",this.onMouseLeave.bind(this)),this.manager.on("dragStart",e=>{this.onDragStart(e.element)}),this.manager.on("drag",e=>{this.onDrag(e.element)}),this.manager.on("dragEnd",e=>{this.onDragEnd(e.element)})}onMouseEnter(){const t=this.manager.getContainer();this.isContainerDocked(t)&&t.classList.add("edge-docked-visible")}onMouseLeave(){const t=this.manager.getContainer();this.isContainerDocked(t)&&t.classList.remove("edge-docked-visible")}onDragStart(t){t.classList.remove("edge-dock-hint","edge-dock-blocked","edge-docked-visible","edge-dock-hint-top","edge-dock-hint-bottom","edge-dock-hint-left","edge-dock-hint-right");const e=this.dockedContainers.get(t);e&&this.undockContainer(t,e)}onDrag(t){const e=t.getBoundingClientRect(),i=this.getClosestEdge(e);this.updateEdgeHints(t,i)}onDragEnd(t){const e=t.getBoundingClientRect(),i=this.getClosestEdge(e);t.classList.remove("edge-dock-hint","edge-dock-blocked","edge-dock-hint-top","edge-dock-hint-bottom","edge-dock-hint-left","edge-dock-hint-right"),i&&!this.isEdgeOccupied(i)&&this.dockContainer(t,i)}updateEdgeHints(t,e){t.classList.remove("edge-dock-hint","edge-dock-blocked","edge-dock-hint-top","edge-dock-hint-bottom","edge-dock-hint-left","edge-dock-hint-right"),e&&(this.isEdgeOccupied(e)?t.classList.add("edge-dock-hint",`edge-dock-hint-${e}`,"edge-dock-blocked"):t.classList.add("edge-dock-hint",`edge-dock-hint-${e}`))}getClosestEdge(t){const e=t.top,i=t.left,s=window.innerHeight-t.bottom,r=window.innerWidth-t.right,c=Object.entries({top:e,bottom:s,left:i,right:r}).filter(([g,m])=>m>=-this.edgeThreshold&&m<=this.edgeThreshold).sort((g,m)=>g[1]-m[1]);return c.length>0?c[0][0]:null}dockContainer(t,e){const i=window.getComputedStyle(t),s=t.getBoundingClientRect(),r={x:s.left,y:s.top};this.dockedContainers.set(t,{element:t,edge:e,screenPosition:r,originalPosition:{top:parseFloat(i.top)||s.top,left:parseFloat(i.left)||s.left,width:s.width,height:s.height,transform:i.transform,position:i.position}}),this.occupiedEdges.set(e,t),t.style.top="",t.style.bottom="",t.style.left="",t.style.right="",t.style.width="",t.style.height="",t.style.transform="",t.classList.add("edge-docked",`edge-docked-${e}`),this.applyEdgePositioning(t,e,r),t.setAttribute("data-docked","true"),t.setAttribute("data-docked-edge",e)}applyEdgePositioning(t,e,i){const s=t.getBoundingClientRect();switch(e){case"top":t.style.left=`${i.x}px`,t.style.width=`${s.width}px`;break;case"bottom":t.style.left=`${i.x}px`,t.style.width=`${s.width}px`;break;case"left":t.style.top=`${i.y}px`,t.style.height=`${s.height}px`;break;case"right":t.style.top=`${i.y}px`,t.style.height=`${s.height}px`;break}}undockContainer(t,e){this.dockedContainers.delete(t),this.occupiedEdges.set(e.edge,null),t.classList.remove("edge-docked","edge-docked-visible","edge-docked-top","edge-docked-bottom","edge-docked-left","edge-docked-right"),t.removeAttribute("data-docked"),t.removeAttribute("data-docked-edge"),t.style.top="",t.style.bottom="",t.style.left="",t.style.right="",t.style.width="",t.style.height="",t.style.transform="",t.style.position="",this.restoreOriginalPosition(t,e)}restoreOriginalPosition(t,e){this.manager.setState({x:e.screenPosition.x,y:e.screenPosition.y,width:e.originalPosition.width,height:e.originalPosition.height})}getDockedContainer(t){const e=this.occupiedEdges.get(t);return e&&this.dockedContainers.get(e)||null}isContainerDocked(t){return this.dockedContainers.has(t)}getContainerDockEdge(t){const e=this.dockedContainers.get(t);return e?e.edge:null}destroy(){const t=this.manager.getContainer();t.removeEventListener("mouseenter",this.onMouseEnter.bind(this)),t.removeEventListener("mouseleave",this.onMouseLeave.bind(this)),this.dockedContainers.forEach((e,i)=>{this.undockContainer(i,e)}),this.dockedContainers.clear(),this.occupiedEdges.forEach((e,i)=>{this.occupiedEdges.set(i,null)})}};a(R,"_pluginId",Symbol("EdgeDockingPlugin"));let N=R;const n=class n{constructor(){a(this,"manager");a(this,"containerId");a(this,"storable",!0);a(this,"autoSaveEffect")}get pluginId(){return n._pluginId}static get containerStates(){return n.reactiveState.containerStates}static get closedQueue(){return n.reactiveState.closedQueue}static get storableContainers(){return n.reactiveState.storableContainers}install(t,e){if(this.manager=t,this.containerId=e==null?void 0:e.containerId,this.storable=(e==null?void 0:e.storable)??!0,!this.containerId){console.warn("[StatePersistencePlugin] containerId is required for state persistence");return}n.containers.push({manager:t,containerId:this.containerId,storable:this.storable}),this.storable&&n.registerContainer(this.containerId),n.isGlobalEventsInitialized||(n.initializeGlobalEvents(),n.isGlobalEventsInitialized=!0),this.storable&&this.setupAutoSaveEffect(),this.bindContainerEvents()}setupAutoSaveEffect(){if(!this.manager||!this.containerId)return;const t=u.debounce(()=>{this.storable&&this.saveState()},300);this.autoSaveEffect=d.effect(()=>{this.manager.getState(),this.manager.getMode(),t()})}bindContainerEvents(){this.manager&&(this.manager.on("dragStart",()=>{}),this.manager.on("dragEnd",()=>{this.storable&&this.saveState()}),this.manager.on("resizeEnd",()=>{this.storable&&this.saveState()}),this.manager.onPluginEvent("maximizeChanged",()=>{this.storable&&this.saveState()}),this.manager.onPluginEvent("directionChanged",()=>{this.storable&&this.saveState()}))}static initializeGlobalEvents(){window.addEventListener("beforeunload",()=>{n.saveAllContainers()}),document.addEventListener("visibilitychange",()=>{document.hidden&&n.saveAllContainers()}),window.addEventListener("resize",u.debounce(()=>{n.saveAllContainers()},500))}static registerContainer(t){try{n.storableContainers.includes(t)||(n.storableContainers.push(t),n.saveContainersToStorage())}catch(e){console.error("[StatePersistencePlugin] Failed to register container:",e)}}static saveContainersToStorage(){try{localStorage.setItem(n.STORABLE_CONTAINERS_KEY,JSON.stringify(n.storableContainers))}catch(t){console.error("[StatePersistencePlugin] Failed to save containers:",t)}}static getContainers(){try{const t=localStorage.getItem(n.STORABLE_CONTAINERS_KEY);return t?JSON.parse(t):[]}catch(t){return console.error("[StatePersistencePlugin] Failed to parse containers:",t),[]}}static isStorableContainer(t){return n.getContainers().includes(t)}static getAllStates(){try{const t=localStorage.getItem(n.STORAGE_KEY);return t?JSON.parse(t):{}}catch(t){return console.error("[StatePersistencePlugin] Failed to parse stored states:",t),{}}}static addToClosedQueue(t){if(!n.isStorableContainer(t)){console.log(`[StatePersistencePlugin] Skipping closed queue for non-storable container: ${t}`);return}if(!n.getContainerState(t)){console.error(`[StatePersistencePlugin] Cannot add ${t} to closed queue: state not found`);return}const i=n.closedQueue,s=i.indexOf(t);s>-1&&i.splice(s,1),i.push(t),n.saveClosedQueueToStorage()}static saveClosedQueueToStorage(){try{localStorage.setItem(n.CLOSED_QUEUE_KEY,JSON.stringify(n.closedQueue))}catch(t){console.error("[StatePersistencePlugin] Failed to save closed queue:",t)}}static getClosedQueue(){try{const t=localStorage.getItem(n.CLOSED_QUEUE_KEY);return t?JSON.parse(t):[]}catch(t){return console.error("[StatePersistencePlugin] Failed to parse closed queue:",t),[]}}saveState(){!this.manager||!this.containerId||!this.storable||d.batch(()=>{var z;n.reactiveState.isSaving=!0,n.reactiveState.pendingChanges=!0;const t=this.manager.getContainer(),e=t.dataset.maximized==="true",i=this.manager.getState(),s=this.manager.getMode(),r=this.manager.getDirection(),o=t.dataset.containerType||"unknown",c=t.dataset.title,g=t.dataset.color,m=t.dataset.useSnapping==="true",y=(z=this.manager.config)==null?void 0:z.resize,w=t.parentElement,M=w&&w!==document.body?w.id||`parent-${this.containerId}`:void 0,C={...i,mode:s,draggingDirection:r,isMaximized:e,containerType:o,title:c,color:g,useSnapping:m,isClosed:!1,parentElementId:M,closedTimestamp:0,resize:y,storable:!0};n.reactiveState.containerStates[this.containerId]=C;const E=n.getAllStates();E[this.containerId]=C,localStorage.setItem(n.STORAGE_KEY,JSON.stringify(E)),n.reactiveState.lastSaved=Date.now(),n.reactiveState.isSaving=!1})}static saveContainerStateBeforeClose(t,e){var V,U,K;if(!n.isStorableContainer(e)){n.containers=n.containers.filter(k=>k.containerId!==e);return}const s=t.getState(),r=t.getMode(),o=t.getContainer(),c=t.getDirection(),g=o.dataset.maximized==="true",m=o.dataset.containerType||"unknown",y=o.dataset.title,w=o.dataset.color,M=o.dataset.useSnapping==="true",C=(V=t.config)==null?void 0:V.resize,E=((U=t.isEdgeDocked)==null?void 0:U.call(t))||!1,z=((K=t.getDockEdge)==null?void 0:K.call(t))||null,T=o.parentElement,gt=T&&T!==document.body?T.id||`parent-${e}`:void 0,j={...s,mode:r,draggingDirection:c,isMaximized:g,isEdgeDocked:E,dockEdge:z||void 0,containerType:m,title:y,color:w,useSnapping:M,isClosed:!0,parentElementId:gt,closedTimestamp:Date.now(),resize:C,storable:!0},G=n.getAllStates();G[e]=j;try{localStorage.setItem(n.STORAGE_KEY,JSON.stringify(G))}catch(k){console.error("[StatePersistencePlugin] Failed to save to localStorage:",k)}n.reactiveState.containerStates[e]=j,n.containers=n.containers.filter(k=>k.containerId!==e),n.addToClosedQueue(e)}static saveAllContainers(){d.batch(()=>{const t=n.getAllStates();n.containers.filter(e=>!("storable"in e&&e.storable===!1)).forEach(({manager:e,containerId:i})=>{var T;const s=e.getState(),r=e.getMode(),o=e.getContainer(),c=e.getDirection(),g=o.dataset.maximized==="true",m=o.dataset.containerType||"unknown",y=o.dataset.title,w=o.dataset.color,M=o.dataset.useSnapping==="true",C=(T=e.config)==null?void 0:T.resize,E=o.parentElement,z=E&&E!==document.body?E.id||`parent-${i}`:void 0;t[i]={...s,mode:r,draggingDirection:c,isMaximized:g,containerType:m,title:y,color:w,useSnapping:M,isClosed:!1,parentElementId:z,closedTimestamp:0,resize:C,storable:!0}}),n.reactiveState.containerStates=t,localStorage.setItem(n.STORAGE_KEY,JSON.stringify(t)),n.reactiveState.lastSaved=Date.now()})}static popLastClosedContainer(){try{const t=n.closedQueue;if(t.length===0)return null;const e=t.pop();return n.saveClosedQueueToStorage(),e}catch(t){return console.error("[StatePersistencePlugin] Failed to pop last closed container:",t),null}}static hasClosedContainers(){return n.closedQueue.length>0}static getContainerState(t){try{const e=n.containerStates[t];if(e)return e;const s=n.getAllStates()[t];return s?(n.reactiveState.containerStates[t]=s,s):null}catch(e){return console.error("[StatePersistencePlugin] Failed to get container state:",e),null}}static getAllContainerStates(){return n.getAllStates()}static hasContainerState(t){return n.getContainerState(t)!==null}static updateContainerState(t,e){try{const i=n.getAllStates(),s=i[t];if(s){const r={...s,...e};i[t]=r,localStorage.setItem(n.STORAGE_KEY,JSON.stringify(i)),n.reactiveState.containerStates[t]=r}else{console.warn(`[StatePersistencePlugin] No state found for container ${t}, creating new state`);const r={x:0,y:0,width:300,height:200,mode:"smooth",draggingDirection:"all",isMaximized:!1,containerType:"unknown",isClosed:!1,storable:n.isStorableContainer(t),...e};i[t]=r,localStorage.setItem(n.STORAGE_KEY,JSON.stringify(i)),n.reactiveState.containerStates[t]=r}}catch(i){console.error("[StatePersistencePlugin] Failed to update container state:",i)}}static clearStorage(){d.batch(()=>{n.reactiveState.containerStates={},n.closedQueue.length=0,n.storableContainers.length=0,n.reactiveState.isSaving=!1,n.reactiveState.lastSaved=null,n.reactiveState.pendingChanges=!1}),localStorage.removeItem(n.STORAGE_KEY),localStorage.removeItem(n.CLOSED_QUEUE_KEY),localStorage.removeItem(n.STORABLE_CONTAINERS_KEY),n.containers=[]}static initializeReactiveState(){try{const t=n.getAllStates(),e=n.getClosedQueue(),i=n.getContainers();d.batch(()=>{n.reactiveState.containerStates=t,n.closedQueue.length=0,n.closedQueue.push(...e),n.storableContainers.length=0,n.storableContainers.push(...i)})}catch(t){console.error("[StatePersistencePlugin] Failed to initialize reactive state:",t)}}static getMetrics(){return{totalContainers:Object.keys(n.containerStates).length,demoContainers:n.storableContainers.length,closedContainers:n.closedQueue.length,lastSaved:n.reactiveState.lastSaved,isSaving:n.reactiveState.isSaving}}static debugStorage(){console.log("[StatePersistencePlugin] === START DEBUG INFO ===");try{const t=localStorage.getItem(n.STORAGE_KEY);if(t){const s=JSON.parse(t);console.log(`[StatePersistencePlugin] Number of states: ${Object.keys(s).length}`),console.log("[StatePersistencePlugin] State keys:",Object.keys(s));for(const[r,o]of Object.entries(s))console.log(`[StatePersistencePlugin] State ${r}:`,{storable:o.storable,isClosed:o.isClosed,title:o.title})}const e=localStorage.getItem(n.CLOSED_QUEUE_KEY);console.log("[StatePersistencePlugin] Closed queue:",e?JSON.parse(e):[]);const i=localStorage.getItem(n.STORABLE_CONTAINERS_KEY);console.log("[StatePersistencePlugin] Storable containers:",i?JSON.parse(i):[])}catch(t){console.error("[StatePersistencePlugin] Debug error:",t)}console.log("[StatePersistencePlugin] === END DEBUG INFO ===")}destroy(){this.autoSaveEffect&&(this.autoSaveEffect(),this.autoSaveEffect=void 0),this.containerId&&(n.containers=n.containers.filter(t=>t.containerId!==this.containerId))}};a(n,"_pluginId",Symbol("StatePersistencePlugin")),a(n,"STORAGE_KEY","containerManagerState"),a(n,"CLOSED_QUEUE_KEY","containerManagerClosedQueue"),a(n,"STORABLE_CONTAINERS_KEY","containerManagerStorableContainers"),a(n,"reactiveState",d.reactive({isSaving:!1,lastSaved:null,pendingChanges:!1,containerStates:{},closedQueue:[],storableContainers:[]})),a(n,"isGlobalEventsInitialized",!1),a(n,"containers",[]);let x=n;x.initializeReactiveState();const D=class D{constructor(){a(this,"manager");a(this,"containerName","");a(this,"notificationSystem",null)}get pluginId(){return D._pluginId}install(t,e){this.manager=t,this.containerName=(e==null?void 0:e.containerName)||`Container-${Math.random().toString(36).substring(2,11)}`,this.notificationSystem=e==null?void 0:e.notificationSystem,this.bindEvents()}bindEvents(){this.manager&&(this.logResize=u.debounce(this.logResize.bind(this),250),this.logDrag=u.debounce(this.logDrag.bind(this),250),this.logViewportResize=u.debounce(this.logViewportResize.bind(this),250),this.logSnapStep=u.debounce(this.logSnapStep.bind(this),250),this.manager.on("modeChange",t=>{this.logModeChange(t.mode)}),this.manager.on("resize",t=>{this.logResize(t.state)}),this.manager.on("resizeEnd",t=>{this.logResize(t.state)}),this.manager.on("drag",t=>{this.logDrag(t.state)}),this.manager.on("dragEnd",t=>{this.logDrag(t.state)}),this.manager.on("viewportResize",t=>{this.logViewportResize(t.state)}),this.manager.onPluginEvent("snappingEnabledChanged",t=>{this.logSnappingEnabled(t.enabled)}),this.manager.onPluginEvent("snapStepChanged",t=>{this.logSnapStep(t.snapStep)}),this.manager.onPluginEvent("directionChanged",t=>{this.logDirectionChange(t.direction)}))}logResize(t){const e=`Resized to ${Math.round(t.width)}×${Math.round(t.height)}`;this.showNotification(e,"info")}logDrag(t){const e=`Moved to (${Math.round(t.x)}, ${Math.round(t.y)})`;this.showNotification(e,"info")}logModeChange(t){const e=`Mode changed to ${t}`;this.showNotification(e,"warning")}logViewportResize(t){const e=`Adjusted position to (${Math.round(t.x)}, ${Math.round(t.y)}) due to window resize`;this.showNotification(e,"info")}logSnappingEnabled(t){const e=`Snapping ${t?"enabled":"disabled"}`;this.showNotification(e,t?"success":"warning")}logSnapStep(t){const e=`Snap step changed to ${t}px`;this.showNotification(e,"info")}logDirectionChange(t){const e=`Drag direction: ${t}`;this.showNotification(e,"info")}showNotification(t,e){if(this.notificationSystem){const i=`${this.containerName}: ${t}`;this.notificationSystem.show(i,e)}}};a(D,"_pluginId",Symbol("LoggingPlugin"));let Y=D;const ht=Object.freeze(Object.defineProperty({__proto__:null,default:`<div class="media-content">
|
|
43
42
|
<h4>🎬 Media Gallery</h4>
|
|
44
43
|
<div class="media-grid">
|
|
45
44
|
<div class="media-item" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);">
|
|
@@ -59,7 +58,7 @@
|
|
|
59
58
|
<small>📁 Template: media.html</small>
|
|
60
59
|
</div>
|
|
61
60
|
</div>
|
|
62
|
-
`},Symbol.toStringTag,{value:"Module"})),
|
|
61
|
+
`},Symbol.toStringTag,{value:"Module"})),lt=Object.freeze(Object.defineProperty({__proto__:null,default:`<div class="stats-content">
|
|
63
62
|
<h4>📊 Statistics Panel</h4>
|
|
64
63
|
<div class="stats-grid">
|
|
65
64
|
<div class="stat-card">
|
|
@@ -90,7 +89,7 @@
|
|
|
90
89
|
</div>
|
|
91
90
|
</div>
|
|
92
91
|
<p>This template demonstrates dynamic content structure with CSS styling.</p>
|
|
93
|
-
</div>`},Symbol.toStringTag,{value:"Module"})),
|
|
92
|
+
</div>`},Symbol.toStringTag,{value:"Module"})),dt=Object.freeze(Object.defineProperty({__proto__:null,default:`<div class="tasks-content">
|
|
94
93
|
<h4>✅ Task Manager</h4>
|
|
95
94
|
<div class="task-list">
|
|
96
95
|
<div class="task-item completed">
|
|
@@ -119,5 +118,5 @@
|
|
|
119
118
|
</div>
|
|
120
119
|
</div>
|
|
121
120
|
<p>Template content can include interactive elements and dynamic data.</p>
|
|
122
|
-
</div>`},Symbol.toStringTag,{value:"Module"}));l.ContainerInitializer=
|
|
121
|
+
</div>`},Symbol.toStringTag,{value:"Module"}));l.ContainerInitializer=q,l.ContainerManager=I,l.ContentCreator=J,l.EdgeDockingPlugin=N,l.LoggingPlugin=Y,l.NotificationSystem=B,l.SnappingPlugin=A,l.StatePersistencePlugin=x,l.StatsManager=Z,l.TemplateLoader=O,l.getState=X,l.getTemplateLoader=at,l.initializeTemplateSystem=nt,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
|
123
122
|
//# sourceMappingURL=index.umd.js.map
|