@moonitoring/nidamjs 1.0.0

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.
@@ -0,0 +1,1096 @@
1
+ class x {
2
+ static #t = /* @__PURE__ */ new WeakSet();
3
+ /**
4
+ * Initialize feature modules in a container.
5
+ *
6
+ * @param {Object} delegator - Shared EventDelegator instance.
7
+ * @param {Document|Element} container - Container to scan.
8
+ * @param {Map|null} modules - Shared module registry.
9
+ * @param {Array<{selector:string, init:Function, name?:string}>} registry - Feature definitions.
10
+ */
11
+ static initialize(t, s = document, e = null, i = []) {
12
+ !Array.isArray(i) || i.length === 0 || i.forEach(({ selector: o, init: n, name: a }) => {
13
+ if (!o || typeof n != "function")
14
+ return;
15
+ s.querySelectorAll(o).forEach((d) => {
16
+ if (!this.#t.has(d))
17
+ try {
18
+ const c = n(d, t, e);
19
+ this.#t.add(d), a && c && e && typeof e.set == "function" && e.set(a, c);
20
+ } catch (c) {
21
+ console.warn(`Failed to initialize ${o}:`, c);
22
+ }
23
+ });
24
+ });
25
+ }
26
+ }
27
+ class b {
28
+ #t = /* @__PURE__ */ new Map();
29
+ #s;
30
+ #e = /* @__PURE__ */ new Map();
31
+ constructor(t = document) {
32
+ this.#s = t, this.#i();
33
+ }
34
+ #i() {
35
+ [
36
+ "click",
37
+ "input",
38
+ "change",
39
+ "focusin",
40
+ "focusout",
41
+ "keydown",
42
+ "mousedown",
43
+ "desktop:toggle-matrix",
44
+ "desktop:theme-changed"
45
+ ].forEach((s) => {
46
+ const e = (i) => this.#o(s, i);
47
+ this.#s.addEventListener(s, e), this.#e.set(s, e);
48
+ });
49
+ }
50
+ #o(t, s) {
51
+ const e = this.#t.get(t);
52
+ if (!(!e || e.length === 0))
53
+ for (const { selector: i, handler: o } of e) {
54
+ if (!i) {
55
+ o.call(this.#s, s, this.#s);
56
+ continue;
57
+ }
58
+ const n = s.target.closest(i);
59
+ n && o.call(n, s, n);
60
+ }
61
+ }
62
+ /**
63
+ * Register an event handler.
64
+ * @param {string} eventType
65
+ * @param {string|null} selector
66
+ * @param {(e: Event, target: Element|Document) => void} handler
67
+ * @param {{group?: string}} [options]
68
+ */
69
+ on(t, s, e, i = {}) {
70
+ const o = i.group;
71
+ this.#t.has(t) || this.#t.set(t, []);
72
+ const n = { selector: s, handler: e, group: o };
73
+ return this.#t.get(t).push(n), n;
74
+ }
75
+ off(t, s) {
76
+ const e = this.#t.get(t);
77
+ if (!e) return;
78
+ const i = e.indexOf(s);
79
+ i !== -1 && e.splice(i, 1), e.length || this.#t.delete(t);
80
+ }
81
+ destroy() {
82
+ for (const [t, s] of this.#e)
83
+ this.#s.removeEventListener(t, s);
84
+ this.#e.clear(), this.#t.clear();
85
+ }
86
+ }
87
+ const R = {
88
+ /**
89
+ * Move text cursor to the end of an editable element
90
+ * @param {HTMLElement} element - Target element
91
+ */
92
+ moveCursorToEnd(r) {
93
+ const t = document.createRange();
94
+ t.selectNodeContents(r), t.collapse(!1);
95
+ const s = window.getSelection();
96
+ s.removeAllRanges(), s.addRange(t);
97
+ },
98
+ /**
99
+ * Register a callback for ESC key press
100
+ * Automatically removes listener after first trigger
101
+ * @param {Function} callback - Function to call on ESC press
102
+ * @returns {Function} Handler function for manual removal
103
+ */
104
+ onEscape(r) {
105
+ const t = (s) => {
106
+ s.key === "Escape" && (r(), document.removeEventListener("keydown", t));
107
+ };
108
+ return document.addEventListener("keydown", t), t;
109
+ },
110
+ /**
111
+ * Hide elements by adding 'hidden' class
112
+ * @param {...HTMLElement} elements - Elements to hide
113
+ */
114
+ hide(...r) {
115
+ r.forEach((t) => t?.classList.add("hidden"));
116
+ },
117
+ /**
118
+ * Show elements by removing 'hidden' class
119
+ * @param {...HTMLElement} elements - Elements to show
120
+ */
121
+ show(...r) {
122
+ r.forEach((t) => t?.classList.remove("hidden"));
123
+ },
124
+ /**
125
+ * Toggle visibility of elements
126
+ * @param {...HTMLElement} elements - Elements to toggle
127
+ */
128
+ toggle(...r) {
129
+ r.forEach((t) => t?.classList.toggle("hidden"));
130
+ }
131
+ };
132
+ class z {
133
+ _root;
134
+ _elements = {};
135
+ _state = {};
136
+ _utils = R;
137
+ _delegator = null;
138
+ /**
139
+ * @param {HTMLElement|string} root - Root element or selector
140
+ * @param {EventDelegator} delegator - Global event delegator instance
141
+ */
142
+ constructor(t, s) {
143
+ if (this._root = typeof t == "string" ? document.querySelector(t) : t, this._delegator = s, !this._root)
144
+ throw new Error(`Root element not found: ${t}`);
145
+ this._initialize();
146
+ }
147
+ /**
148
+ * Initialize the manager (called automatically)
149
+ * @private
150
+ */
151
+ _initialize() {
152
+ this._elements = this._cacheElements(), this._bindEvents();
153
+ }
154
+ /**
155
+ * Cache DOM elements needed by this manager
156
+ * Override in child classes
157
+ * @returns {Object} Object containing DOM element references
158
+ * @protected
159
+ */
160
+ _cacheElements() {
161
+ return {};
162
+ }
163
+ /**
164
+ * Bind event listeners
165
+ * Override in child classes
166
+ * @protected
167
+ */
168
+ _bindEvents() {
169
+ }
170
+ /**
171
+ * Query a single element within the root
172
+ * @param {string} selector - CSS selector
173
+ * @returns {HTMLElement|null}
174
+ * @protected
175
+ */
176
+ _query(t) {
177
+ return this._root.querySelector(t);
178
+ }
179
+ /**
180
+ * Query multiple elements within the root
181
+ * @param {string} selector - CSS selector
182
+ * @returns {NodeList}
183
+ * @protected
184
+ */
185
+ _queryAll(t) {
186
+ return this._root.querySelectorAll(t);
187
+ }
188
+ /**
189
+ * Register scoped event handler
190
+ * @param {string} eventType
191
+ * @param {string} selector
192
+ * @param {Function} handler
193
+ * @protected
194
+ */
195
+ _on(t, s, e) {
196
+ this._delegator.on(t, s, (i, o) => {
197
+ this._root.contains(o) && e.call(this, i, o);
198
+ });
199
+ }
200
+ }
201
+ const W = /* @__PURE__ */ new WeakMap();
202
+ function u(r) {
203
+ return !r || r === "auto" || r === "normal" ? "" : r;
204
+ }
205
+ function w(r) {
206
+ return Number.isFinite(r) ? `${Math.round(r)}px` : "";
207
+ }
208
+ function T(r, t = {}) {
209
+ const s = t.includePosition === !0;
210
+ let e = null;
211
+ const i = () => (e || (e = window.getComputedStyle(r)), e), o = (r.offsetWidth > 0 ? w(r.offsetWidth) : "") || u(r.style.width) || u(i().width), n = (r.offsetHeight > 0 ? w(r.offsetHeight) : "") || u(r.style.height) || u(i().height);
212
+ let a = "", l = "";
213
+ return s && (a = w(r.offsetLeft) || u(r.style.left) || u(i().left), l = w(r.offsetTop) || u(r.style.top) || u(i().top)), {
214
+ width: o || "",
215
+ height: n || "",
216
+ left: a,
217
+ top: l
218
+ };
219
+ }
220
+ function y(r) {
221
+ let t = W.get(r);
222
+ return t || (t = /* @__PURE__ */ new Map(), W.set(r, t)), t;
223
+ }
224
+ function C(r, t = "prevState", s = {}) {
225
+ const e = T(r, s), i = JSON.stringify(e);
226
+ return r.dataset[t] = i, y(r).set(t, { raw: i, parsed: e }), e;
227
+ }
228
+ function v(r, t = "prevState") {
229
+ const s = r.dataset[t];
230
+ if (!s) return null;
231
+ const e = y(r).get(t);
232
+ if (e && e.raw === s)
233
+ return e.parsed;
234
+ try {
235
+ const i = JSON.parse(s);
236
+ if (!i || typeof i != "object")
237
+ return y(r).set(t, { raw: s, parsed: null }), null;
238
+ const o = {
239
+ width: u(i.width),
240
+ height: u(i.height),
241
+ left: u(i.left),
242
+ top: u(i.top)
243
+ };
244
+ return y(r).set(t, { raw: s, parsed: o }), o;
245
+ } catch {
246
+ return y(r).set(t, { raw: s, parsed: null }), null;
247
+ }
248
+ }
249
+ function L(r, t, s = {}) {
250
+ return !t || typeof t != "object" ? !1 : (t.width && r.style.width !== t.width && (r.style.width = t.width), t.height && r.style.height !== t.height && (r.style.height = t.height), s.includePosition && (t.left && r.style.left !== t.left && (r.style.left = t.left), t.top && r.style.top !== t.top && (r.style.top = t.top)), !0);
251
+ }
252
+ class D extends z {
253
+ // Configuration
254
+ _config = {
255
+ zIndexBase: 40,
256
+ layoutStabilizationMs: 450,
257
+ cascadeOffset: 30,
258
+ cooldownMs: 500,
259
+ maxWindows: 10,
260
+ snapGap: 6,
261
+ taskbarHeight: 64,
262
+ snapThreshold: 30,
263
+ dragThreshold: 10,
264
+ resizeDebounceMs: 6,
265
+ animationDurationMs: 400,
266
+ defaultWidth: 800,
267
+ defaultHeight: 600,
268
+ minMargin: 10,
269
+ edgeDetectionRatio: 0.4,
270
+ scrollRestoreTimeoutMs: 2e3
271
+ };
272
+ _windows = /* @__PURE__ */ new Map();
273
+ _zIndexCounter = this._config.zIndexBase;
274
+ _getModules = null;
275
+ _notify = null;
276
+ _fetchWindowContent = null;
277
+ _initializeContent = null;
278
+ _resolveEndpoint = null;
279
+ _lastOpenTimestamps = /* @__PURE__ */ new Map();
280
+ _pendingRequests = /* @__PURE__ */ new Map();
281
+ // Tiling & Snapping properties
282
+ _snapIndicator = null;
283
+ constructor(t, s, e = {}) {
284
+ super(t, s);
285
+ const {
286
+ getModules: i = null,
287
+ config: o = null,
288
+ notify: n = null,
289
+ fetchWindowContent: a = null,
290
+ initializeContent: l = null,
291
+ resolveEndpoint: d = null
292
+ } = e || {};
293
+ this._getModules = i, this._notify = n || this._defaultNotify.bind(this), this._fetchWindowContent = a || this._defaultFetchWindowContent.bind(this), this._initializeContent = l || (() => {
294
+ }), this._resolveEndpoint = d || this._defaultResolveEndpoint, o && typeof o == "object" && (this._config = { ...this._config, ...o }), this._zIndexCounter = this._config.zIndexBase, this._initSnapIndicator();
295
+ }
296
+ // Create the visual indicator for window snapping
297
+ _initSnapIndicator() {
298
+ this._snapIndicator = document.createElement("div"), this._snapIndicator.className = "snap-indicator", document.body.appendChild(this._snapIndicator);
299
+ }
300
+ _cacheElements() {
301
+ return {};
302
+ }
303
+ _bindEvents() {
304
+ this._delegator.on(
305
+ "click",
306
+ "[data-modal]",
307
+ this._handleModalTrigger.bind(this)
308
+ ), this._delegator.on(
309
+ "click",
310
+ "[data-maximize]",
311
+ this._handleMaximizeTrigger.bind(this)
312
+ ), this._delegator.on(
313
+ "click",
314
+ "[data-close]",
315
+ this._handleCloseTrigger.bind(this)
316
+ ), this._delegator.on(
317
+ "mousedown",
318
+ ".window",
319
+ this._handleWindowFocus.bind(this)
320
+ ), this._delegator.on(
321
+ "mousedown",
322
+ "[data-bar]",
323
+ this._handleWindowDragStart.bind(this)
324
+ ), document.addEventListener("keydown", this._handleGlobalKeydown.bind(this));
325
+ let t;
326
+ window.addEventListener("resize", () => {
327
+ clearTimeout(t), t = setTimeout(
328
+ () => this._handleResize(),
329
+ this._config.resizeDebounceMs
330
+ );
331
+ });
332
+ }
333
+ // Event Handlers
334
+ _handleModalTrigger(t, s) {
335
+ t.preventDefault(), this.open(s.dataset.modal).catch((e) => {
336
+ console.debug("Modal trigger failed:", e);
337
+ });
338
+ }
339
+ _handleCloseTrigger(t, s) {
340
+ t.preventDefault();
341
+ const e = s.closest(".window");
342
+ e && this.close(e);
343
+ }
344
+ _handleWindowFocus(t, s) {
345
+ if (t.target.closest("[data-close]") || t.target.closest("[data-modal]"))
346
+ return;
347
+ const e = s.closest(".window");
348
+ e && this._focusWindow(e);
349
+ }
350
+ _handleMaximizeTrigger(t, s) {
351
+ t.preventDefault();
352
+ const e = s.closest(".window");
353
+ e && this.toggleMaximize(e);
354
+ }
355
+ _handleWindowDragStart(t, s) {
356
+ if (t.target.closest("[data-close]") || t.target.closest("[data-maximize]"))
357
+ return;
358
+ t.preventDefault();
359
+ const e = s.closest(".window");
360
+ e && (this._focusWindow(e), this.drag(t, e));
361
+ }
362
+ _handleGlobalKeydown(t) {
363
+ t.key === "Escape" && !t.repeat && this._closeTopmostWindow();
364
+ }
365
+ // Public Methods
366
+ // Toggle between maximized and normal state
367
+ toggleMaximize(t) {
368
+ const s = t.classList.contains("maximized"), e = t.classList.contains("tiled") && typeof t.dataset.snapType == "string" && t.dataset.snapType.length > 0;
369
+ t.classList.add("window-toggling"), !s && !t.classList.contains("tiled") && this._ensureRestoreState(t);
370
+ const i = t.classList.toggle("maximized");
371
+ let o = !1;
372
+ if (this._updateMaximizeIcon(t, i), !i)
373
+ if (e) {
374
+ const n = this._getSnapLayout(
375
+ t.dataset.snapType,
376
+ window.innerWidth,
377
+ window.innerHeight - this._config.taskbarHeight
378
+ );
379
+ Object.assign(t.style, n);
380
+ } else {
381
+ const n = v(t);
382
+ L(t, n);
383
+ const a = this._parseCssPixelValue(n?.width) || this._parseCssPixelValue(t.style.width) || t.offsetWidth, l = this._parseCssPixelValue(n?.height) || this._parseCssPixelValue(t.style.height) || t.offsetHeight;
384
+ this._repositionWindowFromRatios(
385
+ t,
386
+ window.innerWidth,
387
+ window.innerHeight,
388
+ {
389
+ widthPx: a,
390
+ heightPx: l
391
+ }
392
+ ), o = !0;
393
+ }
394
+ setTimeout(() => {
395
+ t.classList.remove("window-toggling"), o && this._savePositionRatios(t);
396
+ }, this._config.animationDurationMs);
397
+ }
398
+ // Open a window by its endpoint
399
+ async open(t, s = !1, e = null, i = !0) {
400
+ if (this._windows.size >= this._config.maxWindows && !this._windows.has(t)) {
401
+ const a = document.body.dataset.errorMaxWindows || `Maximum of ${this._config.maxWindows} windows allowed.`;
402
+ return this._notify("error", a.replace("%s", String(this._config.maxWindows))), Promise.reject(new Error("Max windows reached"));
403
+ }
404
+ if (this._windows.has(t) && !s) {
405
+ const a = this._windows.get(t);
406
+ return i && this._focusWindow(a), Promise.resolve(a);
407
+ }
408
+ if (this._pendingRequests.has(t))
409
+ return this._pendingRequests.get(t);
410
+ const o = Date.now();
411
+ if (!s && o - (this._lastOpenTimestamps.get(t) || 0) < this._config.cooldownMs)
412
+ return Promise.resolve();
413
+ this._lastOpenTimestamps.set(t, o);
414
+ const n = (async () => {
415
+ try {
416
+ const a = await this._fetchWindowContent(t, {
417
+ force: s,
418
+ focusSelector: e,
419
+ activate: i,
420
+ manager: this
421
+ });
422
+ if (typeof a != "string")
423
+ throw new TypeError("fetchWindowContent must return an HTML string");
424
+ if (this._windows.has(t) && s) {
425
+ const d = this._windows.get(t);
426
+ return !i && this._isWindowBusy(d) || (this._refreshWindowContent(d, a), i && this._focusWindow(d), e && this._handleFocusSelector(d, e)), d;
427
+ }
428
+ const l = this._createWindowElement(a, t);
429
+ if (!l) {
430
+ console.warn(`No .window element found for ${t}`);
431
+ return;
432
+ }
433
+ return this._setupNewWindow(l, t, e, i), l;
434
+ } catch (a) {
435
+ console.error("Error opening window:", a);
436
+ const l = document.body.dataset.errorOpenFailed || "Failed to open window.";
437
+ throw this._notify("error", l), a;
438
+ } finally {
439
+ this._pendingRequests.delete(t);
440
+ }
441
+ })();
442
+ return this._pendingRequests.set(t, n), n;
443
+ }
444
+ // Close a window
445
+ close(t) {
446
+ const s = t.dataset.endpoint;
447
+ this._windows.get(s) === t && this._windows.delete(s), t.classList.add("animate-disappearance"), t.classList.remove("animate-appearance"), t.addEventListener(
448
+ "animationend",
449
+ () => {
450
+ t.isConnected && t.remove();
451
+ },
452
+ { once: !0 }
453
+ );
454
+ }
455
+ // Internal Logic
456
+ // Focus a window and bring it to top
457
+ _focusWindow(t) {
458
+ this._zIndexCounter++, t.style.zIndex = this._zIndexCounter, t.classList.add("focused"), this._windows.forEach((s) => {
459
+ s !== t && s.classList.remove("focused");
460
+ });
461
+ }
462
+ _isWindowBusy(t) {
463
+ return t.dataset.isBusy === "true" ? !0 : t.querySelector('[data-is-busy="true"]') !== null;
464
+ }
465
+ _refreshWindowContent(t, s) {
466
+ const o = (
467
+ /** @type {HTMLElement|null} */
468
+ new DOMParser().parseFromString(s, "text/html").querySelector(".window")
469
+ );
470
+ if (!o) return;
471
+ const n = t.dataset.snapType, a = t.dataset.prevState, l = t.dataset.xRatio, d = t.dataset.yRatio, c = t.classList.contains("focused"), h = t.classList.contains("maximized"), f = t.classList.contains("tiled"), g = this._captureScrollState(t);
472
+ t.innerHTML = o.innerHTML, t.className = o.className, n && (t.dataset.snapType = n), a && (t.dataset.prevState = a), l && (t.dataset.xRatio = l), d && (t.dataset.yRatio = d), c && t.classList.add("focused"), f && t.classList.add("tiled"), h && (t.classList.add("maximized"), this._updateMaximizeIcon(t, !0)), !f && !h && (o.style.width && (t.style.width = o.style.width), o.style.height && (t.style.height = o.style.height)), t.style.margin = "0", t.style.transform = "none", this._restoreScrollState(t, g), this._initializeModalContent(t);
473
+ }
474
+ _updateMaximizeIcon(t, s) {
475
+ const e = t.querySelector("[data-maximize] i");
476
+ e && (e.classList.toggle("fa-expand", !s), e.classList.toggle("fa-compress", s));
477
+ }
478
+ _createWindowElement(t, s) {
479
+ const o = (
480
+ /** @type {HTMLElement|null} */
481
+ new DOMParser().parseFromString(t, "text/html").querySelector(".window")
482
+ );
483
+ return o && (o.dataset.endpoint = s), o;
484
+ }
485
+ _setupNewWindow(t, s, e, i = !0) {
486
+ Object.assign(t.style, {
487
+ position: "absolute",
488
+ pointerEvents: "auto",
489
+ margin: "0",
490
+ transform: "none",
491
+ visibility: "hidden"
492
+ }), this._root.appendChild(t);
493
+ const o = this._windows.size, n = t.dataset.defaultSnap;
494
+ if (n) {
495
+ const a = window.innerWidth, l = window.innerHeight - this._config.taskbarHeight;
496
+ this._snapWindow(t, n, a, l);
497
+ } else
498
+ this._positionWindow(t, o), this._ensureRestoreState(t);
499
+ this._windows.set(s, t), this._initializeModalContent(t), i && this._focusWindow(t), t.style.visibility = "", n || this._stabilizeInitialPlacement(t, o), e && this._handleFocusSelector(t, e);
500
+ }
501
+ _positionWindow(t, s = null) {
502
+ const e = t.offsetWidth || parseInt(t.style.width) || this._config.defaultWidth, i = t.offsetHeight || parseInt(t.style.height) || this._config.defaultHeight, o = window.innerWidth, n = window.innerHeight, a = Number.isFinite(s) && s >= 0 ? s : this._windows.size, l = a * this._config.cascadeOffset, d = a * this._config.cascadeOffset;
503
+ let c = (o - e) / 2 + l, h = (n - i) / 2 + d;
504
+ const f = this._config.minMargin;
505
+ c + e > o && (c = Math.max(f, o - e - f)), h + i > n && (h = Math.max(f, n - i - f)), t.style.left = `${Math.round(c)}px`, t.style.top = `${Math.round(h)}px`, this._savePositionRatios(t);
506
+ }
507
+ _stabilizeInitialPlacement(t, s) {
508
+ if (!t?.isConnected) return;
509
+ const e = Number.isFinite(this._config.layoutStabilizationMs) && this._config.layoutStabilizationMs > 0 ? this._config.layoutStabilizationMs : 450, i = typeof performance < "u" ? () => performance.now() : () => Date.now(), o = i();
510
+ let n = !0, a = null, l = t.offsetWidth, d = t.offsetHeight;
511
+ const c = () => {
512
+ n && (n = !1, a && (a.disconnect(), a = null));
513
+ }, h = () => {
514
+ if (!n || !t.isConnected) {
515
+ c();
516
+ return;
517
+ }
518
+ if (t.classList.contains("tiled") || t.classList.contains("maximized"))
519
+ return;
520
+ const g = t.offsetWidth, _ = t.offsetHeight;
521
+ (g !== l || _ !== d) && (l = g, d = _, this._positionWindow(t, s));
522
+ }, f = () => {
523
+ if (n) {
524
+ if (h(), i() - o < e) {
525
+ requestAnimationFrame(f);
526
+ return;
527
+ }
528
+ c();
529
+ }
530
+ };
531
+ requestAnimationFrame(f), typeof ResizeObserver == "function" && (a = new ResizeObserver(() => h()), a.observe(t)), setTimeout(() => c(), e);
532
+ }
533
+ // Save relative position ratios (Center-based)
534
+ _savePositionRatios(t) {
535
+ if (t.classList.contains("tiled") || t.classList.contains("maximized"))
536
+ return;
537
+ const s = t.offsetLeft + t.offsetWidth / 2, e = t.offsetTop + t.offsetHeight / 2;
538
+ t.dataset.xRatio = String(s / window.innerWidth), t.dataset.yRatio = String(e / window.innerHeight);
539
+ }
540
+ _ensureRestoreState(t) {
541
+ const s = v(t);
542
+ return s?.width && s?.height ? s : C(t, "prevState", { includePosition: !1 });
543
+ }
544
+ _parseCssPixelValue(t) {
545
+ if (!t) return null;
546
+ const s = parseFloat(t);
547
+ return Number.isFinite(s) ? s : null;
548
+ }
549
+ _repositionWindowFromRatios(t, s, e, i = null) {
550
+ const o = parseFloat(t.dataset.xRatio), n = parseFloat(t.dataset.yRatio);
551
+ if (isNaN(o) || isNaN(n)) return !1;
552
+ const a = (i && Number.isFinite(i.widthPx) && i.widthPx > 0 ? i.widthPx : null) || t.offsetWidth, l = (i && Number.isFinite(i.heightPx) && i.heightPx > 0 ? i.heightPx : null) || t.offsetHeight, d = o * s, c = n * e;
553
+ return t.style.left = `${Math.round(d - a / 2)}px`, t.style.top = `${Math.round(c - l / 2)}px`, !0;
554
+ }
555
+ _handleFocusSelector(t, s) {
556
+ const e = t.querySelector(s);
557
+ e && ((e.type === "radio" || e.type === "checkbox") && (e.checked = !0), e.focus());
558
+ }
559
+ _closeTopmostWindow() {
560
+ let t = null, s = 0;
561
+ this._windows.forEach((e) => {
562
+ if (e.classList.contains("animate-disappearance")) return;
563
+ const i = parseInt(e.style.zIndex || 0, 10);
564
+ i > s && (s = i, t = e);
565
+ }), t && this.close(t);
566
+ }
567
+ // Drag & Tiling Methods
568
+ drag(t, s) {
569
+ this._dragState?.active || (this._dragState = {
570
+ active: !0,
571
+ winElement: s,
572
+ startX: t.clientX,
573
+ startY: t.clientY,
574
+ currentX: t.clientX,
575
+ currentY: t.clientY,
576
+ startWinLeft: s.offsetLeft,
577
+ startWinTop: s.offsetTop,
578
+ isRestored: !1,
579
+ restoreXRatio: null,
580
+ initialState: {
581
+ tiled: s.classList.contains("tiled"),
582
+ maximized: s.classList.contains("maximized")
583
+ },
584
+ view: {
585
+ w: window.innerWidth,
586
+ h: window.innerHeight - this._config.taskbarHeight
587
+ },
588
+ snap: null,
589
+ inhibitSnap: !1,
590
+ isDragging: !1
591
+ }, this._dragHandlers = {
592
+ move: (e) => {
593
+ this._dragState.currentX = e.clientX, this._dragState.currentY = e.clientY;
594
+ },
595
+ stop: () => this._handleDragStop()
596
+ }, document.addEventListener("mousemove", this._dragHandlers.move, {
597
+ passive: !0
598
+ }), document.addEventListener("mouseup", this._dragHandlers.stop), requestAnimationFrame(() => this._dragLoop()));
599
+ }
600
+ _dragLoop() {
601
+ this._dragState?.active && (this._updateDragPosition(), requestAnimationFrame(() => this._dragLoop()));
602
+ }
603
+ _updateDragPosition() {
604
+ const t = this._dragState, { winElement: s, currentX: e, currentY: i, startX: o, startY: n } = t, a = e - o, l = i - n;
605
+ if (!t.isDragging && (Math.abs(a) > this._config.dragThreshold || Math.abs(l) > this._config.dragThreshold) && (t.isDragging = !0), !t.isDragging) return;
606
+ (t.initialState.tiled || t.initialState.maximized) && !t.isRestored && t.isDragging && (t.initialState.maximized ? (t.restoreXRatio = o / window.innerWidth, this._restoreWindowInternal(s, t.restoreXRatio), t.startWinTop = 0) : (t.restoreXRatio = (o - s.offsetLeft) / s.offsetWidth, this._restoreWindowInternal(s, null), t.startWinTop = s.offsetTop), t.startX = e, t.startY = i, t.isRestored = !0);
607
+ let d, c;
608
+ if (t.isRestored && t.restoreXRatio !== null) {
609
+ const h = s.offsetWidth;
610
+ d = e - t.restoreXRatio * h, c = Math.max(0, t.startWinTop + (i - n));
611
+ } else
612
+ d = t.startWinLeft + (t.isRestored ? e - t.startX : a), c = Math.max(
613
+ 0,
614
+ t.startWinTop + (t.isRestored ? i - t.startY : l)
615
+ );
616
+ s.style.left = `${d}px`, s.style.top = `${c}px`, (t.isRestored || !t.initialState.tiled && !t.initialState.maximized) && (s.classList.contains("tiled") && s.classList.remove("tiled"), s.classList.contains("maximized") && (s.classList.remove("maximized"), this._updateMaximizeIcon(s, !1))), t.isDragging && this._detectSnapZone(e, i);
617
+ }
618
+ _detectSnapZone(t, s) {
619
+ const { view: e } = this._dragState, i = this._config.snapThreshold, o = e.w * this._config.edgeDetectionRatio, n = e.h * this._config.edgeDetectionRatio;
620
+ let a = null;
621
+ s < i ? t < o ? a = "tl" : t > e.w - o ? a = "tr" : a = "maximize" : t < i ? s < n ? a = "tl" : s > e.h - n ? a = "bl" : a = "left" : t > e.w - i ? s < n ? a = "tr" : s > e.h - n ? a = "br" : a = "right" : s > e.h - i && (a = t < e.w / 2 ? "bl" : "br"), this._dragState.snap !== a && (this._dragState.snap = a, this._updateSnapIndicator(a, e.w, e.h));
622
+ }
623
+ _handleDragStop() {
624
+ if (!this._dragState?.active) return;
625
+ const { winElement: t, snap: s, view: e } = this._dragState;
626
+ document.removeEventListener("mousemove", this._dragHandlers.move), document.removeEventListener("mouseup", this._dragHandlers.stop), this._snapIndicator.classList.remove("visible"), s ? s === "maximize" ? this.toggleMaximize(t) : this._snapWindow(t, s, e.w, e.h) : this._savePositionRatios(t), this._dragState.active = !1, this._dragState = null, this._dragHandlers = null;
627
+ }
628
+ // Unified Restore Logic
629
+ _restoreWindowInternal(t, s) {
630
+ let e, i;
631
+ const o = v(t);
632
+ s === null ? o && (e = o.width, i = o.height) : (e = o?.width || t.style.width, i = o?.height || t.style.height), (!e || e === "100%") && (e = this._config.defaultWidth + "px"), (!i || i === "100%") && (i = this._config.defaultHeight + "px"), t.classList.remove("maximized", "tiled"), this._updateMaximizeIcon(t, !1), t.classList.add("window-toggling", "dragging-restore"), L(t, { width: e, height: i }), setTimeout(() => {
633
+ t.classList.remove("window-toggling", "dragging-restore"), this._savePositionRatios(t);
634
+ }, this._config.animationDurationMs);
635
+ }
636
+ // Update snap indicator visibility and position
637
+ _updateSnapIndicator(t, s, e) {
638
+ if (!t) {
639
+ this._snapIndicator.classList.remove("visible");
640
+ return;
641
+ }
642
+ let i;
643
+ t === "maximize" ? i = {
644
+ top: "0px",
645
+ left: "0px",
646
+ width: `${s}px`,
647
+ height: `${e}px`
648
+ } : i = this._getSnapLayout(t, s, e), Object.assign(this._snapIndicator.style, i), this._snapIndicator.classList.add("visible");
649
+ }
650
+ // Snap window to a specific quadrant
651
+ _snapWindow(t, s, e, i) {
652
+ t.classList.contains("tiled") || this._ensureRestoreState(t), t.classList.add("window-toggling", "tiled"), t.dataset.snapType = s;
653
+ const o = this._getSnapLayout(s, e, i);
654
+ Object.assign(t.style, o), setTimeout(
655
+ () => t.classList.remove("window-toggling"),
656
+ this._config.animationDurationMs
657
+ );
658
+ }
659
+ // Calculate dimensions and position for a snap quadrant
660
+ _getSnapLayout(t, s, e) {
661
+ const i = this._config.snapGap, o = (s - i * 3) / 2, n = (e - i * 3) / 2, a = e - i * 2, l = i, d = o + i * 2, c = i, h = n + i * 2, g = {
662
+ // Quadrants
663
+ tl: { top: c, left: l, width: o, height: n },
664
+ tr: { top: c, left: d, width: o, height: n },
665
+ bl: { top: h, left: l, width: o, height: n },
666
+ br: { top: h, left: d, width: o, height: n },
667
+ // Vertical Splits
668
+ left: { top: c, left: l, width: o, height: a },
669
+ right: { top: c, left: d, width: o, height: a }
670
+ }[t];
671
+ return {
672
+ width: `${g.width}px`,
673
+ height: `${g.height}px`,
674
+ top: `${g.top}px`,
675
+ left: `${g.left}px`
676
+ };
677
+ }
678
+ // Handle browser window resize to keep tiled windows in place
679
+ _handleResize() {
680
+ const t = window.innerWidth, s = window.innerHeight, e = s - this._config.taskbarHeight;
681
+ this._windows.forEach((i) => {
682
+ if (i.classList.contains("tiled") && i.dataset.snapType) {
683
+ const o = i.dataset.snapType, n = this._getSnapLayout(o, t, e);
684
+ Object.assign(i.style, n);
685
+ } else i.classList.contains("maximized") || this._repositionWindowFromRatios(i, t, s);
686
+ });
687
+ }
688
+ // Capture scroll positions of an element and its descendants
689
+ _captureScrollState(t) {
690
+ const s = /* @__PURE__ */ new Map();
691
+ return (t.scrollTop > 0 || t.scrollLeft > 0) && s.set("root", {
692
+ top: t.scrollTop,
693
+ left: t.scrollLeft
694
+ }), t.querySelectorAll("*").forEach((e) => {
695
+ (e.scrollTop > 0 || e.scrollLeft > 0) && s.set(this._getElementPath(t, e), {
696
+ top: e.scrollTop,
697
+ left: e.scrollLeft
698
+ });
699
+ }), s;
700
+ }
701
+ // Restore scroll positions and observe layout shifts for stabilization
702
+ _restoreScrollState(t, s) {
703
+ const e = () => {
704
+ s.forEach((n, a) => {
705
+ let l;
706
+ if (a === "root")
707
+ l = t;
708
+ else
709
+ try {
710
+ l = t.querySelector(`:scope > ${a}`);
711
+ } catch {
712
+ l = t.querySelector(a);
713
+ }
714
+ l && (l.scrollTop = n.top, l.scrollLeft = n.left);
715
+ });
716
+ };
717
+ e();
718
+ const i = t.querySelector(".window-content-scrollable > div") || t, o = new ResizeObserver(() => e());
719
+ o.observe(i), setTimeout(
720
+ () => o.disconnect(),
721
+ this._config.scrollRestoreTimeoutMs
722
+ );
723
+ }
724
+ // Generate unique CSS path for an element relative to window
725
+ _getElementPath(t, s) {
726
+ let e = [], i = s;
727
+ for (; i && i !== t; ) {
728
+ let o = Array.prototype.indexOf.call(
729
+ i.parentNode.children,
730
+ i
731
+ );
732
+ e.unshift(`${i.tagName}:nth-child(${o + 1})`), i = i.parentNode;
733
+ }
734
+ return e.join(" > ");
735
+ }
736
+ async _defaultFetchWindowContent(t) {
737
+ return (await fetch(this._resolveEndpoint(t), {
738
+ headers: { "X-Modal-Request": "1" },
739
+ cache: "no-cache"
740
+ })).text();
741
+ }
742
+ _defaultResolveEndpoint(t) {
743
+ return `/${String(t || "").replace(/^\/+/, "")}`;
744
+ }
745
+ _defaultNotify(t, s) {
746
+ (t === "error" ? console.error : console.log)(`[nidamjs:${t}]`, s);
747
+ }
748
+ _initializeModalContent(t) {
749
+ const s = this._getModules ? this._getModules() : null;
750
+ this._initializeContent(t, {
751
+ delegator: this._delegator,
752
+ modules: s,
753
+ manager: this
754
+ });
755
+ }
756
+ }
757
+ class I {
758
+ #t;
759
+ #s;
760
+ #e = 200;
761
+ constructor(t, { refreshMap: s = null, refreshTimeout: e = 200 } = {}) {
762
+ this.#t = t, this.#s = s || window.window_refresh_map || {}, this.#e = e;
763
+ }
764
+ setRefreshMap(t = {}) {
765
+ this.#s = t || {};
766
+ }
767
+ handleEvent(t, s) {
768
+ const e = this.#s[t], [i, o] = t.split(":"), n = o === "deleted", a = s?.id || null;
769
+ this.#t && Array.from(this.#t._windows.entries()).forEach(
770
+ ([l, d]) => {
771
+ const c = l.startsWith("/") ? l.slice(1) : l;
772
+ if (n && a && d.dataset.dependsOn && d.dataset.dependsOn.split("|").some((g) => {
773
+ const [_, m] = g.split(":");
774
+ return i === _ && String(m) === String(a);
775
+ })) {
776
+ setTimeout(() => {
777
+ this.#t.close(d);
778
+ }, this.#e);
779
+ return;
780
+ }
781
+ e && e.forEach((h) => {
782
+ this.#i(
783
+ h,
784
+ c,
785
+ n ? null : a
786
+ ) && setTimeout(() => {
787
+ this.#t.open(l, !0, null, !1);
788
+ }, this.#e);
789
+ });
790
+ }
791
+ );
792
+ }
793
+ /**
794
+ * Matches a route pattern against an actual path with strict validation.
795
+ *
796
+ * Rules:
797
+ * 1. Exact Match: "team" matches "team", but NOT "team/5" (length mismatch).
798
+ * 2. Wildcard (*): "team/*" matches "team/5", "team/12/details", etc.
799
+ * 3. Parameters ({param}): "team/{id}" matches "team/5".
800
+ * - If entityId is provided, it MUST match the parameter value (e.g. entityId "5" matches "team/5", but not "team/12").
801
+ * - Parameter syntax must be enclosed in braces: {id}.
802
+ *
803
+ * @param {string} pattern - The route pattern from configuration.
804
+ * @param {string} path - The actual window endpoint path.
805
+ * @param {string|null} entityId - Optional ID to enforce specific parameter matching.
806
+ */
807
+ #i(t, s, e = null) {
808
+ if (t === s) return !0;
809
+ const i = t.split("/"), o = s.split("/");
810
+ return !(i[i.length - 1] === "*") && i.length !== o.length ? !1 : i.every((a, l) => a === "*" ? !0 : a.startsWith("{") && a.endsWith("}") ? e !== null ? String(o[l]) === String(e) : !0 : a === o[l]);
811
+ }
812
+ }
813
+ const H = (r, t) => {
814
+ (r === "error" ? console.error : console.log)(`[nidamjs:${r}]`, t);
815
+ };
816
+ class P {
817
+ #t;
818
+ #s = /* @__PURE__ */ new Map();
819
+ #e = null;
820
+ constructor(t = {}) {
821
+ this.#t = {
822
+ root: document,
823
+ modalContainer: "#target",
824
+ pendingModalDatasetKey: "pendingModal",
825
+ registry: [],
826
+ refreshMap: null,
827
+ refreshTimeout: 200,
828
+ notify: H,
829
+ windowManager: {},
830
+ ...t
831
+ };
832
+ }
833
+ initialize() {
834
+ return this.#i(), this.#o(), this.#r(), this;
835
+ }
836
+ getModule(t) {
837
+ return this.#s.get(t);
838
+ }
839
+ getModules() {
840
+ return this.#s;
841
+ }
842
+ #i() {
843
+ this.#e = new b(this.#t.root), this.#s.set("delegator", this.#e);
844
+ }
845
+ #o() {
846
+ const t = this.#t.root.querySelector(
847
+ this.#t.modalContainer
848
+ );
849
+ if (!t)
850
+ return;
851
+ const s = new D(t, this.#e, {
852
+ getModules: () => this.#s,
853
+ initializeContent: (i, o) => x.initialize(
854
+ o.delegator,
855
+ i,
856
+ o.modules,
857
+ this.#t.registry
858
+ ),
859
+ notify: this.#t.notify,
860
+ ...this.#t.windowManager || {}
861
+ });
862
+ this.#s.set("window", s), this.#a(t, s);
863
+ const e = new I(s, {
864
+ refreshMap: this.#t.refreshMap,
865
+ refreshTimeout: this.#t.refreshTimeout
866
+ });
867
+ this.#s.set("refresher", e);
868
+ }
869
+ #a(t, s) {
870
+ const e = this.#t.pendingModalDatasetKey, i = (t?.dataset?.[e] || "").trim();
871
+ if (!i)
872
+ return;
873
+ const o = i.startsWith("/") ? i.slice(1) : i;
874
+ s.open(o);
875
+ }
876
+ #r() {
877
+ x.initialize(
878
+ this.#e,
879
+ this.#t.root,
880
+ this.#s,
881
+ this.#t.registry
882
+ );
883
+ }
884
+ }
885
+ const $ = (r = {}) => new P(r), M = {
886
+ /**
887
+ * Saves a value to localStorage. Automatically stringifies objects/arrays.
888
+ * @param {string} key
889
+ * @param {*} value
890
+ */
891
+ set(r, t) {
892
+ try {
893
+ const s = JSON.stringify(t);
894
+ localStorage.setItem(r, s);
895
+ } catch (s) {
896
+ console.error(`Error saving to localStorage (key: ${r}):`, s);
897
+ }
898
+ },
899
+ /**
900
+ * Retrieves a value from localStorage. Automatically parses JSON.
901
+ * @param {string} key
902
+ * @param {*} defaultValue - Returned if the key doesn't exist or on error.
903
+ * @returns {*}
904
+ */
905
+ get(r, t = null) {
906
+ try {
907
+ const s = localStorage.getItem(r);
908
+ return s === null ? t : JSON.parse(s);
909
+ } catch (s) {
910
+ return console.error(`Error reading from localStorage (key: ${r}):`, s), t;
911
+ }
912
+ },
913
+ /**
914
+ * Removes a specific item from localStorage.
915
+ * @param {string} key
916
+ */
917
+ remove(r) {
918
+ try {
919
+ localStorage.removeItem(r);
920
+ } catch (t) {
921
+ console.error(`Error removing from localStorage (key: ${r}):`, t);
922
+ }
923
+ },
924
+ /**
925
+ * Clears ALL items from localStorage for this domain.
926
+ */
927
+ clear() {
928
+ try {
929
+ localStorage.clear();
930
+ } catch (r) {
931
+ console.error("Error clearing localStorage:", r);
932
+ }
933
+ },
934
+ /**
935
+ * Checks if a key exists in localStorage.
936
+ * @param {string} key
937
+ * @returns {boolean}
938
+ */
939
+ has(r) {
940
+ try {
941
+ return localStorage.getItem(r) !== null;
942
+ } catch {
943
+ return !1;
944
+ }
945
+ }
946
+ };
947
+ class X extends z {
948
+ _dragState = null;
949
+ _storageKey = "desktop_grid_layout";
950
+ _storageNamespace = "";
951
+ _storage = M;
952
+ constructor(t, s, e = {}) {
953
+ super(t, s), this._storageKey = e.storageKey || this._storageKey, this._storageNamespace = e.storageNamespace || "", this._storage = e.storage || M, this._loadLayout();
954
+ }
955
+ _getStorageKey() {
956
+ return this._storageNamespace ? `${this._storageNamespace}_${this._storageKey}` : this._storageKey;
957
+ }
958
+ _loadLayout() {
959
+ try {
960
+ const t = this._getStorageKey(), s = this._storage.get(t, []);
961
+ if (!s || !Array.isArray(s)) return;
962
+ /** @type {NodeListOf<HTMLElement>} */
963
+ this._root.querySelectorAll(".desktop-icon").forEach((i) => {
964
+ const o = i.dataset.modal, n = s.find((a) => a.id === o);
965
+ if (o && n && Array.isArray(n.classes)) {
966
+ const a = Array.from(i.classList).filter(
967
+ (l) => l.startsWith("col-start-") || l.startsWith("row-start-") || l.startsWith("col-end-")
968
+ );
969
+ i.classList.remove(...a), i.classList.add(...n.classes);
970
+ }
971
+ });
972
+ } catch (t) {
973
+ console.error("Failed to load desktop layout", t);
974
+ }
975
+ }
976
+ _bindEvents() {
977
+ this._delegator.on(
978
+ "mousedown",
979
+ ".desktop-icon",
980
+ this._handleDragStart.bind(this)
981
+ );
982
+ }
983
+ _handleDragStart(t, s) {
984
+ if (t.button !== 0) return;
985
+ t.preventDefault();
986
+ const e = s.closest(".desktop-icon"), i = e.getBoundingClientRect(), o = this._root.getBoundingClientRect(), n = Array.from(e.classList).filter(
987
+ (a) => a.startsWith("col-start-") || a.startsWith("row-start-") || a.startsWith("col-end-")
988
+ );
989
+ this._dragState = {
990
+ element: e,
991
+ startX: t.clientX,
992
+ startY: t.clientY,
993
+ initialLeft: i.left - o.left,
994
+ initialTop: i.top - o.top,
995
+ containerRect: o,
996
+ originalClasses: n
997
+ }, e.style.left = `${this._dragState.initialLeft}px`, e.style.top = `${this._dragState.initialTop}px`, e.style.width = `${i.width}px`, e.style.position = "absolute", e.classList.remove(...n), e.classList.add("dragging"), this._dragHandlers = {
998
+ move: this._handleDragMove.bind(this),
999
+ stop: this._handleDragStop.bind(this)
1000
+ }, document.addEventListener("mousemove", this._dragHandlers.move), document.addEventListener("mouseup", this._dragHandlers.stop);
1001
+ }
1002
+ _handleDragMove(t) {
1003
+ if (!this._dragState) return;
1004
+ const { element: s, startX: e, startY: i, initialLeft: o, initialTop: n, containerRect: a } = this._dragState, l = t.clientX - e, d = t.clientY - i;
1005
+ let c = o + l, h = n + d;
1006
+ const f = a.width - s.offsetWidth, g = a.height - s.offsetHeight;
1007
+ c = Math.max(0, Math.min(c, f)), h = Math.max(0, Math.min(h, g)), s.style.left = `${c}px`, s.style.top = `${h}px`;
1008
+ }
1009
+ _handleDragStop(t) {
1010
+ if (!this._dragState) return;
1011
+ const { element: s, startX: e, startY: i, originalClasses: o } = this._dragState, n = Math.abs(t.clientX - e), a = Math.abs(t.clientY - i), l = n > 5 || a > 5;
1012
+ if (s.classList.remove("dragging"), s.style.zIndex = "", l) {
1013
+ const d = (c) => {
1014
+ c.preventDefault(), c.stopPropagation();
1015
+ };
1016
+ s.addEventListener("click", d, {
1017
+ capture: !0,
1018
+ once: !0
1019
+ }), this._snapToGrid(s);
1020
+ } else
1021
+ s.style.position = "", s.style.left = "", s.style.top = "", s.style.width = "", s.classList.add(...o);
1022
+ this._saveLayout && this._saveLayout(), document.removeEventListener("mousemove", this._dragHandlers.move), document.removeEventListener("mouseup", this._dragHandlers.stop), this._dragState = null;
1023
+ }
1024
+ _snapToGrid(t) {
1025
+ const s = this._root.getBoundingClientRect(), e = t.getBoundingClientRect();
1026
+ let i = 2;
1027
+ window.innerWidth >= 1280 ? i = 10 : window.innerWidth >= 1024 ? i = 8 : window.innerWidth >= 768 && (i = 6);
1028
+ const o = 3, n = s.width / i, a = s.height / o, l = e.left - s.left + e.width / 2, d = e.top - s.top + e.height / 2;
1029
+ let c = Math.floor(l / n) + 1, h = Math.floor(d / a) + 1;
1030
+ c = Math.max(1, Math.min(c, i)), h = Math.max(1, Math.min(h, o));
1031
+ const f = `col-start-${c}`, g = `row-start-${h}`;
1032
+ if (Array.from(
1033
+ /** @type {NodeListOf<HTMLElement>} */
1034
+ this._root.querySelectorAll(".desktop-icon")
1035
+ ).find(
1036
+ (p) => p !== t && p.classList.contains(f) && p.classList.contains(g)
1037
+ )) {
1038
+ if (t.style.position = "", t.style.left = "", t.style.top = "", t.style.width = "", this._dragState && this._dragState.originalClasses) {
1039
+ const p = Array.from(t.classList).filter(
1040
+ (S) => S.startsWith("col-start-") || S.startsWith("row-start-") || S.startsWith("col-end-")
1041
+ );
1042
+ t.classList.remove(...p), t.classList.add(...this._dragState.originalClasses);
1043
+ }
1044
+ return;
1045
+ }
1046
+ t.style.position = "", t.style.left = "", t.style.top = "", t.style.width = "";
1047
+ const m = Array.from(t.classList).filter(
1048
+ (p) => p.startsWith("col-start-") || p.startsWith("row-start-") || p.startsWith("col-end-")
1049
+ );
1050
+ t.classList.remove(...m), t.classList.add(f, g);
1051
+ }
1052
+ _saveLayout() {
1053
+ const t = [];
1054
+ /** @type {NodeListOf<HTMLElement>} */
1055
+ this._root.querySelectorAll(".desktop-icon").forEach((i) => {
1056
+ const o = i.dataset.modal;
1057
+ if (o) {
1058
+ const n = Array.from(i.classList).filter(
1059
+ (a) => a.startsWith("col-start-") || a.startsWith("row-start-")
1060
+ );
1061
+ t.push({
1062
+ id: o,
1063
+ classes: n
1064
+ });
1065
+ }
1066
+ });
1067
+ const e = this._getStorageKey();
1068
+ this._storage.set(e, t);
1069
+ }
1070
+ }
1071
+ function A(r, t) {
1072
+ if (!r || !t || t.type !== "success" || !t.emit)
1073
+ return;
1074
+ let s = t.emit, e = t.id || null;
1075
+ const i = s.split(":");
1076
+ i.length >= 3 && (e = i.pop(), s = i.join(":")), r.handleEvent(s, { ...t, emit: s, id: e });
1077
+ }
1078
+ const N = $();
1079
+ N.initialize();
1080
+ export {
1081
+ z as BaseManager,
1082
+ x as ContentInitializer,
1083
+ R as DOMUtils,
1084
+ X as DesktopIconManager,
1085
+ b as EventDelegator,
1086
+ P as NidamApp,
1087
+ D as WindowManager,
1088
+ I as WindowRefresher,
1089
+ L as applyWindowState,
1090
+ T as captureWindowState,
1091
+ $ as createNidamApp,
1092
+ A as handleRefreshEvent,
1093
+ v as readWindowState,
1094
+ C as saveWindowState,
1095
+ M as storageUtil
1096
+ };