@editora/ui-core 0.1.7 → 0.1.9

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.
Files changed (60) hide show
  1. package/dist/ElementBase.d.ts.map +1 -1
  2. package/dist/__tests__/setup.d.ts +8 -0
  3. package/dist/__tests__/setup.d.ts.map +1 -0
  4. package/dist/components/date-time-utils.d.ts.map +1 -1
  5. package/dist/components/ui-anchor.d.ts +7 -0
  6. package/dist/components/ui-anchor.d.ts.map +1 -1
  7. package/dist/components/ui-animated-beam.d.ts.map +1 -1
  8. package/dist/components/ui-calendar.d.ts.map +1 -1
  9. package/dist/components/ui-data-table.d.ts.map +1 -1
  10. package/dist/components/ui-date-picker.d.ts +3 -0
  11. package/dist/components/ui-date-picker.d.ts.map +1 -1
  12. package/dist/components/ui-date-range-picker.d.ts +3 -0
  13. package/dist/components/ui-date-range-picker.d.ts.map +1 -1
  14. package/dist/components/ui-date-range-time-picker.d.ts.map +1 -1
  15. package/dist/components/ui-date-time-picker.d.ts.map +1 -1
  16. package/dist/components/ui-drawer.d.ts.map +1 -1
  17. package/dist/components/ui-form.d.ts +0 -1
  18. package/dist/components/ui-form.d.ts.map +1 -1
  19. package/dist/components/ui-icon-cloud.d.ts +68 -0
  20. package/dist/components/ui-icon-cloud.d.ts.map +1 -0
  21. package/dist/components/ui-listbox.d.ts +3 -0
  22. package/dist/components/ui-listbox.d.ts.map +1 -1
  23. package/dist/components/ui-masonry-grid.d.ts +12 -0
  24. package/dist/components/ui-masonry-grid.d.ts.map +1 -0
  25. package/dist/components/ui-number-ticker.d.ts +98 -0
  26. package/dist/components/ui-number-ticker.d.ts.map +1 -0
  27. package/dist/components/ui-odometer.d.ts +26 -0
  28. package/dist/components/ui-odometer.d.ts.map +1 -0
  29. package/dist/components/ui-placement-grid.d.ts +52 -0
  30. package/dist/components/ui-placement-grid.d.ts.map +1 -0
  31. package/dist/components/ui-portal.d.ts +1 -0
  32. package/dist/components/ui-portal.d.ts.map +1 -1
  33. package/dist/components/ui-sidebar.d.ts.map +1 -1
  34. package/dist/components/ui-sortable.d.ts +192 -0
  35. package/dist/components/ui-sortable.d.ts.map +1 -0
  36. package/dist/components/ui-spinning-text.d.ts +25 -0
  37. package/dist/components/ui-spinning-text.d.ts.map +1 -0
  38. package/dist/components/ui-tooltip.d.ts.map +1 -1
  39. package/dist/components/ui-transfer-list.d.ts +5 -0
  40. package/dist/components/ui-transfer-list.d.ts.map +1 -1
  41. package/dist/index.cjs.js +2778 -938
  42. package/dist/index.d.ts +15 -0
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.esm.js +10845 -9069
  45. package/dist/portal.d.ts.map +1 -1
  46. package/dist/runtime-3cc1c386.mjs +2065 -0
  47. package/dist/runtime-41717c1e.js +1 -0
  48. package/dist/runtime.cjs.js +1 -0
  49. package/dist/runtime.d.ts +9 -0
  50. package/dist/runtime.d.ts.map +1 -0
  51. package/dist/runtime.esm.js +25 -0
  52. package/dist/sortable-06a3bd6c.js +855 -0
  53. package/dist/sortable-23bf110b.mjs +2254 -0
  54. package/dist/sortable.cjs.js +1 -0
  55. package/dist/sortable.d.ts +4 -0
  56. package/dist/sortable.d.ts.map +1 -0
  57. package/dist/sortable.esm.js +4 -0
  58. package/dist/theme.d.ts +1 -1
  59. package/dist/theme.d.ts.map +1 -1
  60. package/package.json +14 -1
@@ -0,0 +1,2254 @@
1
+ class ee extends HTMLElement {
2
+ constructor() {
3
+ super(), this._isRendering = !1, this._renderRequested = !1, this._renderScheduled = !1, this._hasRendered = !1, this._visibilityGuardApplied = !1, this._lastRenderedContent = null, this.root = this.attachShadow({ mode: "open" });
4
+ }
5
+ connectedCallback() {
6
+ if (!this._hasRendered && !this._visibilityGuardApplied && (this.style.getPropertyValue("visibility").trim() || (this.style.setProperty("visibility", "hidden"), this._visibilityGuardApplied = !0)), !this._hasRendered) {
7
+ this._requestRender();
8
+ return;
9
+ }
10
+ this._scheduleRender();
11
+ }
12
+ disconnectedCallback() {
13
+ try {
14
+ if (typeof this.close == "function")
15
+ try {
16
+ this.close();
17
+ } catch {
18
+ }
19
+ if (typeof this._cleanup == "function") {
20
+ try {
21
+ this._cleanup();
22
+ } catch {
23
+ }
24
+ this._cleanup = void 0;
25
+ }
26
+ if (typeof this.__menuCleanup == "function") {
27
+ try {
28
+ this.__menuCleanup();
29
+ } catch {
30
+ }
31
+ this.__menuCleanup = null;
32
+ }
33
+ const e = this._portalEl;
34
+ if (e && e.parentElement)
35
+ try {
36
+ e.parentElement.removeChild(e);
37
+ } catch {
38
+ }
39
+ } catch {
40
+ }
41
+ }
42
+ attributeChangedCallback(e, r, t) {
43
+ r !== t && this.isConnected && (e && !this.shouldRenderOnAttributeChange(e, r ?? null, t ?? null) || this._scheduleRender());
44
+ }
45
+ // Override in components to avoid full shadow rerenders for non-template attributes.
46
+ shouldRenderOnAttributeChange(e, r, t) {
47
+ return !0;
48
+ }
49
+ setContent(e, r) {
50
+ !(r != null && r.force) && this._lastRenderedContent === e || (this.root.innerHTML = e, this._lastRenderedContent = e);
51
+ }
52
+ invalidateContentCache() {
53
+ this._lastRenderedContent = null;
54
+ }
55
+ requestRender() {
56
+ this._scheduleRender();
57
+ }
58
+ _scheduleRender() {
59
+ this._renderScheduled || (this._renderScheduled = !0, queueMicrotask(() => {
60
+ this._renderScheduled = !1, this._requestRender();
61
+ }));
62
+ }
63
+ _requestRender() {
64
+ if (this._isRendering) {
65
+ this._renderRequested = !0;
66
+ return;
67
+ }
68
+ this._isRendering = !0;
69
+ try {
70
+ this.render();
71
+ } finally {
72
+ this._isRendering = !1, this._hasRendered || (this._hasRendered = !0, this._visibilityGuardApplied && (this.style.removeProperty("visibility"), this._visibilityGuardApplied = !1));
73
+ }
74
+ this._renderRequested && (this._renderRequested = !1, this._scheduleRender());
75
+ }
76
+ }
77
+ const te = 1, re = 44, ie = 72, se = `
78
+ :host {
79
+ --ui-sortable-accent: var(--ui-color-primary, #2563eb);
80
+ --ui-sortable-surface: var(--ui-color-surface, #ffffff);
81
+ --ui-sortable-surface-muted: color-mix(in srgb, var(--ui-sortable-surface) 92%, #eff6ff);
82
+ --ui-sortable-border: color-mix(in srgb, var(--ui-color-border, #cbd5e1) 76%, transparent);
83
+ --ui-sortable-text: var(--ui-color-text, #0f172a);
84
+ --ui-sortable-muted: var(--ui-color-muted, #64748b);
85
+ --ui-sortable-shadow:
86
+ 0 1px 3px rgba(15, 23, 42, 0.06),
87
+ 0 16px 34px rgba(15, 23, 42, 0.08);
88
+ --ui-sortable-radius: 24px;
89
+ --ui-sortable-panel-radius: 18px;
90
+ --ui-sortable-item-radius: 16px;
91
+ --ui-sortable-handle-radius: 12px;
92
+ --ui-sortable-gap: 16px;
93
+ --ui-sortable-list-gap: 8px;
94
+ --ui-sortable-item-gap: 12px;
95
+ --ui-sortable-dropzone-size: 10px;
96
+ --ui-sortable-dropzone-inside-size: 16px;
97
+ --ui-sortable-dropzone-container-min-block-size: 76px;
98
+ --ui-sortable-dropzone-container-min-inline-size: 180px;
99
+ --ui-sortable-indent: 22px;
100
+ display: block;
101
+ min-inline-size: 0;
102
+ color: var(--ui-sortable-text);
103
+ color-scheme: light dark;
104
+ font-family: "Inter", "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
105
+ box-sizing: border-box;
106
+ }
107
+
108
+ :host([disabled]) {
109
+ opacity: 0.72;
110
+ }
111
+
112
+ .root {
113
+ display: grid;
114
+ gap: 14px;
115
+ min-inline-size: 0;
116
+ }
117
+
118
+ .toolbar {
119
+ display: flex;
120
+ flex-wrap: wrap;
121
+ align-items: center;
122
+ justify-content: space-between;
123
+ gap: 10px 16px;
124
+ padding: 0 2px;
125
+ color: var(--ui-sortable-muted);
126
+ font-size: 13px;
127
+ line-height: 1.5;
128
+ }
129
+
130
+ .helper {
131
+ display: inline-flex;
132
+ align-items: center;
133
+ gap: 8px;
134
+ min-inline-size: 0;
135
+ }
136
+
137
+ .selection-pill {
138
+ display: inline-flex;
139
+ align-items: center;
140
+ justify-content: center;
141
+ min-inline-size: 28px;
142
+ min-block-size: 24px;
143
+ padding-inline: 8px;
144
+ border-radius: 999px;
145
+ background: color-mix(in srgb, var(--ui-sortable-accent) 14%, transparent);
146
+ color: color-mix(in srgb, var(--ui-sortable-accent) 84%, var(--ui-sortable-text));
147
+ font-weight: 700;
148
+ }
149
+
150
+ .lists {
151
+ display: grid;
152
+ gap: var(--ui-sortable-gap);
153
+ grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
154
+ min-inline-size: 0;
155
+ }
156
+
157
+ .list {
158
+ display: grid;
159
+ grid-template-rows: auto 1fr;
160
+ gap: 12px;
161
+ min-inline-size: 0;
162
+ padding: 16px;
163
+ border: 1px solid var(--ui-sortable-border);
164
+ border-radius: var(--ui-sortable-radius);
165
+ background:
166
+ linear-gradient(
167
+ 180deg,
168
+ color-mix(in srgb, var(--ui-sortable-surface) 96%, transparent),
169
+ color-mix(in srgb, var(--ui-sortable-accent) 4%, var(--ui-sortable-surface))
170
+ );
171
+ box-shadow: var(--ui-sortable-shadow);
172
+ }
173
+
174
+ .list[data-orientation="horizontal"] .items {
175
+ display: flex;
176
+ flex-wrap: nowrap;
177
+ overflow: auto hidden;
178
+ align-items: stretch;
179
+ }
180
+
181
+ .list[data-disabled="true"] {
182
+ opacity: 0.68;
183
+ }
184
+
185
+ .list-header {
186
+ display: grid;
187
+ gap: 4px;
188
+ }
189
+
190
+ .list-custom-header:empty {
191
+ display: none;
192
+ }
193
+
194
+ .list-custom-header:not(:empty) {
195
+ display: block;
196
+ }
197
+
198
+ .list-custom-header:not(:empty) + .list-default-header {
199
+ display: none;
200
+ }
201
+
202
+ .list-topline {
203
+ display: flex;
204
+ align-items: center;
205
+ justify-content: space-between;
206
+ gap: 12px;
207
+ }
208
+
209
+ .list-label {
210
+ font-size: 14px;
211
+ line-height: 1.4;
212
+ font-weight: 700;
213
+ color: var(--ui-sortable-text);
214
+ }
215
+
216
+ .list-count {
217
+ display: inline-flex;
218
+ align-items: center;
219
+ justify-content: center;
220
+ min-inline-size: 28px;
221
+ min-block-size: 24px;
222
+ padding-inline: 8px;
223
+ border-radius: 999px;
224
+ background: color-mix(in srgb, var(--ui-sortable-accent) 10%, transparent);
225
+ color: var(--ui-sortable-muted);
226
+ font-size: 12px;
227
+ font-weight: 700;
228
+ }
229
+
230
+ .list-description,
231
+ .list-helper,
232
+ .empty {
233
+ color: var(--ui-sortable-muted);
234
+ font-size: 12px;
235
+ line-height: 1.55;
236
+ }
237
+
238
+ .items {
239
+ display: grid;
240
+ align-content: start;
241
+ gap: var(--ui-sortable-list-gap);
242
+ min-block-size: 140px;
243
+ min-inline-size: 0;
244
+ }
245
+
246
+ .tree {
247
+ display: grid;
248
+ gap: var(--ui-sortable-list-gap);
249
+ min-inline-size: 0;
250
+ }
251
+
252
+ .list-custom-empty:empty {
253
+ display: none;
254
+ }
255
+
256
+ .list-custom-empty:not(:empty) {
257
+ display: block;
258
+ }
259
+
260
+ .list-custom-empty:not(:empty) + .empty {
261
+ display: none;
262
+ }
263
+
264
+ .item-shell {
265
+ display: grid;
266
+ gap: 8px;
267
+ min-inline-size: 0;
268
+ }
269
+
270
+ .item {
271
+ display: grid;
272
+ grid-template-columns: auto minmax(0, 1fr);
273
+ align-items: start;
274
+ gap: var(--ui-sortable-item-gap);
275
+ min-inline-size: 0;
276
+ padding: 12px;
277
+ border: 1px solid color-mix(in srgb, var(--ui-sortable-border) 82%, transparent);
278
+ border-radius: var(--ui-sortable-item-radius);
279
+ background: var(--ui-sortable-surface-muted);
280
+ box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
281
+ will-change: transform, opacity, box-shadow, border-color, background;
282
+ transition:
283
+ transform 180ms ease,
284
+ opacity 180ms ease,
285
+ box-shadow 180ms ease,
286
+ border-color 180ms ease,
287
+ background 180ms ease;
288
+ }
289
+
290
+ .item[data-drag-handle-mode="item"],
291
+ .item[data-drag-handle-mode="custom"] {
292
+ grid-template-columns: minmax(0, 1fr);
293
+ }
294
+
295
+ .item[data-drag-handle-mode="item"] {
296
+ cursor: grab;
297
+ }
298
+
299
+ .item[data-drag-handle-mode="item"][data-dragging="true"] {
300
+ cursor: grabbing;
301
+ }
302
+
303
+ .item[data-selected="true"] {
304
+ border-color: color-mix(in srgb, var(--ui-sortable-accent) 32%, var(--ui-sortable-border));
305
+ background: color-mix(in srgb, var(--ui-sortable-accent) 11%, var(--ui-sortable-surface));
306
+ box-shadow:
307
+ 0 0 0 1px color-mix(in srgb, var(--ui-sortable-accent) 10%, transparent),
308
+ 0 10px 24px rgba(15, 23, 42, 0.08);
309
+ }
310
+
311
+ .item[data-focused="true"] {
312
+ border-color: color-mix(in srgb, var(--ui-sortable-accent) 42%, var(--ui-sortable-border));
313
+ box-shadow:
314
+ 0 0 0 3px color-mix(in srgb, var(--ui-sortable-accent) 12%, transparent),
315
+ 0 10px 24px rgba(15, 23, 42, 0.08);
316
+ }
317
+
318
+ .item[data-drop-inside-active="true"] {
319
+ border-color: color-mix(in srgb, var(--ui-sortable-accent) 48%, var(--ui-sortable-border));
320
+ background:
321
+ linear-gradient(
322
+ 180deg,
323
+ color-mix(in srgb, var(--ui-sortable-accent) 14%, var(--ui-sortable-surface)),
324
+ color-mix(in srgb, var(--ui-sortable-accent) 10%, var(--ui-sortable-surface-muted))
325
+ );
326
+ box-shadow:
327
+ 0 0 0 3px color-mix(in srgb, var(--ui-sortable-accent) 12%, transparent),
328
+ 0 14px 30px rgba(15, 23, 42, 0.1);
329
+ }
330
+
331
+ .item[data-dragging="true"] {
332
+ opacity: 0.48;
333
+ transform: scale(0.985);
334
+ transition-duration: 0ms, 180ms, 180ms, 180ms, 180ms;
335
+ }
336
+
337
+ .item.item-placeholder {
338
+ grid-template-columns: 1fr;
339
+ border-style: dashed;
340
+ border-color: color-mix(in srgb, var(--ui-sortable-accent) 50%, var(--ui-sortable-border));
341
+ background:
342
+ linear-gradient(
343
+ 180deg,
344
+ color-mix(in srgb, var(--ui-sortable-accent) 10%, var(--ui-sortable-surface)),
345
+ color-mix(in srgb, var(--ui-sortable-accent) 6%, var(--ui-sortable-surface-muted))
346
+ );
347
+ box-shadow:
348
+ inset 0 0 0 1px color-mix(in srgb, var(--ui-sortable-accent) 18%, transparent),
349
+ 0 12px 26px rgba(15, 23, 42, 0.08);
350
+ }
351
+
352
+ .placeholder-content {
353
+ display: grid;
354
+ gap: 6px;
355
+ min-inline-size: 0;
356
+ }
357
+
358
+ .placeholder-kicker {
359
+ font-size: 11px;
360
+ line-height: 1.4;
361
+ font-weight: 700;
362
+ letter-spacing: 0.08em;
363
+ text-transform: uppercase;
364
+ color: color-mix(in srgb, var(--ui-sortable-accent) 72%, var(--ui-sortable-text));
365
+ }
366
+
367
+ .placeholder-title {
368
+ font-size: 14px;
369
+ line-height: 1.4;
370
+ font-weight: 700;
371
+ color: var(--ui-sortable-text);
372
+ }
373
+
374
+ .placeholder-description {
375
+ color: var(--ui-sortable-muted);
376
+ font-size: 12px;
377
+ line-height: 1.55;
378
+ }
379
+
380
+ .drag-preview-overlay {
381
+ position: fixed;
382
+ inset: auto auto auto auto;
383
+ top: -9999px;
384
+ left: -9999px;
385
+ z-index: 2147483646;
386
+ box-sizing: border-box;
387
+ inline-size: min(320px, calc(100vw - 32px));
388
+ padding: 12px;
389
+ border: 1px dashed color-mix(in srgb, var(--ui-sortable-accent) 50%, var(--ui-sortable-border));
390
+ border-radius: var(--ui-sortable-item-radius);
391
+ background:
392
+ linear-gradient(
393
+ 180deg,
394
+ color-mix(in srgb, var(--ui-sortable-accent) 10%, var(--ui-sortable-surface)),
395
+ color-mix(in srgb, var(--ui-sortable-accent) 6%, var(--ui-sortable-surface-muted))
396
+ );
397
+ box-shadow:
398
+ inset 0 0 0 1px color-mix(in srgb, var(--ui-sortable-accent) 18%, transparent),
399
+ 0 18px 40px rgba(15, 23, 42, 0.12);
400
+ pointer-events: none;
401
+ opacity: 0;
402
+ transition: opacity 120ms ease;
403
+ }
404
+
405
+ .drag-preview-overlay[data-visible="true"] {
406
+ opacity: 1;
407
+ }
408
+
409
+ .drag-preview-overlay .placeholder-description {
410
+ display: inline-block;
411
+ max-inline-size: 190px;
412
+ padding: 4px 8px;
413
+ border-radius: 10px;
414
+ background: color-mix(in srgb, var(--ui-sortable-surface) 94%, white 6%);
415
+ box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ui-sortable-border) 72%, transparent);
416
+ color: color-mix(in srgb, var(--ui-sortable-text) 84%, var(--ui-sortable-accent));
417
+ font-weight: 500;
418
+ }
419
+
420
+ .item[data-disabled="true"] {
421
+ opacity: 0.58;
422
+ }
423
+
424
+ .item-content {
425
+ display: grid;
426
+ gap: 4px;
427
+ min-inline-size: 0;
428
+ }
429
+
430
+ :host([custom-item-rendering][custom-item-rendering-pending]) {
431
+ visibility: hidden;
432
+ }
433
+
434
+ :host([custom-item-rendering][custom-item-rendering-ready]) .item-custom-content {
435
+ display: block;
436
+ min-inline-size: 0;
437
+ }
438
+
439
+ :host([custom-item-rendering][custom-item-rendering-ready]) .item-default-content {
440
+ display: none;
441
+ }
442
+
443
+ .item-custom-content:empty {
444
+ display: none;
445
+ }
446
+
447
+ .item-custom-content:not(:empty) {
448
+ display: block;
449
+ min-inline-size: 0;
450
+ }
451
+
452
+ .item-custom-content:not(:empty) + .item-default-content {
453
+ display: none;
454
+ }
455
+
456
+ .item-title {
457
+ font-size: 14px;
458
+ line-height: 1.4;
459
+ font-weight: 700;
460
+ color: var(--ui-sortable-text);
461
+ overflow-wrap: anywhere;
462
+ }
463
+
464
+ .item-description {
465
+ color: var(--ui-sortable-muted);
466
+ font-size: 12px;
467
+ line-height: 1.55;
468
+ overflow-wrap: anywhere;
469
+ }
470
+
471
+ .item-meta {
472
+ display: flex;
473
+ flex-wrap: wrap;
474
+ gap: 6px;
475
+ }
476
+
477
+ .item-badge {
478
+ display: inline-flex;
479
+ align-items: center;
480
+ gap: 6px;
481
+ padding: 4px 8px;
482
+ border-radius: 999px;
483
+ background: color-mix(in srgb, var(--ui-sortable-accent) 10%, transparent);
484
+ color: var(--ui-sortable-muted);
485
+ font-size: 11px;
486
+ font-weight: 600;
487
+ }
488
+
489
+ .item-badge[hidden] {
490
+ display: none;
491
+ }
492
+
493
+ .item[data-drop-inside-active="true"] .item-badge.drop-badge {
494
+ background: color-mix(in srgb, var(--ui-sortable-accent) 18%, var(--ui-sortable-surface));
495
+ color: color-mix(in srgb, var(--ui-sortable-accent) 78%, var(--ui-sortable-text));
496
+ }
497
+
498
+ .item-badge.drop-badge {
499
+ display: none;
500
+ }
501
+
502
+ .item[data-drop-inside-active="true"] .item-badge.drop-badge {
503
+ display: inline-flex;
504
+ }
505
+
506
+ .handle {
507
+ display: inline-grid;
508
+ place-items: center;
509
+ inline-size: 34px;
510
+ block-size: 34px;
511
+ margin: 0;
512
+ padding: 0;
513
+ border: 1px solid color-mix(in srgb, var(--ui-sortable-border) 86%, transparent);
514
+ border-radius: var(--ui-sortable-handle-radius);
515
+ background: color-mix(in srgb, var(--ui-sortable-surface) 92%, transparent);
516
+ color: var(--ui-sortable-muted);
517
+ cursor: grab;
518
+ touch-action: none;
519
+ user-select: none;
520
+ -webkit-user-select: none;
521
+ transition:
522
+ transform 160ms ease,
523
+ color 160ms ease,
524
+ border-color 160ms ease,
525
+ background 160ms ease;
526
+ }
527
+
528
+ .handle:hover {
529
+ color: color-mix(in srgb, var(--ui-sortable-accent) 80%, var(--ui-sortable-text));
530
+ border-color: color-mix(in srgb, var(--ui-sortable-accent) 26%, var(--ui-sortable-border));
531
+ background: color-mix(in srgb, var(--ui-sortable-accent) 8%, var(--ui-sortable-surface));
532
+ }
533
+
534
+ .handle:active {
535
+ cursor: grabbing;
536
+ transform: scale(0.96);
537
+ }
538
+
539
+ .handle[disabled] {
540
+ cursor: not-allowed;
541
+ opacity: 0.48;
542
+ }
543
+
544
+ .handle svg {
545
+ inline-size: 16px;
546
+ block-size: 16px;
547
+ }
548
+
549
+ .children {
550
+ display: grid;
551
+ gap: var(--ui-sortable-list-gap);
552
+ padding-inline-start: var(--ui-sortable-indent);
553
+ min-inline-size: 0;
554
+ }
555
+
556
+ .dropzone {
557
+ position: relative;
558
+ display: block;
559
+ min-block-size: var(--ui-sortable-dropzone-size);
560
+ min-inline-size: 0;
561
+ border-radius: 999px;
562
+ will-change: opacity, background;
563
+ transition: opacity 140ms ease, background 140ms ease;
564
+ }
565
+
566
+ .root[data-dropzone-style="container"] .dropzone {
567
+ display: grid;
568
+ place-items: center;
569
+ min-block-size: var(--ui-sortable-dropzone-match-block-size, var(--ui-sortable-dropzone-container-min-block-size));
570
+ inline-size: min(100%, var(--ui-sortable-dropzone-match-inline-size, 100%));
571
+ max-inline-size: var(--ui-sortable-dropzone-container-max-inline-size, none);
572
+ padding: 12px;
573
+ border: 1px dashed color-mix(in srgb, var(--ui-sortable-accent) 40%, var(--ui-sortable-border));
574
+ border-radius: var(--ui-sortable-item-radius);
575
+ background:
576
+ linear-gradient(
577
+ 180deg,
578
+ color-mix(in srgb, var(--ui-sortable-accent) 9%, var(--ui-sortable-surface)),
579
+ color-mix(in srgb, var(--ui-sortable-accent) 5%, var(--ui-sortable-surface-muted))
580
+ );
581
+ box-shadow:
582
+ inset 0 0 0 1px color-mix(in srgb, var(--ui-sortable-accent) 12%, transparent),
583
+ 0 8px 18px rgba(15, 23, 42, 0.05);
584
+ opacity: 0.82;
585
+ overflow: hidden;
586
+ }
587
+
588
+ .list[data-orientation="horizontal"] .dropzone {
589
+ min-block-size: auto;
590
+ min-inline-size: 16px;
591
+ align-self: stretch;
592
+ }
593
+
594
+ .root[data-dropzone-style="container"] .list[data-orientation="horizontal"] .dropzone {
595
+ min-block-size: var(--ui-sortable-dropzone-match-block-size, var(--ui-sortable-dropzone-container-min-block-size));
596
+ min-inline-size: var(--ui-sortable-dropzone-match-inline-size, var(--ui-sortable-dropzone-container-min-inline-size));
597
+ inline-size: auto;
598
+ align-self: stretch;
599
+ }
600
+
601
+ .dropzone::before {
602
+ content: '';
603
+ position: absolute;
604
+ inset-block-start: 50%;
605
+ inset-inline: 0;
606
+ block-size: 2px;
607
+ transform: translateY(-50%) scaleX(0.42);
608
+ transform-origin: center;
609
+ border-radius: 999px;
610
+ background: color-mix(in srgb, var(--ui-sortable-accent) 22%, transparent);
611
+ transition: transform 160ms ease, background 160ms ease;
612
+ }
613
+
614
+ .list[data-orientation="horizontal"] .dropzone::before {
615
+ inset-block: 0;
616
+ inset-inline-start: 50%;
617
+ inset-inline-end: auto;
618
+ inline-size: 2px;
619
+ block-size: 100%;
620
+ transform: translateX(-50%) scaleY(0.24);
621
+ }
622
+
623
+ .dropzone[data-active="true"] {
624
+ opacity: 1;
625
+ }
626
+
627
+ .root[data-dropzone-style="container"] .dropzone[data-active="true"] {
628
+ border-color: color-mix(in srgb, var(--ui-sortable-accent) 56%, var(--ui-sortable-border));
629
+ background:
630
+ linear-gradient(
631
+ 180deg,
632
+ color-mix(in srgb, var(--ui-sortable-accent) 14%, var(--ui-sortable-surface)),
633
+ color-mix(in srgb, var(--ui-sortable-accent) 10%, var(--ui-sortable-surface-muted))
634
+ );
635
+ box-shadow:
636
+ inset 0 0 0 1px color-mix(in srgb, var(--ui-sortable-accent) 16%, transparent),
637
+ 0 12px 24px rgba(15, 23, 42, 0.08);
638
+ }
639
+
640
+ .list[data-orientation="horizontal"] .dropzone[data-active="true"] {
641
+ opacity: 1;
642
+ }
643
+
644
+ .dropzone[data-active="true"]::before {
645
+ transform: translateY(-50%) scaleX(1);
646
+ background: color-mix(in srgb, var(--ui-sortable-accent) 86%, var(--ui-sortable-text));
647
+ }
648
+
649
+ .list[data-orientation="horizontal"] .dropzone[data-active="true"]::before {
650
+ transform: translateX(-50%) scaleY(1);
651
+ }
652
+
653
+ .dropzone[data-mode="inside"] {
654
+ min-block-size: var(--ui-sortable-dropzone-inside-size);
655
+ margin-block-start: -2px;
656
+ padding-inline-start: 6px;
657
+ }
658
+
659
+ .root[data-dropzone-style="container"] .dropzone[data-mode="inside"] {
660
+ min-block-size: max(
661
+ calc(var(--ui-sortable-dropzone-match-block-size, var(--ui-sortable-dropzone-container-min-block-size)) * 0.78),
662
+ var(--ui-sortable-dropzone-container-min-block-size)
663
+ );
664
+ margin-block-start: 0;
665
+ padding-inline-start: 12px;
666
+ }
667
+
668
+ .dropzone[data-mode="inside"]::before {
669
+ inset-inline-start: 8px;
670
+ inset-inline-end: auto;
671
+ inline-size: 42px;
672
+ }
673
+
674
+ .dropzone-label {
675
+ position: absolute;
676
+ inset-block-start: 50%;
677
+ inset-inline-start: 50%;
678
+ inset-inline-end: auto;
679
+ transform: translate(-50%, -50%) scale(0.98);
680
+ padding: 2px 8px;
681
+ border-radius: 999px;
682
+ background: color-mix(in srgb, var(--ui-sortable-surface) 84%, transparent);
683
+ color: var(--ui-sortable-muted);
684
+ font-size: 11px;
685
+ opacity: 0;
686
+ transition: opacity 120ms ease, transform 120ms ease;
687
+ pointer-events: none;
688
+ }
689
+
690
+ .root[data-dropzone-style="container"] .dropzone::before {
691
+ display: none;
692
+ }
693
+
694
+ .root[data-dropzone-style="container"] .dropzone-label {
695
+ position: static;
696
+ inset: auto;
697
+ transform: none;
698
+ padding: 0;
699
+ border-radius: 0;
700
+ background: transparent;
701
+ color: color-mix(in srgb, var(--ui-sortable-accent) 76%, var(--ui-sortable-text));
702
+ font-size: 12px;
703
+ font-weight: 700;
704
+ letter-spacing: 0.02em;
705
+ opacity: 1;
706
+ white-space: nowrap;
707
+ }
708
+
709
+ .dropzone[data-active="true"] .dropzone-label {
710
+ opacity: 1;
711
+ transform: translate(-50%, -50%) scale(1);
712
+ }
713
+
714
+ .root[data-drag-preview="true"] .dropzone-label {
715
+ opacity: 0;
716
+ }
717
+
718
+ .root[data-dropzone-style="container"][data-drag-preview="true"] .dropzone-label {
719
+ opacity: 1;
720
+ }
721
+
722
+ .root[data-drop-indicator-visibility="active"] .dropzone {
723
+ opacity: 0;
724
+ }
725
+
726
+ .root[data-dropzone-style="container"][data-drop-indicator-visibility="active"] .dropzone {
727
+ display: none;
728
+ opacity: 0;
729
+ }
730
+
731
+ .root[data-dropzone-style="container"][data-drop-indicator-visibility="active"] .dropzone[data-active="true"] {
732
+ display: grid;
733
+ opacity: 1;
734
+ }
735
+
736
+ .root[data-drop-indicator-visibility="active"] .dropzone::before {
737
+ background: transparent;
738
+ transform: translateY(-50%) scaleX(0.16);
739
+ }
740
+
741
+ .root[data-drop-indicator-visibility="active"] .list[data-orientation="horizontal"] .dropzone::before {
742
+ transform: translateX(-50%) scaleY(0.16);
743
+ }
744
+
745
+ .root[data-drop-indicator-visibility="active"] .dropzone[data-active="true"] {
746
+ opacity: 1;
747
+ }
748
+
749
+ .root[data-drop-indicator-visibility="active"] .dropzone[data-active="true"]::before {
750
+ transform: translateY(-50%) scaleX(1);
751
+ background: color-mix(in srgb, var(--ui-sortable-accent) 86%, var(--ui-sortable-text));
752
+ }
753
+
754
+ .root[data-drop-indicator-visibility="active"] .list[data-orientation="horizontal"] .dropzone[data-active="true"]::before {
755
+ transform: translateX(-50%) scaleY(1);
756
+ }
757
+
758
+ .root[data-drop-indicator-visibility="active"] .dropzone[data-active="true"] .dropzone-label {
759
+ opacity: 1;
760
+ transform: translate(-50%, -50%) scale(1);
761
+ }
762
+
763
+ .sr-only {
764
+ position: absolute;
765
+ inline-size: 1px;
766
+ block-size: 1px;
767
+ margin: -1px;
768
+ padding: 0;
769
+ overflow: hidden;
770
+ clip: rect(0, 0, 0, 0);
771
+ white-space: nowrap;
772
+ border: 0;
773
+ }
774
+
775
+ @media (prefers-reduced-motion: reduce) {
776
+ .item,
777
+ .handle,
778
+ .dropzone,
779
+ .dropzone::before,
780
+ .dropzone-label {
781
+ transition: none;
782
+ }
783
+ }
784
+
785
+ @media (forced-colors: active) {
786
+ .list,
787
+ .item,
788
+ .handle {
789
+ forced-color-adjust: none;
790
+ background: Canvas;
791
+ color: CanvasText;
792
+ border-color: CanvasText;
793
+ }
794
+
795
+ .dropzone::before {
796
+ background: Highlight;
797
+ }
798
+ }
799
+ `;
800
+ function N(u) {
801
+ if (!u)
802
+ return [];
803
+ try {
804
+ const e = JSON.parse(u);
805
+ return Array.isArray(e) ? e : [];
806
+ } catch {
807
+ return [];
808
+ }
809
+ }
810
+ function I(u) {
811
+ return u.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
812
+ }
813
+ function z(u, e) {
814
+ return `${u}::${e ?? "__root__"}`;
815
+ }
816
+ function X(u) {
817
+ return u ? [u.listId, u.parentId ?? "", u.beforeId ?? "", u.mode].join("::") : "";
818
+ }
819
+ function B(u, e) {
820
+ return X(u) === X(e);
821
+ }
822
+ function ne(u) {
823
+ if (!u || u === "none")
824
+ return { x: 1, y: 1 };
825
+ const e = u.match(/^matrix3d\((.+)\)$/);
826
+ if (e) {
827
+ const t = e[1].split(",").map((i) => Number.parseFloat(i.trim()));
828
+ if (t.length === 16 && t.every((i) => Number.isFinite(i)))
829
+ return {
830
+ x: t[0] || 1,
831
+ y: t[5] || 1
832
+ };
833
+ }
834
+ const r = u.match(/^matrix\((.+)\)$/);
835
+ if (r) {
836
+ const t = r[1].split(",").map((i) => Number.parseFloat(i.trim()));
837
+ if (t.length === 6 && t.every((i) => Number.isFinite(i))) {
838
+ const [i, s, o, a] = t;
839
+ return {
840
+ x: Math.sqrt(i * i + s * s) || 1,
841
+ y: Math.sqrt(o * o + a * a) || 1
842
+ };
843
+ }
844
+ }
845
+ return { x: 1, y: 1 };
846
+ }
847
+ function oe(u) {
848
+ return u === "item" ? "item" : "handle";
849
+ }
850
+ function $(u) {
851
+ return { ...u };
852
+ }
853
+ function ae(u, e, r, t, i, s) {
854
+ const o = T(u), a = E(u), l = /* @__PURE__ */ new Set(), n = [], d = (p) => {
855
+ const x = o.get(p);
856
+ !x || l.has(p) || (l.add(p), n.push(p), (a.get(z(x.listId, p)) || []).forEach(d));
857
+ };
858
+ t.forEach(d);
859
+ const c = u.map($), g = c.filter((p) => l.has(p.id)), m = i ? c.map($) : c.filter((p) => !l.has(p.id)), f = i ? g.map((p) => s(p, n)) : g.map($), v = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map();
860
+ i && g.forEach((p, x) => {
861
+ v.set(p.id, f[x].id), b.set(f[x].id, p.id);
862
+ }), f.forEach((p) => {
863
+ const x = i ? b.get(p.id) : p.id, F = x ? o.get(x) : null;
864
+ F && (i && (p.parentId = F.parentId && v.has(F.parentId) && v.get(F.parentId) || null), p.listId = r.listId);
865
+ });
866
+ const y = t.map((p) => v.get(p) || p), w = [...m, ...f], k = E(m), A = z(r.listId, r.parentId), _ = [...k.get(A) || []], C = r.beforeId ? _.indexOf(r.beforeId) : _.length, S = C >= 0 ? C : _.length;
867
+ _.splice(S, 0, ...y), k.set(A, _), E(f).forEach((p, x) => {
868
+ const [, F] = x.split("::");
869
+ (F || "") !== "__root__" && k.set(x, [...p]);
870
+ });
871
+ const R = T(w);
872
+ y.forEach((p) => {
873
+ const x = R.get(p);
874
+ x && (x.parentId = r.parentId, x.listId = r.listId);
875
+ });
876
+ const P = [], L = /* @__PURE__ */ new Set(), G = (p, x) => {
877
+ (k.get(z(p, x)) || []).forEach((O, V) => {
878
+ const h = R.get(O);
879
+ !h || L.has(O) || (L.add(O), h.listId = p, h.parentId = x, h.order = V, P.push(h), G(p, O));
880
+ });
881
+ };
882
+ return e.forEach((p) => G(p.id, null)), w.forEach((p) => {
883
+ L.has(p.id) || (p.parentId = null, P.push(p));
884
+ }), {
885
+ items: P.map($),
886
+ insertedRootIds: y
887
+ };
888
+ }
889
+ function E(u) {
890
+ const e = /* @__PURE__ */ new Map();
891
+ return u.forEach((r) => {
892
+ const t = z(r.listId, r.parentId), i = e.get(t);
893
+ i ? i.push(r.id) : e.set(t, [r.id]);
894
+ }), e;
895
+ }
896
+ function T(u) {
897
+ return new Map(u.map((e) => [e.id, e]));
898
+ }
899
+ function Y(u) {
900
+ const e = /* @__PURE__ */ new Set(), r = [];
901
+ return u.forEach((t, i) => {
902
+ const s = typeof (t == null ? void 0 : t.id) == "string" && t.id.trim() ? t.id.trim() : `list-${i + 1}`;
903
+ e.has(s) || (e.add(s), r.push({
904
+ id: s,
905
+ label: typeof (t == null ? void 0 : t.label) == "string" && t.label.trim() ? t.label.trim() : `List ${i + 1}`,
906
+ description: typeof (t == null ? void 0 : t.description) == "string" ? t.description : "",
907
+ emptyLabel: typeof (t == null ? void 0 : t.emptyLabel) == "string" && t.emptyLabel.trim() ? t.emptyLabel.trim() : "Drop items here.",
908
+ orientation: (t == null ? void 0 : t.orientation) === "horizontal" ? "horizontal" : "vertical",
909
+ disabled: !!(t != null && t.disabled),
910
+ cloneOnDrag: !!(t != null && t.cloneOnDrag),
911
+ accepts: Array.isArray(t == null ? void 0 : t.accepts) ? t.accepts.filter((o) => typeof o == "string" && o.trim().length > 0) : void 0
912
+ }));
913
+ }), r.length ? r : [{
914
+ id: "default",
915
+ label: "Items",
916
+ description: "",
917
+ emptyLabel: "Drop items here.",
918
+ orientation: "vertical",
919
+ disabled: !1,
920
+ cloneOnDrag: !1
921
+ }];
922
+ }
923
+ function U(u, e) {
924
+ const r = new Set(u.map((n) => n.id)), t = [];
925
+ e.forEach((n, d) => {
926
+ const c = typeof (n == null ? void 0 : n.id) == "string" && n.id.trim() ? n.id.trim() : "", g = typeof (n == null ? void 0 : n.label) == "string" && n.label.trim() ? n.label.trim() : "";
927
+ if (!c || !g)
928
+ return;
929
+ const m = typeof (n == null ? void 0 : n.listId) == "string" && r.has(n.listId) ? n.listId : u[0].id;
930
+ t.push({
931
+ id: c,
932
+ label: g,
933
+ listId: m,
934
+ parentId: typeof (n == null ? void 0 : n.parentId) == "string" && n.parentId.trim() ? n.parentId.trim() : null,
935
+ description: typeof (n == null ? void 0 : n.description) == "string" ? n.description : "",
936
+ order: Number.isFinite(n == null ? void 0 : n.order) ? Number(n.order) : d,
937
+ disabled: !!(n != null && n.disabled),
938
+ dragDisabled: !!(n != null && n.dragDisabled),
939
+ cloneOnDrag: !!(n != null && n.cloneOnDrag),
940
+ hidden: !!(n != null && n.hidden)
941
+ });
942
+ });
943
+ const i = new Map(t.map((n) => [n.id, n]));
944
+ t.forEach((n) => {
945
+ if (!n.parentId)
946
+ return;
947
+ const d = i.get(n.parentId);
948
+ (!d || d.id === n.id || d.listId !== n.listId) && (n.parentId = null);
949
+ });
950
+ const s = /* @__PURE__ */ new Map();
951
+ t.forEach((n) => {
952
+ const d = z(n.listId, n.parentId), c = s.get(d);
953
+ c ? c.push(n) : s.set(d, [n]);
954
+ }), s.forEach((n) => n.sort((d, c) => d.order - c.order || d.label.localeCompare(c.label)));
955
+ const o = [], a = /* @__PURE__ */ new Set(), l = (n, d) => {
956
+ (s.get(z(n, d)) || []).forEach((g, m) => {
957
+ a.has(g.id) || (a.add(g.id), g.order = m, o.push(g), l(n, g.id));
958
+ });
959
+ };
960
+ return u.forEach((n) => l(n.id, null)), t.forEach((n) => {
961
+ a.has(n.id) || (n.parentId = null, o.push(n));
962
+ }), o.map($);
963
+ }
964
+ function de(u) {
965
+ return JSON.stringify(u.map((e) => ({
966
+ id: e.id,
967
+ label: e.label,
968
+ listId: e.listId,
969
+ parentId: e.parentId,
970
+ description: e.description,
971
+ order: e.order,
972
+ disabled: e.disabled,
973
+ dragDisabled: e.dragDisabled,
974
+ cloneOnDrag: e.cloneOnDrag,
975
+ hidden: e.hidden
976
+ })));
977
+ }
978
+ function le(u) {
979
+ return JSON.stringify(u.map((e) => ({
980
+ id: e.id,
981
+ label: e.label,
982
+ description: e.description,
983
+ emptyLabel: e.emptyLabel,
984
+ orientation: e.orientation,
985
+ disabled: e.disabled,
986
+ cloneOnDrag: e.cloneOnDrag,
987
+ accepts: e.accepts
988
+ })));
989
+ }
990
+ function j(u) {
991
+ return JSON.stringify(u);
992
+ }
993
+ function J(u) {
994
+ const e = /* @__PURE__ */ new Map(), r = u.map((t) => {
995
+ const i = z(t.listId, t.parentId), s = e.get(i) ?? 0;
996
+ return e.set(i, s + 1), {
997
+ id: t.id,
998
+ listId: t.listId,
999
+ parentId: t.parentId,
1000
+ index: s
1001
+ };
1002
+ });
1003
+ return {
1004
+ version: te,
1005
+ records: r
1006
+ };
1007
+ }
1008
+ function W(u, e) {
1009
+ return e ? `${u.label} ${u.description}`.toLowerCase().includes(e.toLowerCase()) : !0;
1010
+ }
1011
+ function Q(u, e, r, t, i) {
1012
+ const s = T(u), o = E(u), a = /* @__PURE__ */ new Map(), l = (c, g) => {
1013
+ const m = [...o.get(z(c, g)) || []];
1014
+ return i === "label" && m.sort((f, v) => {
1015
+ const b = s.get(f), y = s.get(v);
1016
+ return !b || !y ? 0 : b.label.localeCompare(y.label);
1017
+ }), m;
1018
+ }, n = (c, g, m) => {
1019
+ const f = [];
1020
+ return l(c, g).forEach((v) => {
1021
+ const b = s.get(v);
1022
+ if (!b || b.hidden)
1023
+ return;
1024
+ const y = n(c, b.id);
1025
+ !W(b, t) && y.length === 0 || (f.push({
1026
+ id: b.id,
1027
+ disabled: b.disabled
1028
+ }), y.length && f.push(...y));
1029
+ }), f;
1030
+ };
1031
+ return Array.from(new Set(u.map((c) => c.listId))).forEach((c) => {
1032
+ a.set(c, n(c, null));
1033
+ }), a;
1034
+ }
1035
+ class ce extends ee {
1036
+ constructor() {
1037
+ super(), this._lists = Y([]), this._items = [], this._selection = [], this._focusedId = null, this._rangeAnchorId = null, this._dragState = null, this._liveMessage = "Sortable list ready.", this._lastListsAttr = null, this._lastItemsAttr = null, this._lastSelectionAttr = null, this._hydratedPersistKey = null, this._cloneSeed = 1, this._dragImage = null, this._dragPreviewOverlay = null, this._pendingFocusId = null, this._pointerGesture = null, this._pendingDropTarget = null, this._suppressAttributeRender = !1, this._onClick = this._onClick.bind(this), this._onKeyDown = this._onKeyDown.bind(this), this._onDragStart = this._onDragStart.bind(this), this._onDragOver = this._onDragOver.bind(this), this._onDrop = this._onDrop.bind(this), this._onDragEnd = this._onDragEnd.bind(this), this._onPointerDown = this._onPointerDown.bind(this), this._onPointerMove = this._onPointerMove.bind(this), this._onPointerUp = this._onPointerUp.bind(this), this._onPointerCancel = this._onPointerCancel.bind(this), this._onFocusIn = this._onFocusIn.bind(this), this._onDocumentKeyDown = this._onDocumentKeyDown.bind(this);
1038
+ }
1039
+ static get observedAttributes() {
1040
+ return [
1041
+ "lists",
1042
+ "items",
1043
+ "selection",
1044
+ "filter-query",
1045
+ "sort",
1046
+ "persist-key",
1047
+ "allow-filtered-drag",
1048
+ "allow-nesting",
1049
+ "drop-indicator-visibility",
1050
+ "dropzone-style",
1051
+ "drag-preview-size",
1052
+ "drag-handle-mode",
1053
+ "drag-handle-selector",
1054
+ "custom-item-rendering",
1055
+ "show-selection-badge",
1056
+ "disabled"
1057
+ ];
1058
+ }
1059
+ shouldRenderOnAttributeChange(e, r, t) {
1060
+ return this._suppressAttributeRender ? !["lists", "items", "selection"].includes(e) : !0;
1061
+ }
1062
+ attributeChangedCallback(e, r, t) {
1063
+ if (r !== t && this.isConnected) {
1064
+ if (e === "selection" && !this._suppressAttributeRender && this._canSyncInteractiveStateInPlace()) {
1065
+ this._syncSelectionFromAttribute(t ?? null), this._syncSelectionVisualState();
1066
+ return;
1067
+ }
1068
+ if (e === "show-selection-badge" && this._canSyncInteractiveStateInPlace()) {
1069
+ this._syncSelectionVisualState();
1070
+ return;
1071
+ }
1072
+ super.attributeChangedCallback(e, r, t);
1073
+ }
1074
+ }
1075
+ connectedCallback() {
1076
+ var e, r, t, i;
1077
+ super.connectedCallback(), this.root.addEventListener("click", this._onClick), this.root.addEventListener("keydown", this._onKeyDown), this.root.addEventListener("dragstart", this._onDragStart), this.root.addEventListener("dragover", this._onDragOver), this.root.addEventListener("drop", this._onDrop), this.root.addEventListener("dragend", this._onDragEnd), this.root.addEventListener("pointerdown", this._onPointerDown), this.root.addEventListener("focusin", this._onFocusIn), (e = this.ownerDocument) == null || e.addEventListener("keydown", this._onDocumentKeyDown, !0), (r = this.ownerDocument) == null || r.addEventListener("pointermove", this._onPointerMove, !0), (t = this.ownerDocument) == null || t.addEventListener("pointerup", this._onPointerUp, !0), (i = this.ownerDocument) == null || i.addEventListener("pointercancel", this._onPointerCancel, !0);
1078
+ }
1079
+ disconnectedCallback() {
1080
+ var e, r, t, i;
1081
+ this.root.removeEventListener("click", this._onClick), this.root.removeEventListener("keydown", this._onKeyDown), this.root.removeEventListener("dragstart", this._onDragStart), this.root.removeEventListener("dragover", this._onDragOver), this.root.removeEventListener("drop", this._onDrop), this.root.removeEventListener("dragend", this._onDragEnd), this.root.removeEventListener("pointerdown", this._onPointerDown), this.root.removeEventListener("focusin", this._onFocusIn), (e = this.ownerDocument) == null || e.removeEventListener("keydown", this._onDocumentKeyDown, !0), (r = this.ownerDocument) == null || r.removeEventListener("pointermove", this._onPointerMove, !0), (t = this.ownerDocument) == null || t.removeEventListener("pointerup", this._onPointerUp, !0), (i = this.ownerDocument) == null || i.removeEventListener("pointercancel", this._onPointerCancel, !0), this._removeDragPreviewOverlay(), this._removeDragImage(), super.disconnectedCallback();
1082
+ }
1083
+ get lists() {
1084
+ return this._lists.map((e) => ({ ...e }));
1085
+ }
1086
+ set lists(e) {
1087
+ this.setAttribute("lists", JSON.stringify(e ?? []));
1088
+ }
1089
+ get items() {
1090
+ return this._items.map((e) => ({ ...e }));
1091
+ }
1092
+ set items(e) {
1093
+ this.setAttribute("items", JSON.stringify(e ?? []));
1094
+ }
1095
+ get selection() {
1096
+ return [...this._selection];
1097
+ }
1098
+ set selection(e) {
1099
+ this.setAttribute("selection", JSON.stringify(e ?? []));
1100
+ }
1101
+ get sort() {
1102
+ return this.getAttribute("sort") === "label" ? "label" : "manual";
1103
+ }
1104
+ set sort(e) {
1105
+ !e || e === "manual" ? this.removeAttribute("sort") : this.setAttribute("sort", e);
1106
+ }
1107
+ get filterQuery() {
1108
+ return this.getAttribute("filter-query") || "";
1109
+ }
1110
+ set filterQuery(e) {
1111
+ e ? this.setAttribute("filter-query", e) : this.removeAttribute("filter-query");
1112
+ }
1113
+ select(e) {
1114
+ this._setSelection(e, "api");
1115
+ }
1116
+ clearSelection() {
1117
+ this._setSelection([], "api");
1118
+ }
1119
+ cancelDrag() {
1120
+ this._cancelDrag(!0);
1121
+ }
1122
+ focusItem(e) {
1123
+ this._items.some((r) => r.id === e) && (this._focusedId = e, this._pendingFocusId = e, !this._applyInteractiveStateInPlace({ restoreFocus: !0 }) && this.requestRender());
1124
+ }
1125
+ moveSelection(e) {
1126
+ const r = this._selectedRootIds();
1127
+ r.length && this._commitMove({
1128
+ listId: e.targetListId,
1129
+ parentId: e.parentId ?? null,
1130
+ beforeId: e.beforeId ?? null,
1131
+ mode: e.mode ?? (e.parentId ? "inside" : "before")
1132
+ }, r, !!e.clone, e.source ?? "api");
1133
+ }
1134
+ getPersistenceSnapshot() {
1135
+ return J(this._items);
1136
+ }
1137
+ render() {
1138
+ var _, C;
1139
+ this._syncStateFromAttributes();
1140
+ const e = this._measureItemShellRects(), r = new Set(this._draggingIds()), t = new Set(this._selection), s = !!((_ = this._dragState) != null && _.keyboard) ? this._projectedMoveResult() : null, o = (s == null ? void 0 : s.items) || this._items, a = new Set((s == null ? void 0 : s.insertedRootIds) || []), l = !!this._dragState && !this._dragState.keyboard && !!this._dragState.dropTarget, n = Q(o, t, r, this.filterQuery, this.sort), d = this._resolvedFocusedId(n), c = this._isDragLocked(), g = this._selection.length, m = this.getAttribute("allow-nesting") !== "false", f = this.getAttribute("drop-indicator-visibility") === "always" ? "always" : "active", v = this._dropzoneStyle(), b = this.getAttribute("show-selection-badge") !== "false", y = this._dragHandleMode(), w = this._usesCustomHandleSelector(), k = c ? this.sort === "label" ? "Dragging is paused while alphabetical sorting is active." : this.filterQuery && !this.hasAttribute("allow-filtered-drag") ? "Dragging is paused while the list is filtered." : "Dragging is currently disabled." : (C = this._dragState) != null && C.keyboard ? "Keyboard drag active. Use arrow keys to choose a drop target, Space or Enter to drop, and Escape to cancel." : y === "item" ? "Drag from anywhere on an item, or press Space on a focused item to start keyboard reordering." : w ? "Use your custom drag handle element, or press Space on a focused item to start keyboard reordering." : "Use the handle to drag, or press Space on a focused item to start keyboard reordering.", A = `
1141
+ <style>${se}</style>
1142
+ <div
1143
+ class="root"
1144
+ part="root"
1145
+ data-drag-locked="${c}"
1146
+ data-drag-preview="${a.size || l ? "true" : "false"}"
1147
+ data-drop-indicator-visibility="${f}"
1148
+ data-dropzone-style="${v}"
1149
+ >
1150
+ <div class="toolbar" part="toolbar">
1151
+ <div class="helper">${I(k)}</div>
1152
+ <div class="helper selection-summary">
1153
+ <span class="selection-pill" part="selection-count">${g}</span>
1154
+ <span class="selection-text">${g === 1 ? "item selected" : "items selected"}</span>
1155
+ </div>
1156
+ </div>
1157
+ <div class="lists" part="lists">
1158
+ ${this._lists.map((S) => {
1159
+ var L;
1160
+ const M = n.get(S.id) || [], R = M.length ? this._renderListTree(o, S, d, r, m, a, b) : "", P = S.disabled ? "This list is read-only." : S.cloneOnDrag ? "Dragging from this list creates a copy." : (L = S.accepts) != null && L.length ? `Accepts drops from: ${S.accepts.join(", ")}` : "";
1161
+ return `
1162
+ <section
1163
+ class="list"
1164
+ part="list"
1165
+ data-list-id="${I(S.id)}"
1166
+ data-orientation="${S.orientation}"
1167
+ data-disabled="${S.disabled}"
1168
+ aria-label="${I(S.label)}"
1169
+ >
1170
+ <header class="list-header">
1171
+ <div class="list-custom-header" part="list-custom-header" data-list-header-target="${I(S.id)}"></div>
1172
+ <div class="list-default-header">
1173
+ <div class="list-topline">
1174
+ <div class="list-label">${I(S.label)}</div>
1175
+ <span class="list-count">${M.length}</span>
1176
+ </div>
1177
+ ${S.description ? `<div class="list-description">${I(S.description)}</div>` : ""}
1178
+ ${P ? `<div class="list-helper">${I(P)}</div>` : ""}
1179
+ </div>
1180
+ </header>
1181
+ <div class="items" role="listbox" aria-multiselectable="true">
1182
+ ${R || `<div class="list-custom-empty" part="list-custom-empty" data-list-empty-target="${I(S.id)}"></div><div class="empty">${I(S.emptyLabel)}</div>${this._renderDropzone({
1183
+ listId: S.id,
1184
+ parentId: null,
1185
+ beforeId: null,
1186
+ mode: "before"
1187
+ }, "Drop here")}`}
1188
+ </div>
1189
+ </section>
1190
+ `;
1191
+ }).join("")}
1192
+ </div>
1193
+ <div class="sr-only" aria-live="polite" aria-atomic="true">${I(this._liveMessage)}</div>
1194
+ </div>
1195
+ `;
1196
+ this.setContent(A), queueMicrotask(() => {
1197
+ this._restorePendingFocus(), this._applyCurrentDropTargetVisualState(), this._applyLiveMessage(), this._updatePointerDragPreview(), this._animateItemShellReflow(e);
1198
+ });
1199
+ }
1200
+ _syncStateFromAttributes() {
1201
+ var i;
1202
+ const e = this.getAttribute("lists");
1203
+ e !== this._lastListsAttr && (this._lastListsAttr = e, this._lists = Y(N(e)));
1204
+ const r = this.getAttribute("items");
1205
+ if (r !== this._lastItemsAttr) {
1206
+ this._lastItemsAttr = r, this._items = U(this._lists, N(r));
1207
+ const s = this.getAttribute("persist-key");
1208
+ s && this._hydratedPersistKey !== s && (this._items = this._restorePersistedItems(s, this._items), this._hydratedPersistKey = s);
1209
+ }
1210
+ const t = this.getAttribute("selection");
1211
+ t !== this._lastSelectionAttr && this._syncSelectionFromAttribute(t), this._focusedId || (this._focusedId = ((i = this._items.find((s) => !s.hidden)) == null ? void 0 : i.id) || null);
1212
+ }
1213
+ _restorePersistedItems(e, r) {
1214
+ try {
1215
+ const t = window.localStorage.getItem(e);
1216
+ if (!t)
1217
+ return r;
1218
+ const i = JSON.parse(t);
1219
+ if (!i || typeof i != "object" || !Array.isArray(i.records))
1220
+ return r;
1221
+ const s = new Map(i.records.map((a) => [a.id, a])), o = r.map((a, l) => {
1222
+ const n = s.get(a.id);
1223
+ return n ? {
1224
+ ...a,
1225
+ listId: this._lists.some((d) => d.id === n.listId) ? n.listId : a.listId,
1226
+ parentId: typeof n.parentId == "string" ? n.parentId : null,
1227
+ order: Number.isFinite(n.index) ? n.index : l
1228
+ } : { ...a, order: l };
1229
+ });
1230
+ return U(this._lists, o);
1231
+ } catch {
1232
+ return r;
1233
+ }
1234
+ }
1235
+ _resolvedFocusedId(e) {
1236
+ const r = new Set(Array.from(e.values()).flat().map((i) => i.id));
1237
+ if (this._focusedId && r.has(this._focusedId))
1238
+ return this._focusedId;
1239
+ const t = Array.from(e.values()).flat().find((i) => !i.disabled);
1240
+ return (t == null ? void 0 : t.id) || null;
1241
+ }
1242
+ _restorePendingFocus() {
1243
+ const e = this._pendingFocusId || this._focusedId;
1244
+ if (!e)
1245
+ return;
1246
+ const r = typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/"/g, '\\"'), t = this.root.querySelector(`.item[data-id="${r}"]`);
1247
+ t && (document.activeElement !== t && t.focus({ preventScroll: !0 }), this._pendingFocusId = null);
1248
+ }
1249
+ _escapeSelectorValue(e) {
1250
+ return typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/"/g, '\\"');
1251
+ }
1252
+ _findDropzone(e) {
1253
+ const r = this._escapeSelectorValue(e.listId), t = this._escapeSelectorValue(e.parentId ?? ""), i = this._escapeSelectorValue(e.beforeId ?? ""), s = this._escapeSelectorValue(e.mode);
1254
+ return this.root.querySelector(
1255
+ `.dropzone[data-list-id="${r}"][data-parent-id="${t}"][data-before-id="${i}"][data-mode="${s}"]`
1256
+ );
1257
+ }
1258
+ _findItemElement(e) {
1259
+ const r = this._escapeSelectorValue(e);
1260
+ return this.root.querySelector(`.item[data-id="${r}"]`);
1261
+ }
1262
+ _dragHandleMode() {
1263
+ return oe(this.getAttribute("drag-handle-mode"));
1264
+ }
1265
+ _dropzoneStyle() {
1266
+ return this.getAttribute("dropzone-style") === "container" ? "container" : "indicator";
1267
+ }
1268
+ _usesCustomHandleSelector() {
1269
+ var e;
1270
+ return !!((e = this.getAttribute("drag-handle-selector")) != null && e.trim());
1271
+ }
1272
+ _dragActivatorFromPath(e) {
1273
+ var o;
1274
+ const r = e.find((a) => a instanceof HTMLElement && !!a.getAttribute("data-drag-trigger"));
1275
+ if (!r)
1276
+ return null;
1277
+ const t = r.getAttribute("data-drag-trigger"), i = t === "item" ? "item" : t === "custom" ? "custom" : "handle", s = r.getAttribute("data-id") || ((o = r.closest(".item[data-id]")) == null ? void 0 : o.getAttribute("data-id"));
1278
+ return s ? { element: r, id: s, kind: i } : null;
1279
+ }
1280
+ _setDropTargetVisualState(e, r) {
1281
+ var i;
1282
+ if (!e)
1283
+ return;
1284
+ const t = this._findDropzone(e);
1285
+ t && (t.setAttribute("data-active", r ? "true" : "false"), r ? this._syncDropzoneContainerSize(t, e) : this._clearDropzoneContainerSize(t)), e.mode === "inside" && e.parentId && ((i = this._findItemElement(e.parentId)) == null || i.setAttribute("data-drop-inside-active", r ? "true" : "false"));
1286
+ }
1287
+ _applyCurrentDropTargetVisualState(e) {
1288
+ var r;
1289
+ this._setDropTargetVisualState(e ?? null, !1), this._setDropTargetVisualState(((r = this._dragState) == null ? void 0 : r.dropTarget) ?? null, !0);
1290
+ }
1291
+ _applyLiveMessage() {
1292
+ const e = this.root.querySelector(".sr-only[aria-live]");
1293
+ e && (e.textContent = this._liveMessage);
1294
+ }
1295
+ _canSyncInteractiveStateInPlace() {
1296
+ return !!this.root.querySelector(".root") && !this._dragState;
1297
+ }
1298
+ _applyInteractiveStateInPlace(e) {
1299
+ return this._canSyncInteractiveStateInPlace() ? (this._syncSelectionVisualState(), e != null && e.restoreFocus && this._restorePendingFocus(), this._applyLiveMessage(), !0) : !1;
1300
+ }
1301
+ _hasCustomItemRendering() {
1302
+ return this.hasAttribute("custom-item-rendering");
1303
+ }
1304
+ _syncSelectionFromAttribute(e) {
1305
+ this._lastSelectionAttr = e;
1306
+ const r = new Set(this._items.map((t) => t.id));
1307
+ this._selection = N(e).filter((t) => r.has(t)), !this._selection.length && this._focusedId && !r.has(this._focusedId) && (this._focusedId = null);
1308
+ }
1309
+ _syncSelectionVisualState() {
1310
+ const e = new Set(this._selection), r = this.getAttribute("show-selection-badge") !== "false";
1311
+ this.root.querySelectorAll(".item[data-id]").forEach((s) => {
1312
+ const o = s.getAttribute("data-id");
1313
+ if (!o)
1314
+ return;
1315
+ const a = e.has(o), l = this._focusedId === o;
1316
+ s.setAttribute("data-selected", a ? "true" : "false"), s.setAttribute("aria-selected", a ? "true" : "false"), s.setAttribute("data-focused", l ? "true" : "false"), s.setAttribute("tabindex", l ? "0" : "-1");
1317
+ const n = s.querySelector('[data-selection-badge="true"]');
1318
+ if (n) {
1319
+ const d = a && r;
1320
+ n.hidden = !d, n.textContent = d ? "Selected" : "";
1321
+ }
1322
+ });
1323
+ const t = this.root.querySelector(".selection-pill");
1324
+ t && (t.textContent = String(this._selection.length));
1325
+ const i = this.root.querySelector(".selection-text");
1326
+ i && (i.textContent = this._selection.length === 1 ? "item selected" : "items selected");
1327
+ }
1328
+ _clearDropzoneContainerSize(e) {
1329
+ e.style.removeProperty("--ui-sortable-dropzone-match-block-size"), e.style.removeProperty("--ui-sortable-dropzone-match-inline-size");
1330
+ }
1331
+ _dropzoneReferenceElement(e, r) {
1332
+ if (e.mode === "inside" && e.parentId)
1333
+ return this._findItemElement(e.parentId);
1334
+ let t = r.nextElementSibling;
1335
+ for (; t; ) {
1336
+ if (t instanceof HTMLElement && t.classList.contains("item-shell"))
1337
+ return t.querySelector(".item[data-id]");
1338
+ t = t.nextElementSibling;
1339
+ }
1340
+ let i = r.previousElementSibling;
1341
+ for (; i; ) {
1342
+ if (i instanceof HTMLElement && i.classList.contains("item-shell"))
1343
+ return i.querySelector(".item[data-id]");
1344
+ i = i.previousElementSibling;
1345
+ }
1346
+ const s = this._escapeSelectorValue(e.listId), o = this.root.querySelector(`.list[data-list-id="${s}"] .items`), a = o == null ? void 0 : o.querySelector(".item[data-id]");
1347
+ return a || o || null;
1348
+ }
1349
+ _syncDropzoneContainerSize(e, r) {
1350
+ if (this._clearDropzoneContainerSize(e), this._dropzoneStyle() !== "container")
1351
+ return;
1352
+ const t = this._dropzoneReferenceElement(r, e);
1353
+ if (!t)
1354
+ return;
1355
+ const i = t.getBoundingClientRect();
1356
+ e.style.setProperty("--ui-sortable-dropzone-match-block-size", `${Math.max(76, Math.round(i.height))}px`), e.style.setProperty("--ui-sortable-dropzone-match-inline-size", `${Math.max(180, Math.round(i.width))}px`);
1357
+ }
1358
+ _ensureDragPreviewOverlay() {
1359
+ if (this._dragPreviewOverlay && this._dragPreviewOverlay.isConnected)
1360
+ return this._dragPreviewOverlay;
1361
+ const e = document.createElement("div");
1362
+ return e.className = "drag-preview-overlay", e.setAttribute("data-visible", "false"), this.root.appendChild(e), this._dragPreviewOverlay = e, e;
1363
+ }
1364
+ _clearPointerDragPreview() {
1365
+ var r, t, i, s;
1366
+ (r = this._dragPreviewOverlay) == null || r.setAttribute("data-visible", "false"), (t = this._dragPreviewOverlay) == null || t.style.setProperty("left", "-9999px"), (i = this._dragPreviewOverlay) == null || i.style.setProperty("top", "-9999px");
1367
+ const e = this.root.querySelector(".root");
1368
+ e && !((s = this._dragState) != null && s.keyboard) && e.setAttribute("data-drag-preview", "false");
1369
+ }
1370
+ _pointerPreviewContent() {
1371
+ if (!this._dragState || this._dragState.keyboard)
1372
+ return null;
1373
+ const e = this._dragState.movedRootIds[0], r = this._items.find((t) => t.id === e);
1374
+ return r ? {
1375
+ kicker: this._dragState.clone ? "Copy preview" : "Drop preview",
1376
+ title: this._dragState.clone ? `${r.label} copy` : r.label,
1377
+ description: this._dragState.clone ? "Release to add a copy here." : this._dragState.movedRootIds.length > 1 ? "Release to place this selection here." : "Release to place this item here."
1378
+ } : null;
1379
+ }
1380
+ _pointerPreviewSize() {
1381
+ if (this.getAttribute("drag-preview-size") === "compact" || !this._dragState || this._dragState.keyboard)
1382
+ return null;
1383
+ const e = this._dragState.movedRootIds[0], r = e ? this._findItemElement(e) : null;
1384
+ if (!r)
1385
+ return null;
1386
+ const t = window.getComputedStyle(r), i = ne(t.transform);
1387
+ return {
1388
+ width: r.offsetWidth * i.x,
1389
+ height: r.offsetHeight * i.y
1390
+ };
1391
+ }
1392
+ _updatePointerDragPreview() {
1393
+ if (!this._dragState || this._dragState.keyboard) {
1394
+ this._clearPointerDragPreview();
1395
+ return;
1396
+ }
1397
+ const e = this._pointerPreviewContent();
1398
+ if (!e) {
1399
+ this._clearPointerDragPreview();
1400
+ return;
1401
+ }
1402
+ const r = this.root.querySelector(".root"), t = this._dragPreviewOverlay, i = (t == null ? void 0 : t.getAttribute("data-visible")) === "true", s = this._pointerPreviewSize();
1403
+ if (!this._dragState.dropTarget) {
1404
+ i && r && r.setAttribute("data-drag-preview", "true");
1405
+ return;
1406
+ }
1407
+ const o = this._findDropzone(this._dragState.dropTarget);
1408
+ if (!o) {
1409
+ i && r && r.setAttribute("data-drag-preview", "true");
1410
+ return;
1411
+ }
1412
+ const a = this._ensureDragPreviewOverlay();
1413
+ a.innerHTML = `
1414
+ <div class="placeholder-content">
1415
+ <div class="placeholder-kicker">${I(e.kicker)}</div>
1416
+ <div class="placeholder-title">${I(e.title)}</div>
1417
+ <div class="placeholder-description">${I(e.description)}</div>
1418
+ </div>
1419
+ `;
1420
+ const l = o.getBoundingClientRect();
1421
+ r && r.setAttribute("data-drag-preview", "true"), a.style.setProperty("left", "-9999px"), a.style.setProperty("top", "-9999px"), s ? (a.style.setProperty("inline-size", `${s.width}px`), a.style.setProperty("block-size", `${s.height}px`)) : (a.style.removeProperty("inline-size"), a.style.removeProperty("block-size")), a.setAttribute("data-visible", "true");
1422
+ const n = a.getBoundingClientRect(), d = (s == null ? void 0 : s.width) ?? n.width, c = (s == null ? void 0 : s.height) ?? n.height, g = Math.max(16, Math.min(l.left, window.innerWidth - d - 16)), m = Math.max(
1423
+ 16,
1424
+ Math.min(
1425
+ l.top + (l.height - c) / 2,
1426
+ window.innerHeight - c - 16
1427
+ )
1428
+ );
1429
+ a.style.setProperty("left", `${Math.round(g)}px`), a.style.setProperty("top", `${Math.round(m)}px`);
1430
+ }
1431
+ _setDraggingVisualState(e, r) {
1432
+ e.forEach((t) => {
1433
+ const i = this._findItemElement(t);
1434
+ i && (i.setAttribute("data-dragging", r ? "true" : "false"), i.setAttribute("aria-grabbed", r ? "true" : "false"), r && i.getBoundingClientRect());
1435
+ });
1436
+ }
1437
+ _setDropTarget(e, r) {
1438
+ var i;
1439
+ const t = ((i = this._dragState) == null ? void 0 : i.dropTarget) ?? null;
1440
+ if (!(!this._dragState || B(t, e))) {
1441
+ if (this._pendingDropTarget = null, this._dragState.dropTarget = e, this._applyCurrentDropTargetVisualState(t), r != null && r.announceLabel && this._announce(r.announceLabel), this._dragState.keyboard) {
1442
+ this.requestRender();
1443
+ return;
1444
+ }
1445
+ this._updatePointerDragPreview();
1446
+ }
1447
+ }
1448
+ _queueDropTarget(e, r, t) {
1449
+ if (!this._dragState)
1450
+ return;
1451
+ const i = this._dragState.dropTarget ?? null;
1452
+ if (B(i, e)) {
1453
+ this._pendingDropTarget = null;
1454
+ return;
1455
+ }
1456
+ if (!i && e) {
1457
+ this._setDropTarget(e, t);
1458
+ return;
1459
+ }
1460
+ const s = typeof r == "number" && Number.isFinite(r) ? r : performance.now(), o = this._pendingDropTarget;
1461
+ if (o && B(o.target, e)) {
1462
+ const a = e ? re : ie;
1463
+ s - o.startedAt >= a && this._setDropTarget(e, o.announceLabel ? { announceLabel: o.announceLabel } : t);
1464
+ return;
1465
+ }
1466
+ this._pendingDropTarget = {
1467
+ target: e,
1468
+ startedAt: s,
1469
+ announceLabel: t == null ? void 0 : t.announceLabel
1470
+ };
1471
+ }
1472
+ _releaseDropTarget(e, r) {
1473
+ var s;
1474
+ if (!this._dragState)
1475
+ return null;
1476
+ if (Number.isFinite(e) && Number.isFinite(r)) {
1477
+ const o = this._dropTargetFromPoint(e, r);
1478
+ if (o && this._canDrop(o, this._dragState.movedRootIds))
1479
+ return this._pendingDropTarget = null, o;
1480
+ }
1481
+ const t = ((s = this._pendingDropTarget) == null ? void 0 : s.target) ?? null;
1482
+ if (this._pendingDropTarget = null, t && this._canDrop(t, this._dragState.movedRootIds))
1483
+ return t;
1484
+ const i = this._dragState.dropTarget ?? null;
1485
+ return i && this._canDrop(i, this._dragState.movedRootIds) ? i : null;
1486
+ }
1487
+ _pathFromPoint(e, r) {
1488
+ var o, a;
1489
+ const t = [], i = this.root;
1490
+ let s = typeof i.elementFromPoint == "function" ? i.elementFromPoint(e, r) : ((o = this.ownerDocument) == null ? void 0 : o.elementFromPoint(e, r)) ?? null;
1491
+ for (; s && (s instanceof HTMLElement && t.push(s), s !== this); ) {
1492
+ if (s instanceof ShadowRoot) {
1493
+ s = s.host;
1494
+ continue;
1495
+ }
1496
+ s = s.parentNode, !s && ((a = t[t.length - 1]) == null ? void 0 : a.getRootNode()) instanceof ShadowRoot && (s = t[t.length - 1].getRootNode().host);
1497
+ }
1498
+ return t;
1499
+ }
1500
+ _measureItemShellRects() {
1501
+ const e = /* @__PURE__ */ new Map();
1502
+ return this.root.querySelectorAll(".item-shell[data-item-shell]").forEach((r) => {
1503
+ const t = r.getAttribute("data-item-shell");
1504
+ if (!t)
1505
+ return;
1506
+ const i = r.getBoundingClientRect();
1507
+ e.set(t, { top: i.top, left: i.left });
1508
+ }), e;
1509
+ }
1510
+ _animateItemShellReflow(e) {
1511
+ if (!e.size)
1512
+ return;
1513
+ const r = new Set(this._draggingIds());
1514
+ this.root.querySelectorAll(".item-shell[data-item-shell]").forEach((t) => {
1515
+ const i = t.getAttribute("data-item-shell");
1516
+ if (!i || r.has(i))
1517
+ return;
1518
+ const s = e.get(i);
1519
+ if (!s)
1520
+ return;
1521
+ const o = t.getBoundingClientRect(), a = s.left - o.left, l = s.top - o.top;
1522
+ Math.abs(a) < 0.5 && Math.abs(l) < 0.5 || (t.style.transition = "none", t.style.transform = `translate(${a}px, ${l}px)`, t.style.willChange = "transform", t.getBoundingClientRect(), requestAnimationFrame(() => {
1523
+ t.style.transition = "transform 180ms ease", t.style.transform = "";
1524
+ const n = () => {
1525
+ t.style.transition = "", t.style.willChange = "", t.removeEventListener("transitionend", n);
1526
+ };
1527
+ t.addEventListener("transitionend", n), window.setTimeout(n, 220);
1528
+ }));
1529
+ });
1530
+ }
1531
+ _previewCloneSubtreeItem(e, r) {
1532
+ const t = e.id.includes("--copy-") ? e.id.split("--copy-")[0] : e.id;
1533
+ return {
1534
+ ...e,
1535
+ id: `${t}--preview`,
1536
+ label: r[0] === e.id ? `${e.label} copy` : e.label
1537
+ };
1538
+ }
1539
+ _projectedMoveResult() {
1540
+ var e;
1541
+ return !((e = this._dragState) != null && e.dropTarget) || !this._canDrop(this._dragState.dropTarget, this._dragState.movedRootIds) ? null : ae(
1542
+ this._items,
1543
+ this._lists,
1544
+ this._dragState.dropTarget,
1545
+ this._dragState.movedRootIds,
1546
+ this._dragState.clone,
1547
+ (r, t) => this._previewCloneSubtreeItem(r, t)
1548
+ );
1549
+ }
1550
+ _renderListTree(e, r, t, i, s, o, a) {
1551
+ const l = T(e), n = E(e), d = (c) => {
1552
+ const g = n.get(z(r.id, c)) || [], m = this.sort === "label" ? [...g].sort((v, b) => {
1553
+ const y = l.get(v), w = l.get(b);
1554
+ return !y || !w ? 0 : y.label.localeCompare(w.label);
1555
+ }) : g;
1556
+ let f = "";
1557
+ return m.forEach((v) => {
1558
+ const b = l.get(v);
1559
+ if (!b || b.hidden)
1560
+ return;
1561
+ const y = this._renderChildBranch(
1562
+ b,
1563
+ t,
1564
+ i,
1565
+ d,
1566
+ s,
1567
+ o,
1568
+ a
1569
+ );
1570
+ !W(b, this.filterQuery) && !y.includes('class="item"') || (f += this._renderDropzone({
1571
+ listId: r.id,
1572
+ parentId: c,
1573
+ beforeId: v,
1574
+ mode: "before"
1575
+ }, "Drop here"), f += y);
1576
+ }), f += this._renderDropzone({
1577
+ listId: r.id,
1578
+ parentId: c,
1579
+ beforeId: null,
1580
+ mode: "before"
1581
+ }, "Drop here"), f;
1582
+ };
1583
+ return `<div class="tree">${d(null)}</div>`;
1584
+ }
1585
+ _renderChildBranch(e, r, t, i, s, o, a) {
1586
+ var S, M, R, P;
1587
+ const l = I(e.id), n = o.has(e.id), d = n ? "" : i(e.id), c = d.includes('class="item"'), g = n ? !1 : this._selection.includes(e.id), m = n ? !1 : t.has(e.id), f = e.disabled, v = f || e.dragDisabled || this._isDragLocked(), b = ((M = (S = this._dragState) == null ? void 0 : S.dropTarget) == null ? void 0 : M.mode) === "inside" && this._dragState.dropTarget.parentId === e.id, y = (R = this._dragState) != null && R.clone ? "Copy preview" : "Drop preview", w = (P = this._dragState) != null && P.clone ? "Release to add a copy here." : this._dragState && this._dragState.movedRootIds.length > 1 ? "Release to place this selection here." : "Release to place this item here.", k = this._dragHandleMode(), A = this._usesCustomHandleSelector(), _ = A ? "custom" : k, C = !A && k === "handle";
1588
+ return `
1589
+ <div class="item-shell" data-item-shell="${l}">
1590
+ <article
1591
+ class="item${n ? " item-placeholder" : ""}"
1592
+ part="item"
1593
+ data-id="${l}"
1594
+ data-drag-handle-mode="${_}"
1595
+ ${!n && _ === "item" ? 'data-drag-trigger="item"' : ""}
1596
+ data-selected="${g}"
1597
+ data-focused="${n ? "false" : r === e.id}"
1598
+ data-dragging="${m}"
1599
+ data-disabled="${f}"
1600
+ data-drop-inside-active="${b ? "true" : "false"}"
1601
+ role="${n ? "presentation" : "option"}"
1602
+ aria-selected="${n ? "false" : g}"
1603
+ aria-disabled="${f}"
1604
+ aria-grabbed="${n ? "false" : m}"
1605
+ aria-hidden="${n ? "true" : "false"}"
1606
+ tabindex="${n ? "-1" : r === e.id ? "0" : "-1"}"
1607
+ >
1608
+ ${n ? `
1609
+ <div class="placeholder-content">
1610
+ <div class="placeholder-kicker">${I(y)}</div>
1611
+ <div class="placeholder-title">${I(e.label)}</div>
1612
+ <div class="placeholder-description">${I(w)}</div>
1613
+ </div>
1614
+ ` : `
1615
+ ${C ? `
1616
+ <button
1617
+ class="handle"
1618
+ part="handle"
1619
+ type="button"
1620
+ data-action="handle"
1621
+ data-drag-trigger="handle"
1622
+ data-id="${l}"
1623
+ draggable="false"
1624
+ ${v ? "disabled" : ""}
1625
+ aria-label="Drag ${I(e.label)}"
1626
+ >
1627
+ <svg viewBox="0 0 16 16" aria-hidden="true" focusable="false">
1628
+ <circle cx="5" cy="4" r="1.25"></circle>
1629
+ <circle cx="11" cy="4" r="1.25"></circle>
1630
+ <circle cx="5" cy="8" r="1.25"></circle>
1631
+ <circle cx="11" cy="8" r="1.25"></circle>
1632
+ <circle cx="5" cy="12" r="1.25"></circle>
1633
+ <circle cx="11" cy="12" r="1.25"></circle>
1634
+ </svg>
1635
+ </button>
1636
+ ` : ""}
1637
+ <div class="item-content" data-action="select" data-id="${l}">
1638
+ <div class="item-custom-content" part="item-custom-content" data-item-content-target="${l}"></div>
1639
+ <div class="item-default-content">
1640
+ <div class="item-title">${I(e.label)}</div>
1641
+ ${e.description ? `<div class="item-description">${I(e.description)}</div>` : ""}
1642
+ <div class="item-meta">
1643
+ <span class="item-badge selection-badge" data-selection-badge="true" ${g && a ? "" : "hidden"}>${g && a ? "Selected" : ""}</span>
1644
+ ${e.cloneOnDrag ? '<span class="item-badge">Clone on drag</span>' : ""}
1645
+ ${e.dragDisabled ? '<span class="item-badge">Pinned</span>' : ""}
1646
+ ${s ? '<span class="item-badge drop-badge">Nest here</span>' : ""}
1647
+ </div>
1648
+ </div>
1649
+ </div>
1650
+ `}
1651
+ </article>
1652
+ ${s && !n ? this._renderDropzone({
1653
+ listId: e.listId,
1654
+ parentId: e.id,
1655
+ beforeId: null,
1656
+ mode: "inside"
1657
+ }, "Nest here") : ""}
1658
+ ${c ? `<div class="children">${d}</div>` : ""}
1659
+ </div>
1660
+ `;
1661
+ }
1662
+ _renderDropzone(e, r) {
1663
+ var i;
1664
+ const t = ((i = this._dragState) == null ? void 0 : i.dropTarget) && this._dragState.dropTarget.listId === e.listId && this._dragState.dropTarget.parentId === e.parentId && this._dragState.dropTarget.beforeId === e.beforeId && this._dragState.dropTarget.mode === e.mode;
1665
+ return `
1666
+ <div
1667
+ class="dropzone"
1668
+ part="dropzone"
1669
+ data-list-id="${I(e.listId)}"
1670
+ data-parent-id="${I(e.parentId ?? "")}"
1671
+ data-before-id="${I(e.beforeId ?? "")}"
1672
+ data-mode="${e.mode}"
1673
+ data-active="${t ? "true" : "false"}"
1674
+ aria-hidden="true"
1675
+ >
1676
+ <span class="dropzone-label">${I(r)}</span>
1677
+ </div>
1678
+ `;
1679
+ }
1680
+ _onClick(e) {
1681
+ const r = e.composedPath(), t = r.find((n) => {
1682
+ var d;
1683
+ return n instanceof HTMLElement && ((d = n.classList) == null ? void 0 : d.contains("toolbar"));
1684
+ }), i = this._dragActivatorFromPath(r), s = r.find((n) => n instanceof HTMLElement && n.classList.contains("item"));
1685
+ if (i && i.kind !== "item")
1686
+ return;
1687
+ if (!s)
1688
+ return t && !(e.target instanceof HTMLButtonElement), void 0;
1689
+ const o = s.getAttribute("data-id");
1690
+ if (!o)
1691
+ return;
1692
+ const a = this._items.find((n) => n.id === o);
1693
+ if (!a || a.disabled)
1694
+ return;
1695
+ const l = e;
1696
+ if (l.shiftKey ? this._selectRangeTo(o) : l.metaKey || l.ctrlKey ? this._toggleSelection(o) : this._setSelection([o], "pointer"), this._focusedId = o, this._rangeAnchorId = o, this._pendingFocusId = o, this._hasCustomItemRendering()) {
1697
+ this._syncSelectionVisualState(), this._restorePendingFocus();
1698
+ return;
1699
+ }
1700
+ this.requestRender();
1701
+ }
1702
+ _onFocusIn(e) {
1703
+ const r = e.composedPath().find((i) => i instanceof HTMLElement && i.classList.contains("item")), t = r == null ? void 0 : r.getAttribute("data-id");
1704
+ t && (this._focusedId = t, this._syncSelectionVisualState());
1705
+ }
1706
+ _onKeyDown(e) {
1707
+ var l;
1708
+ const r = this._visibleItemIds();
1709
+ if (!r.length)
1710
+ return;
1711
+ const t = this._focusedId && r.includes(this._focusedId) ? this._focusedId : r[0], i = r.indexOf(t), s = this._items.find((n) => n.id === t), o = s ? this._lists.find((n) => n.id === s.listId) : null, a = (o == null ? void 0 : o.orientation) === "horizontal";
1712
+ if (!((l = this._dragState) != null && l.keyboard)) {
1713
+ if (e.key === "ArrowDown" && !a || e.key === "ArrowRight" && a) {
1714
+ e.preventDefault(), this._moveFocusBy(r, i, 1);
1715
+ return;
1716
+ }
1717
+ if (e.key === "ArrowUp" && !a || e.key === "ArrowLeft" && a) {
1718
+ e.preventDefault(), this._moveFocusBy(r, i, -1);
1719
+ return;
1720
+ }
1721
+ if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "a") {
1722
+ e.preventDefault(), this._setSelection(r, "keyboard"), this._announce(`${r.length} items selected.`);
1723
+ return;
1724
+ }
1725
+ if (e.key === "Enter") {
1726
+ e.preventDefault(), this._setSelection([t], "keyboard");
1727
+ return;
1728
+ }
1729
+ if (e.key === " " || e.code === "Space") {
1730
+ if (e.preventDefault(), this._isDragLocked()) {
1731
+ this._announce("Dragging is disabled right now.");
1732
+ return;
1733
+ }
1734
+ const n = this._selectedRootIds(t);
1735
+ if (!n.length)
1736
+ return;
1737
+ const d = this._itemClonesOnDrag(t);
1738
+ this._dragState = {
1739
+ snapshot: this._items.map($),
1740
+ movedRootIds: n,
1741
+ originId: t,
1742
+ clone: d,
1743
+ keyboard: !0,
1744
+ dropTarget: this._initialKeyboardDropTarget(t),
1745
+ committed: !1
1746
+ };
1747
+ const c = n.length === 1 ? `Lifted ${(s == null ? void 0 : s.label) || "item"}.` : `Lifted ${n.length} items.`;
1748
+ this._announce(`${c} Use arrow keys to choose a destination.`), this.requestRender();
1749
+ return;
1750
+ }
1751
+ if (e.key === "Escape") {
1752
+ this._setSelection([], "keyboard");
1753
+ return;
1754
+ }
1755
+ return;
1756
+ }
1757
+ if (e.key === "Escape") {
1758
+ e.preventDefault(), this._cancelDrag(!0);
1759
+ return;
1760
+ }
1761
+ if (e.key === "Enter" || e.key === " " || e.code === "Space") {
1762
+ e.preventDefault();
1763
+ const n = this._dragState.dropTarget;
1764
+ if (!n)
1765
+ return;
1766
+ this._commitMove(n, this._dragState.movedRootIds, this._dragState.clone, "keyboard");
1767
+ return;
1768
+ }
1769
+ if (["ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"].includes(e.key)) {
1770
+ e.preventDefault();
1771
+ const n = e.key === "ArrowDown" || e.key === "ArrowRight" ? 1 : -1;
1772
+ this._moveKeyboardDropTarget(n);
1773
+ }
1774
+ }
1775
+ _moveFocusBy(e, r, t) {
1776
+ const i = Math.max(0, Math.min(e.length - 1, r + t)), s = e[i];
1777
+ this._focusedId = s, this._pendingFocusId = s, !this._applyInteractiveStateInPlace({ restoreFocus: !0 }) && this.requestRender();
1778
+ }
1779
+ _onDragStart(e) {
1780
+ const r = this._dragActivatorFromPath(e.composedPath()), t = r == null ? void 0 : r.id;
1781
+ if (!r || !t) {
1782
+ e.preventDefault();
1783
+ return;
1784
+ }
1785
+ if (this._isDragLocked()) {
1786
+ e.preventDefault(), this._announce("Dragging is disabled right now.");
1787
+ return;
1788
+ }
1789
+ const i = this._items.find((a) => a.id === t);
1790
+ if (!i || i.disabled || i.dragDisabled) {
1791
+ e.preventDefault();
1792
+ return;
1793
+ }
1794
+ const s = this._selection.includes(t) ? this._selectedRootIds(t) : [t];
1795
+ this._selection.includes(t) || this._setSelection([t], "pointer");
1796
+ const o = this._itemClonesOnDrag(t);
1797
+ this._dragState = {
1798
+ snapshot: this._items.map($),
1799
+ movedRootIds: s,
1800
+ originId: t,
1801
+ clone: o,
1802
+ keyboard: !1,
1803
+ dropTarget: null,
1804
+ committed: !1
1805
+ }, e.dataTransfer && (e.dataTransfer.effectAllowed = o ? "copyMove" : "move", e.dataTransfer.setData("text/plain", s.join(",")), this._applyDragImage(e.dataTransfer, s.length)), this._announce(
1806
+ o ? `Dragging ${s.length === 1 ? i.label : `${s.length} items`} as a copy.` : `Dragging ${s.length === 1 ? i.label : `${s.length} items`}.`
1807
+ ), this.requestRender();
1808
+ }
1809
+ _onDragOver(e) {
1810
+ if (!this._dragState || this._dragState.keyboard)
1811
+ return;
1812
+ const r = this._dropTargetFromEvent(e);
1813
+ if (!r || !this._canDrop(r, this._dragState.movedRootIds)) {
1814
+ this._queueDropTarget(null, e.timeStamp);
1815
+ return;
1816
+ }
1817
+ e.preventDefault(), this._queueDropTarget(r, e.timeStamp), e.dataTransfer && (e.dataTransfer.dropEffect = this._dragState.clone ? "copy" : "move");
1818
+ }
1819
+ _onDrop(e) {
1820
+ if (!this._dragState || this._dragState.keyboard)
1821
+ return;
1822
+ const r = this._dropTargetFromEvent(e);
1823
+ !r || !this._canDrop(r, this._dragState.movedRootIds) || (e.preventDefault(), this._commitMove(r, this._dragState.movedRootIds, this._dragState.clone, "pointer"));
1824
+ }
1825
+ _onDocumentKeyDown(e) {
1826
+ e.key === "Escape" && (!this._dragState || this._dragState.keyboard || (e.preventDefault(), this._cancelDrag(!0)));
1827
+ }
1828
+ _onDragEnd() {
1829
+ !this._dragState || this._dragState.keyboard || this._dragState.committed || (this._pendingDropTarget = null, this._setDropTargetVisualState(this._dragState.dropTarget, !1), this._clearPointerDragPreview(), this._dragState = null, this._removeDragImage(), this._announce("Drag cancelled."), this.requestRender());
1830
+ }
1831
+ _dropTargetFromEvent(e) {
1832
+ return this._dropTargetFromPath(e.composedPath(), e.clientX, e.clientY);
1833
+ }
1834
+ _dropTargetFromPath(e, r, t) {
1835
+ const i = e.find((_) => _ instanceof HTMLElement && _.classList.contains("dropzone"));
1836
+ if (i) {
1837
+ const _ = {
1838
+ listId: i.getAttribute("data-list-id") || "",
1839
+ parentId: i.getAttribute("data-parent-id") || null,
1840
+ beforeId: i.getAttribute("data-before-id") || null,
1841
+ mode: i.getAttribute("data-mode") === "inside" ? "inside" : "before"
1842
+ };
1843
+ if (_.listId)
1844
+ return _;
1845
+ }
1846
+ const s = e.find((_) => _ instanceof HTMLElement && _.classList.contains("item"));
1847
+ if (!s)
1848
+ return null;
1849
+ const o = s.getAttribute("data-id");
1850
+ if (!o)
1851
+ return null;
1852
+ const a = this._items.find((_) => _.id === o);
1853
+ if (!a)
1854
+ return null;
1855
+ const l = this._lists.find((_) => _.id === a.listId), n = s.getBoundingClientRect(), d = (l == null ? void 0 : l.orientation) === "horizontal", c = d ? n.left : n.top, g = d ? n.right : n.bottom, m = d ? r : t, f = Math.max(1, g - c), v = (m - c) / f, b = this.getAttribute("allow-nesting") !== "false" && !a.disabled;
1856
+ if (v <= 0.34)
1857
+ return {
1858
+ listId: a.listId,
1859
+ parentId: a.parentId,
1860
+ beforeId: a.id,
1861
+ mode: "before"
1862
+ };
1863
+ if (b && v >= 0.34 && v <= 0.74)
1864
+ return {
1865
+ listId: a.listId,
1866
+ parentId: a.id,
1867
+ beforeId: null,
1868
+ mode: "inside"
1869
+ };
1870
+ const w = E(this._items).get(z(a.listId, a.parentId)) || [], k = w.indexOf(a.id), A = k >= 0 && w[k + 1] || null;
1871
+ return {
1872
+ listId: a.listId,
1873
+ parentId: a.parentId,
1874
+ beforeId: A,
1875
+ mode: "before"
1876
+ };
1877
+ }
1878
+ _dropTargetFromPoint(e, r) {
1879
+ return this._dropTargetFromPath(this._pathFromPoint(e, r), e, r);
1880
+ }
1881
+ _beginPointerDrag(e, r) {
1882
+ if (!this._pointerGesture || this._dragState)
1883
+ return;
1884
+ const t = this._items.find((i) => {
1885
+ var s;
1886
+ return i.id === ((s = this._pointerGesture) == null ? void 0 : s.originId);
1887
+ });
1888
+ t && (this._dragState = {
1889
+ snapshot: this._items.map($),
1890
+ movedRootIds: [...this._pointerGesture.movedRootIds],
1891
+ originId: this._pointerGesture.originId,
1892
+ clone: this._pointerGesture.clone,
1893
+ keyboard: !1,
1894
+ dropTarget: null,
1895
+ committed: !1
1896
+ }, this._pendingDropTarget = null, this._applyPointerPreview(
1897
+ e,
1898
+ r,
1899
+ this._dragState.movedRootIds.length,
1900
+ this._dragState.clone
1901
+ ), this._setDraggingVisualState(this._draggingIds(), !0), this._announce(
1902
+ this._dragState.clone ? `Dragging ${this._dragState.movedRootIds.length === 1 ? t.label : `${this._dragState.movedRootIds.length} items`} as a copy.` : `Dragging ${this._dragState.movedRootIds.length === 1 ? t.label : `${this._dragState.movedRootIds.length} items`}.`
1903
+ ));
1904
+ }
1905
+ _onPointerDown(e) {
1906
+ var o, a;
1907
+ const r = this._dragActivatorFromPath(e.composedPath()), t = r == null ? void 0 : r.id;
1908
+ if (!r || !t)
1909
+ return;
1910
+ if (this._isDragLocked()) {
1911
+ e.preventDefault(), this._announce("Dragging is disabled right now.");
1912
+ return;
1913
+ }
1914
+ const i = this._items.find((l) => l.id === t);
1915
+ if (!i || i.disabled || i.dragDisabled) {
1916
+ e.preventDefault();
1917
+ return;
1918
+ }
1919
+ e.preventDefault();
1920
+ try {
1921
+ (a = (o = r.element).setPointerCapture) == null || a.call(o, e.pointerId);
1922
+ } catch {
1923
+ }
1924
+ const s = this._selection.includes(t) ? this._selectedRootIds(t) : [t];
1925
+ this._pointerGesture = {
1926
+ pointerId: e.pointerId,
1927
+ pointerType: e.pointerType,
1928
+ originId: t,
1929
+ movedRootIds: s,
1930
+ clone: this._itemClonesOnDrag(t),
1931
+ startX: e.clientX,
1932
+ startY: e.clientY,
1933
+ moved: !1,
1934
+ captureTarget: r.element
1935
+ };
1936
+ }
1937
+ _onPointerMove(e) {
1938
+ if (!(!this._pointerGesture || e.pointerId !== this._pointerGesture.pointerId)) {
1939
+ if (e.preventDefault(), !this._pointerGesture.moved) {
1940
+ if (Math.hypot(e.clientX - this._pointerGesture.startX, e.clientY - this._pointerGesture.startY) < 6)
1941
+ return;
1942
+ this._pointerGesture.moved = !0, this._beginPointerDrag(e.clientX, e.clientY);
1943
+ }
1944
+ if (!(!this._dragState || this._dragState.keyboard) && (this._movePointerPreview(e.clientX, e.clientY), !this._dragState.committed)) {
1945
+ const r = this._dropTargetFromPoint(e.clientX, e.clientY);
1946
+ if (!r || !this._canDrop(r, this._dragState.movedRootIds)) {
1947
+ this._queueDropTarget(null, e.timeStamp);
1948
+ return;
1949
+ }
1950
+ this._queueDropTarget(r, e.timeStamp);
1951
+ }
1952
+ }
1953
+ }
1954
+ _onPointerUp(e) {
1955
+ var i, s;
1956
+ if (!this._pointerGesture || e.pointerId !== this._pointerGesture.pointerId)
1957
+ return;
1958
+ e.preventDefault();
1959
+ try {
1960
+ (s = (i = this._pointerGesture.captureTarget) == null ? void 0 : i.releasePointerCapture) == null || s.call(i, e.pointerId);
1961
+ } catch {
1962
+ }
1963
+ const r = this._pointerGesture;
1964
+ if (this._pointerGesture = null, !this._dragState || this._dragState.keyboard)
1965
+ return;
1966
+ const t = r.moved ? this._releaseDropTarget(e.clientX, e.clientY) : null;
1967
+ if (r.moved && t) {
1968
+ this._commitMove(t, this._dragState.movedRootIds, this._dragState.clone, "pointer");
1969
+ return;
1970
+ }
1971
+ r.moved ? this._cancelDrag(!0) : (this._setDropTargetVisualState(this._dragState.dropTarget, !1), this._clearPointerDragPreview(), this._dragState = null, this._removeDragImage(), this.requestRender());
1972
+ }
1973
+ _onPointerCancel(e) {
1974
+ !this._pointerGesture || e.pointerId !== this._pointerGesture.pointerId || (this._pointerGesture = null, this._dragState && this._cancelDrag(!0));
1975
+ }
1976
+ _setSelection(e, r) {
1977
+ const t = new Set(this._items.map((a) => a.id)), i = Array.from(new Set(e.filter((a) => t.has(a)))), s = [...this._selection];
1978
+ this._selection = i, this._rangeAnchorId = i[i.length - 1] || null, this._focusedId = i[i.length - 1] || this._focusedId;
1979
+ const o = j(i);
1980
+ if (this.getAttribute("selection") !== o) {
1981
+ this._lastSelectionAttr = o, this._suppressAttributeRender = !0;
1982
+ try {
1983
+ i.length ? this.setAttribute("selection", o) : this.removeAttribute("selection");
1984
+ } finally {
1985
+ this._suppressAttributeRender = !1;
1986
+ }
1987
+ }
1988
+ if (this.dispatchEvent(new CustomEvent("selection-change", {
1989
+ detail: {
1990
+ selection: [...i],
1991
+ previousSelection: s
1992
+ },
1993
+ bubbles: !0,
1994
+ composed: !0
1995
+ })), r !== "restore") {
1996
+ if (this._applyInteractiveStateInPlace({ restoreFocus: !0 }))
1997
+ return;
1998
+ this.requestRender();
1999
+ }
2000
+ }
2001
+ _toggleSelection(e) {
2002
+ const r = this._selection.includes(e) ? this._selection.filter((t) => t !== e) : [...this._selection, e];
2003
+ this._setSelection(r, "pointer"), this._announce(`${r.length} items selected.`);
2004
+ }
2005
+ _selectRangeTo(e) {
2006
+ const r = this._visibleItemIds(), t = this._rangeAnchorId || this._focusedId || e, i = r.indexOf(t), s = r.indexOf(e);
2007
+ if (i < 0 || s < 0) {
2008
+ this._setSelection([e], "pointer");
2009
+ return;
2010
+ }
2011
+ const [o, a] = i <= s ? [i, s] : [s, i];
2012
+ this._setSelection(r.slice(o, a + 1), "pointer"), this._announce(`${a - o + 1} items selected.`);
2013
+ }
2014
+ _visibleItemIds() {
2015
+ const e = Q(this._items, new Set(this._selection), new Set(this._draggingIds()), this.filterQuery, this.sort);
2016
+ return Array.from(e.values()).flat().filter((r) => !r.disabled).map((r) => r.id);
2017
+ }
2018
+ _selectedRootIds(e) {
2019
+ const r = this._selection.length ? [...this._selection] : e ? [e] : [], t = T(this._items), i = new Set(r);
2020
+ return r.filter((s) => {
2021
+ var l;
2022
+ const o = t.get(s);
2023
+ if (!o)
2024
+ return !1;
2025
+ let a = o.parentId;
2026
+ for (; a; ) {
2027
+ if (i.has(a))
2028
+ return !1;
2029
+ a = ((l = t.get(a)) == null ? void 0 : l.parentId) ?? null;
2030
+ }
2031
+ return !o.disabled;
2032
+ });
2033
+ }
2034
+ _draggingIds() {
2035
+ if (!this._dragState)
2036
+ return [];
2037
+ const e = T(this._items), r = E(this._items), t = [], i = (s) => {
2038
+ t.push(s);
2039
+ const o = e.get(s);
2040
+ if (!o)
2041
+ return;
2042
+ (r.get(z(o.listId, s)) || []).forEach(i);
2043
+ };
2044
+ return this._dragState.movedRootIds.forEach(i), t;
2045
+ }
2046
+ _itemClonesOnDrag(e) {
2047
+ const r = this._items.find((i) => i.id === e);
2048
+ if (!r)
2049
+ return !1;
2050
+ if (r.cloneOnDrag)
2051
+ return !0;
2052
+ const t = this._lists.find((i) => i.id === r.listId);
2053
+ return !!(t != null && t.cloneOnDrag);
2054
+ }
2055
+ _isDragLocked() {
2056
+ return !!(this.hasAttribute("disabled") || this.sort !== "manual" || this.filterQuery && !this.hasAttribute("allow-filtered-drag"));
2057
+ }
2058
+ _canDrop(e, r) {
2059
+ var n;
2060
+ if (this._isDragLocked())
2061
+ return !1;
2062
+ const t = this._lists.find((d) => d.id === e.listId);
2063
+ if (!t || t.disabled)
2064
+ return !1;
2065
+ const i = T(this._items), s = /* @__PURE__ */ new Set(), o = E(this._items), a = (d) => {
2066
+ s.add(d);
2067
+ const c = i.get(d);
2068
+ c && (o.get(z(c.listId, d)) || []).forEach(a);
2069
+ };
2070
+ if (r.forEach(a), e.parentId && s.has(e.parentId) || e.beforeId && s.has(e.beforeId))
2071
+ return !1;
2072
+ const l = Array.from(new Set(r.map((d) => {
2073
+ var c;
2074
+ return (c = i.get(d)) == null ? void 0 : c.listId;
2075
+ }).filter(Boolean)));
2076
+ return !((n = t.accepts) != null && n.length && l.some((d) => {
2077
+ var c;
2078
+ return !((c = t.accepts) != null && c.includes(d));
2079
+ }) || e.mode === "inside" && this.getAttribute("allow-nesting") === "false");
2080
+ }
2081
+ _commitMove(e, r, t, i) {
2082
+ if (!this._canDrop(e, r))
2083
+ return;
2084
+ const s = T(this._items), o = E(this._items), a = /* @__PURE__ */ new Set(), l = [], n = (h) => {
2085
+ const D = s.get(h);
2086
+ !D || a.has(h) || (a.add(h), l.push(h), (o.get(z(D.listId, h)) || []).forEach(n));
2087
+ };
2088
+ r.forEach(n);
2089
+ const d = this._items.map($), c = d.filter((h) => a.has(h.id)), g = t ? d.map($) : d.filter((h) => !a.has(h.id)), m = t ? c.map((h) => this._cloneSubtreeItem(h, l)) : c.map($), f = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map();
2090
+ t && c.forEach((h, D) => {
2091
+ f.set(h.id, m[D].id), v.set(m[D].id, h.id);
2092
+ }), m.forEach((h) => {
2093
+ const D = t ? v.get(h.id) : h.id, q = D ? s.get(D) : null;
2094
+ q && (t && (h.parentId = q.parentId && f.has(q.parentId) && f.get(q.parentId) || null), h.listId = e.listId);
2095
+ });
2096
+ const b = r.map((h) => f.get(h) || h), y = [...g, ...m], w = E(g), k = z(e.listId, e.parentId), A = [...w.get(k) || []], _ = e.beforeId ? A.indexOf(e.beforeId) : A.length, C = _ >= 0 ? _ : A.length;
2097
+ A.splice(C, 0, ...b), w.set(k, A), E(m).forEach((h, D) => {
2098
+ const [, q] = D.split("::");
2099
+ (q || "") !== "__root__" && w.set(D, [...h]);
2100
+ });
2101
+ const M = T(y);
2102
+ b.forEach((h) => {
2103
+ const D = M.get(h);
2104
+ D && (D.parentId = e.parentId, D.listId = e.listId);
2105
+ });
2106
+ const R = [], P = /* @__PURE__ */ new Set(), L = (h, D) => {
2107
+ (w.get(z(h, D)) || []).forEach((K, Z) => {
2108
+ const H = M.get(K);
2109
+ !H || P.has(K) || (P.add(K), H.listId = h, H.parentId = D, H.order = Z, R.push(H), L(h, K));
2110
+ });
2111
+ };
2112
+ this._lists.forEach((h) => L(h.id, null)), y.forEach((h) => {
2113
+ P.has(h.id) || (h.parentId = null, R.push(h));
2114
+ }), this._dragState && (this._dragState.committed = !0), this._items = R.map($), this._clearPointerDragPreview(), this._dragState = null, this._removeDragImage();
2115
+ const G = [...b], p = [...this._selection];
2116
+ this._selection = G, this._focusedId = G[0] || null, this._pendingFocusId = this._focusedId, this._syncAttributesFromState();
2117
+ const x = J(this._items);
2118
+ this._persistSnapshot(x);
2119
+ const F = r.map((h) => s.get(h)).filter((h) => !!h), O = t ? "clone" : e.mode === "inside" ? "nest" : F.some((h) => h.listId !== e.listId) ? "transfer" : "reorder", V = {
2120
+ items: this.items,
2121
+ lists: this.lists,
2122
+ selection: [...G],
2123
+ previousSelection: p,
2124
+ movedIds: [...b],
2125
+ source: i,
2126
+ operation: O,
2127
+ persistence: x
2128
+ };
2129
+ this.dispatchEvent(new CustomEvent("change", {
2130
+ detail: V,
2131
+ bubbles: !0,
2132
+ composed: !0
2133
+ })), this.dispatchEvent(new CustomEvent("persist-request", {
2134
+ detail: V,
2135
+ bubbles: !0,
2136
+ composed: !0
2137
+ })), this._announce(this._messageForMove(O, b.length, e)), this.requestRender();
2138
+ }
2139
+ _syncAttributesFromState() {
2140
+ const e = le(this._lists), r = de(this._items), t = j(this._selection);
2141
+ this._lastListsAttr = e, this._lastItemsAttr = r, this._lastSelectionAttr = t, this._suppressAttributeRender = !0;
2142
+ try {
2143
+ this.setAttribute("lists", e), this.setAttribute("items", r), this._selection.length ? this.setAttribute("selection", t) : this.removeAttribute("selection");
2144
+ } finally {
2145
+ this._suppressAttributeRender = !1;
2146
+ }
2147
+ }
2148
+ _cloneSubtreeItem(e, r) {
2149
+ const i = `copy-${this._cloneSeed++}`, o = `${e.id.includes("--copy-") ? e.id.split("--copy-")[0] : e.id}--${i}`;
2150
+ return {
2151
+ ...e,
2152
+ id: o,
2153
+ label: r[0] === e.id ? `${e.label} copy` : e.label
2154
+ };
2155
+ }
2156
+ _messageForMove(e, r, t) {
2157
+ const i = this._lists.find((o) => o.id === t.listId), s = (i == null ? void 0 : i.label) || t.listId;
2158
+ return e === "clone" ? `${r === 1 ? "Item copied" : `${r} items copied`} into ${s}.` : e === "nest" ? `${r === 1 ? "Item nested" : `${r} items nested`} in ${s}.` : e === "transfer" ? `${r === 1 ? "Item moved" : `${r} items moved`} to ${s}.` : `${r === 1 ? "Item reordered" : `${r} items reordered`} in ${s}.`;
2159
+ }
2160
+ _persistSnapshot(e) {
2161
+ const r = this.getAttribute("persist-key");
2162
+ if (r)
2163
+ try {
2164
+ window.localStorage.setItem(r, JSON.stringify(e));
2165
+ } catch {
2166
+ }
2167
+ }
2168
+ _announce(e) {
2169
+ this._liveMessage = e, this._applyLiveMessage();
2170
+ }
2171
+ _cancelDrag(e) {
2172
+ this._dragState && (this._pendingDropTarget = null, this._setDropTargetVisualState(this._dragState.dropTarget, !1), this._clearPointerDragPreview(), this._items = this._dragState.snapshot.map($), this._dragState = null, this._pointerGesture = null, this._removeDragImage(), e && this._announce("Drag cancelled."), this._syncAttributesFromState(), this.requestRender());
2173
+ }
2174
+ _applyDragImage(e, r) {
2175
+ this._removeDragImage();
2176
+ const t = document.createElement("div");
2177
+ t.textContent = r === 1 ? "Dragging item" : `Dragging ${r} items`, t.style.position = "fixed", t.style.top = "-999px", t.style.left = "-999px", t.style.padding = "8px 12px", t.style.borderRadius = "999px", t.style.background = "rgba(15, 23, 42, 0.92)", t.style.color = "#f8fafc", t.style.font = "600 12px/1 Inter, sans-serif", t.style.pointerEvents = "none", document.body.appendChild(t), e.setDragImage(t, 12, 12), this._dragImage = t;
2178
+ }
2179
+ _removeDragImage() {
2180
+ var e;
2181
+ (e = this._dragImage) == null || e.remove(), this._dragImage = null;
2182
+ }
2183
+ _removeDragPreviewOverlay() {
2184
+ var e;
2185
+ (e = this._dragPreviewOverlay) == null || e.remove(), this._dragPreviewOverlay = null;
2186
+ }
2187
+ _applyPointerPreview(e, r, t, i) {
2188
+ this._removeDragImage();
2189
+ const s = document.createElement("div");
2190
+ s.textContent = i ? t === 1 ? "Copying item" : `Copying ${t} items` : t === 1 ? "Moving item" : `Moving ${t} items`, s.style.position = "fixed", s.style.top = "0", s.style.left = "0", s.style.zIndex = "2147483647", s.style.padding = "8px 12px", s.style.borderRadius = "999px", s.style.background = "rgba(15, 23, 42, 0.92)", s.style.color = "#f8fafc", s.style.font = "600 12px/1 Inter, sans-serif", s.style.pointerEvents = "none", s.style.boxShadow = "0 12px 28px rgba(15, 23, 42, 0.22)", document.body.appendChild(s), this._dragImage = s, this._movePointerPreview(e, r);
2191
+ }
2192
+ _movePointerPreview(e, r) {
2193
+ this._dragImage && (this._dragImage.style.transform = `translate(${Math.round(e + 14)}px, ${Math.round(r + 14)}px)`);
2194
+ }
2195
+ _keyboardDropTargets() {
2196
+ const e = T(this._items), r = E(this._items), t = [], i = (s, o) => {
2197
+ var l;
2198
+ (r.get(z(s, o)) || []).forEach((n) => {
2199
+ const d = e.get(n);
2200
+ !d || d.hidden || (t.push({
2201
+ listId: s,
2202
+ parentId: o,
2203
+ beforeId: n,
2204
+ mode: "before",
2205
+ label: `Before ${d.label}`
2206
+ }), this.getAttribute("allow-nesting") !== "false" && t.push({
2207
+ listId: s,
2208
+ parentId: n,
2209
+ beforeId: null,
2210
+ mode: "inside",
2211
+ label: `Nest inside ${d.label}`
2212
+ }), i(s, n));
2213
+ }), t.push({
2214
+ listId: s,
2215
+ parentId: o,
2216
+ beforeId: null,
2217
+ mode: "before",
2218
+ label: o ? "After children" : `End of ${((l = this._lists.find((n) => n.id === s)) == null ? void 0 : l.label) || s}`
2219
+ });
2220
+ };
2221
+ return this._lists.forEach((s) => i(s.id, null)), t.filter((s) => {
2222
+ var o;
2223
+ return this._canDrop(s, ((o = this._dragState) == null ? void 0 : o.movedRootIds) || []);
2224
+ });
2225
+ }
2226
+ _initialKeyboardDropTarget(e) {
2227
+ const r = this._items.find((t) => t.id === e);
2228
+ return r ? {
2229
+ listId: r.listId,
2230
+ parentId: r.parentId,
2231
+ beforeId: e,
2232
+ mode: "before"
2233
+ } : null;
2234
+ }
2235
+ _moveKeyboardDropTarget(e) {
2236
+ if (!this._dragState)
2237
+ return;
2238
+ const r = this._keyboardDropTargets();
2239
+ if (!r.length)
2240
+ return;
2241
+ const t = Math.max(0, r.findIndex(
2242
+ (s) => {
2243
+ var o, a, l, n, d, c, g, m;
2244
+ return s.listId === ((a = (o = this._dragState) == null ? void 0 : o.dropTarget) == null ? void 0 : a.listId) && s.parentId === ((n = (l = this._dragState) == null ? void 0 : l.dropTarget) == null ? void 0 : n.parentId) && s.beforeId === ((c = (d = this._dragState) == null ? void 0 : d.dropTarget) == null ? void 0 : c.beforeId) && s.mode === ((m = (g = this._dragState) == null ? void 0 : g.dropTarget) == null ? void 0 : m.mode);
2245
+ }
2246
+ )), i = Math.max(0, Math.min(r.length - 1, t + e));
2247
+ this._setDropTarget(r[i], { announceLabel: r[i].label });
2248
+ }
2249
+ }
2250
+ typeof customElements < "u" && !customElements.get("ui-sortable") && customElements.define("ui-sortable", ce);
2251
+ export {
2252
+ ee as E,
2253
+ ce as U
2254
+ };