@liwe3/webcomponents 1.0.14 → 1.1.10

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 (85) hide show
  1. package/dist/AIMarkdownEditor.d.ts +35 -0
  2. package/dist/AIMarkdownEditor.d.ts.map +1 -0
  3. package/dist/AIMarkdownEditor.js +412 -0
  4. package/dist/AIMarkdownEditor.js.map +1 -0
  5. package/dist/AITextEditor.d.ts +183 -0
  6. package/dist/AITextEditor.d.ts.map +1 -0
  7. package/dist/AITextEditor.js +63 -27
  8. package/dist/AITextEditor.js.map +1 -1
  9. package/dist/ButtonToolbar.d.ts +35 -0
  10. package/dist/ButtonToolbar.d.ts.map +1 -0
  11. package/dist/ButtonToolbar.js +220 -0
  12. package/dist/ButtonToolbar.js.map +1 -0
  13. package/dist/CheckList.d.ts +31 -0
  14. package/dist/CheckList.d.ts.map +1 -0
  15. package/dist/CheckList.js +336 -0
  16. package/dist/CheckList.js.map +1 -0
  17. package/dist/ChunkUploader.d.ts +125 -0
  18. package/dist/ChunkUploader.d.ts.map +1 -0
  19. package/dist/ChunkUploader.js +756 -0
  20. package/dist/ChunkUploader.js.map +1 -0
  21. package/dist/ComicBalloon.d.ts +82 -0
  22. package/dist/ComicBalloon.d.ts.map +1 -0
  23. package/dist/ComicBalloon.js +346 -0
  24. package/dist/ComicBalloon.js.map +1 -0
  25. package/dist/ContainerBox.d.ts +112 -0
  26. package/dist/ContainerBox.d.ts.map +1 -0
  27. package/dist/ContainerBox.js +359 -0
  28. package/dist/ContainerBox.js.map +1 -0
  29. package/dist/DateSelector.d.ts +103 -0
  30. package/dist/DateSelector.d.ts.map +1 -0
  31. package/dist/Dialog.d.ts +102 -0
  32. package/dist/Dialog.d.ts.map +1 -0
  33. package/dist/Dialog.js +299 -0
  34. package/dist/Dialog.js.map +1 -0
  35. package/dist/Drawer.d.ts +63 -0
  36. package/dist/Drawer.d.ts.map +1 -0
  37. package/dist/Drawer.js +340 -0
  38. package/dist/Drawer.js.map +1 -0
  39. package/dist/ImageView.d.ts +42 -0
  40. package/dist/ImageView.d.ts.map +1 -0
  41. package/dist/ImageView.js +209 -0
  42. package/dist/ImageView.js.map +1 -0
  43. package/dist/MarkdownPreview.d.ts +25 -0
  44. package/dist/MarkdownPreview.d.ts.map +1 -0
  45. package/dist/MarkdownPreview.js +147 -0
  46. package/dist/MarkdownPreview.js.map +1 -0
  47. package/dist/PopoverMenu.d.ts +103 -0
  48. package/dist/PopoverMenu.d.ts.map +1 -0
  49. package/dist/ResizableCropper.d.ts +158 -0
  50. package/dist/ResizableCropper.d.ts.map +1 -0
  51. package/dist/ResizableCropper.js +562 -0
  52. package/dist/ResizableCropper.js.map +1 -0
  53. package/dist/SmartSelect.d.ts +100 -0
  54. package/dist/SmartSelect.d.ts.map +1 -0
  55. package/dist/SmartSelect.js +45 -2
  56. package/dist/SmartSelect.js.map +1 -1
  57. package/dist/Toast.d.ts +127 -0
  58. package/dist/Toast.d.ts.map +1 -0
  59. package/dist/Toast.js +79 -49
  60. package/dist/Toast.js.map +1 -1
  61. package/dist/TreeView.d.ts +84 -0
  62. package/dist/TreeView.d.ts.map +1 -0
  63. package/dist/TreeView.js +478 -0
  64. package/dist/TreeView.js.map +1 -0
  65. package/dist/index.d.ts +23 -0
  66. package/dist/index.d.ts.map +1 -0
  67. package/dist/index.js +51 -14
  68. package/dist/index.js.map +1 -1
  69. package/package.json +60 -5
  70. package/src/AIMarkdownEditor.ts +568 -0
  71. package/src/AITextEditor.ts +97 -2
  72. package/src/ButtonToolbar.ts +302 -0
  73. package/src/CheckList.ts +438 -0
  74. package/src/ChunkUploader.ts +1135 -0
  75. package/src/ComicBalloon.ts +709 -0
  76. package/src/ContainerBox.ts +570 -0
  77. package/src/Dialog.ts +510 -0
  78. package/src/Drawer.ts +435 -0
  79. package/src/ImageView.ts +265 -0
  80. package/src/MarkdownPreview.ts +213 -0
  81. package/src/ResizableCropper.ts +1099 -0
  82. package/src/SmartSelect.ts +48 -2
  83. package/src/Toast.ts +96 -32
  84. package/src/TreeView.ts +673 -0
  85. package/src/index.ts +129 -27
@@ -0,0 +1,112 @@
1
+ /**
2
+ * ContainerBox Web Component
3
+ * A container that wraps elements and shows a menu on hover
4
+ */
5
+ import type { PopoverMenuItem } from './PopoverMenu';
6
+ export type MenuPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
7
+ export type ContainerBoxConfig = {
8
+ menuPosition?: MenuPosition;
9
+ menuItems?: PopoverMenuItem[];
10
+ alwaysShowMenu?: boolean;
11
+ };
12
+ export declare class ContainerBoxElement extends HTMLElement {
13
+ shadowRoot: ShadowRoot;
14
+ private menuPosition;
15
+ private menuItems;
16
+ private alwaysShowMenu;
17
+ private popoverMenu;
18
+ private menuButton;
19
+ constructor();
20
+ connectedCallback(): void;
21
+ disconnectedCallback(): void;
22
+ /**
23
+ * Set menu position
24
+ */
25
+ setMenuPosition(position: MenuPosition): void;
26
+ /**
27
+ * Get menu position
28
+ */
29
+ getMenuPosition(): MenuPosition;
30
+ /**
31
+ * Set menu items
32
+ */
33
+ setMenuItems(items: PopoverMenuItem[]): void;
34
+ /**
35
+ * Get menu items
36
+ */
37
+ getMenuItems(): PopoverMenuItem[];
38
+ /**
39
+ * Set whether menu button is always visible
40
+ */
41
+ setAlwaysShowMenu(value: boolean): void;
42
+ /**
43
+ * Get whether menu button is always visible
44
+ */
45
+ getAlwaysShowMenu(): boolean;
46
+ /**
47
+ * Render the component
48
+ */
49
+ private render;
50
+ /**
51
+ * Create the popover menu
52
+ */
53
+ private createPopoverMenu;
54
+ /**
55
+ * Update popover menu items
56
+ */
57
+ private updatePopoverMenu;
58
+ /**
59
+ * Render menu items recursively
60
+ */
61
+ private renderMenuItems;
62
+ /**
63
+ * Create and show the popover menu
64
+ */
65
+ private createAndShowPopover;
66
+ /**
67
+ * Attach event listeners to menu items
68
+ */
69
+ private attachMenuListeners;
70
+ /**
71
+ * Update menu button position
72
+ */
73
+ private updateMenuButtonPosition;
74
+ /**
75
+ * Update menu button visibility
76
+ */
77
+ private updateMenuButtonVisibility;
78
+ /**
79
+ * Setup event listeners
80
+ */
81
+ private setupEventListeners;
82
+ /**
83
+ * Cleanup event listeners
84
+ */
85
+ private cleanupEventListeners;
86
+ /**
87
+ * Handle menu button click
88
+ */
89
+ private handleMenuButtonClick;
90
+ /**
91
+ * Show the menu
92
+ */
93
+ private showMenu;
94
+ /**
95
+ * Hide the menu
96
+ */
97
+ private hideMenu;
98
+ /**
99
+ * Handle document click to close menu
100
+ */
101
+ private handleDocumentClick;
102
+ /**
103
+ * Handle content click - pass through to slotted elements
104
+ */
105
+ private handleContentClick;
106
+ }
107
+ /**
108
+ * Conditionally defines the custom element if in a browser environment.
109
+ */
110
+ declare const defineContainerBox: (tagName?: string) => void;
111
+ export { defineContainerBox };
112
+ //# sourceMappingURL=ContainerBox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContainerBox.d.ts","sourceRoot":"","sources":["../src/ContainerBox.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,WAAW,GAAG,aAAa,GAAG,cAAc,CAAC;AAErF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,SAAS,CAAC,EAAE,eAAe,EAAE,CAAC;IAC9B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,qBAAa,mBAAoB,SAAQ,WAAW;IAC1C,UAAU,EAAE,UAAU,CAAC;IAC/B,OAAO,CAAC,YAAY,CAA+B;IACnD,OAAO,CAAC,SAAS,CAAyB;IAC1C,OAAO,CAAC,cAAc,CAAkB;IACxC,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,UAAU,CAA4B;;IAO9C,iBAAiB,IAAI,IAAI;IAKzB,oBAAoB,IAAI,IAAI;IAI5B;;OAEG;IACH,eAAe,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI;IAK7C;;OAEG;IACH,eAAe,IAAI,YAAY;IAI/B;;OAEG;IACH,YAAY,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,IAAI;IAK5C;;OAEG;IACH,YAAY,IAAI,eAAe,EAAE;IAIjC;;OAEG;IACH,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAKvC;;OAEG;IACH,iBAAiB,IAAI,OAAO;IAI5B;;OAEG;IACH,OAAO,CAAC,MAAM;IAyGd;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAIzB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAIzB;;OAEG;IACH,OAAO,CAAC,eAAe;IAqBvB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA0E5B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAqE3B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAMhC;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAUlC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAY3B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAW7B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAa7B;;OAEG;IACH,OAAO,CAAC,QAAQ;IAwEhB;;OAEG;IACH,OAAO,CAAC,QAAQ;IAOhB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAQ3B;;OAEG;IACH,OAAO,CAAC,kBAAkB;CAY3B;AAED;;GAEG;AACH,QAAA,MAAM,kBAAkB,GAAI,gBAA+B,KAAG,IAI7D,CAAC;AAKF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,359 @@
1
+ class m extends HTMLElement {
2
+ constructor() {
3
+ super(), this.menuPosition = "bottom-left", this.menuItems = [], this.alwaysShowMenu = !1, this.popoverMenu = null, this.menuButton = null, this.attachShadow({ mode: "open" });
4
+ }
5
+ connectedCallback() {
6
+ this.render(), this.setupEventListeners();
7
+ }
8
+ disconnectedCallback() {
9
+ this.cleanupEventListeners();
10
+ }
11
+ /**
12
+ * Set menu position
13
+ */
14
+ setMenuPosition(e) {
15
+ this.menuPosition = e, this.updateMenuButtonPosition();
16
+ }
17
+ /**
18
+ * Get menu position
19
+ */
20
+ getMenuPosition() {
21
+ return this.menuPosition;
22
+ }
23
+ /**
24
+ * Set menu items
25
+ */
26
+ setMenuItems(e) {
27
+ this.menuItems = e, this.updatePopoverMenu();
28
+ }
29
+ /**
30
+ * Get menu items
31
+ */
32
+ getMenuItems() {
33
+ return this.menuItems;
34
+ }
35
+ /**
36
+ * Set whether menu button is always visible
37
+ */
38
+ setAlwaysShowMenu(e) {
39
+ this.alwaysShowMenu = e, this.updateMenuButtonVisibility();
40
+ }
41
+ /**
42
+ * Get whether menu button is always visible
43
+ */
44
+ getAlwaysShowMenu() {
45
+ return this.alwaysShowMenu;
46
+ }
47
+ /**
48
+ * Render the component
49
+ */
50
+ render() {
51
+ this.shadowRoot.innerHTML = `
52
+ <style>
53
+ :host {
54
+ display: block;
55
+ position: relative;
56
+ font-family: var(--font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
57
+ }
58
+
59
+ .container-box {
60
+ position: relative;
61
+ width: 100%;
62
+ height: 100%;
63
+ }
64
+
65
+ .content-wrapper {
66
+ width: 100%;
67
+ height: 100%;
68
+ }
69
+
70
+ .menu-button {
71
+ position: absolute;
72
+ background: var(--container-box-menu-bg, #fff);
73
+ border: 1px solid var(--container-box-menu-border, #ddd);
74
+ border-radius: var(--container-box-menu-radius, 4px);
75
+ padding: var(--container-box-menu-padding, 6px 10px);
76
+ cursor: pointer;
77
+ box-shadow: var(--container-box-menu-shadow, 0 2px 8px rgba(0,0,0,0.15));
78
+ z-index: 10;
79
+ opacity: 0;
80
+ transition: opacity 0.2s;
81
+ display: flex;
82
+ align-items: center;
83
+ gap: 4px;
84
+ font-size: 14px;
85
+ color: var(--container-box-menu-color, #333);
86
+ }
87
+
88
+ .menu-button:hover {
89
+ background: var(--container-box-menu-hover-bg, #f5f5f5);
90
+ }
91
+
92
+ .container-box:hover .menu-button {
93
+ opacity: 1;
94
+ }
95
+
96
+ .menu-button.always-visible {
97
+ opacity: 1;
98
+ }
99
+
100
+ .menu-button-icon {
101
+ width: 16px;
102
+ height: 16px;
103
+ display: flex;
104
+ align-items: center;
105
+ justify-content: center;
106
+ }
107
+
108
+ /* Position variants */
109
+ .menu-button.top-left {
110
+ top: var(--container-box-menu-offset, 8px);
111
+ left: var(--container-box-menu-offset, 8px);
112
+ }
113
+
114
+ .menu-button.top-right {
115
+ top: var(--container-box-menu-offset, 8px);
116
+ right: var(--container-box-menu-offset, 8px);
117
+ }
118
+
119
+ .menu-button.bottom-left {
120
+ bottom: var(--container-box-menu-offset, 8px);
121
+ left: var(--container-box-menu-offset, 8px);
122
+ }
123
+
124
+ .menu-button.bottom-right {
125
+ bottom: var(--container-box-menu-offset, 8px);
126
+ right: var(--container-box-menu-offset, 8px);
127
+ }
128
+
129
+ .popover-container {
130
+ position: fixed;
131
+ z-index: 10000;
132
+ pointer-events: none;
133
+ }
134
+
135
+ .popover-container > * {
136
+ pointer-events: auto;
137
+ }
138
+ </style>
139
+
140
+ <div class="container-box">
141
+ <div class="content-wrapper">
142
+ <slot></slot>
143
+ </div>
144
+ <div class="menu-button ${this.menuPosition} ${this.alwaysShowMenu ? "always-visible" : ""}">
145
+ <span class="menu-button-icon">⋮</span>
146
+ </div>
147
+ </div>
148
+ <div class="popover-container"></div>
149
+ `, this.menuButton = this.shadowRoot.querySelector(".menu-button"), this.createPopoverMenu();
150
+ }
151
+ /**
152
+ * Create the popover menu
153
+ */
154
+ createPopoverMenu() {
155
+ }
156
+ /**
157
+ * Update popover menu items
158
+ */
159
+ updatePopoverMenu() {
160
+ }
161
+ /**
162
+ * Render menu items recursively
163
+ */
164
+ renderMenuItems(e) {
165
+ return e.map((t) => {
166
+ if (t.label === "---sep")
167
+ return '<div class="menu-separator"></div>';
168
+ const o = t.items && t.items.length > 0;
169
+ return `
170
+ <div class="menu-item ${t.enabled === !1 ? "disabled" : ""} ${o ? "has-submenu" : ""}" data-has-submenu="${o}">
171
+ <span class="menu-item-label">${t.label}</span>
172
+ ${o ? '<span class="menu-item-arrow">▶</span>' : ""}
173
+ ${o ? `<div class="submenu">${this.renderMenuItems(t.items)}</div>` : ""}
174
+ </div>
175
+ `;
176
+ }).join("");
177
+ }
178
+ /**
179
+ * Create and show the popover menu
180
+ */
181
+ createAndShowPopover() {
182
+ const e = document.createElement("div");
183
+ return e.className = "custom-popover-menu", e.innerHTML = `
184
+ <style>
185
+ .custom-popover-menu {
186
+ position: fixed;
187
+ background: white;
188
+ border: 1px solid #ccc;
189
+ border-radius: 6px;
190
+ box-shadow: 0 4px 12px rgba(0,0,0,0.15);
191
+ min-width: 180px;
192
+ z-index: 10000;
193
+ }
194
+
195
+ .menu-item {
196
+ padding: 10px 16px;
197
+ cursor: pointer;
198
+ display: flex;
199
+ align-items: center;
200
+ justify-content: space-between;
201
+ transition: background-color 0.2s;
202
+ position: relative;
203
+ font-size: 14px;
204
+ color: #333;
205
+ }
206
+
207
+ .menu-item:hover {
208
+ background: #f5f5f5;
209
+ }
210
+
211
+ .menu-item.disabled {
212
+ opacity: 0.5;
213
+ cursor: not-allowed;
214
+ pointer-events: none;
215
+ }
216
+
217
+ .menu-item.has-submenu:hover .submenu {
218
+ display: block;
219
+ }
220
+
221
+ .menu-item-label {
222
+ flex: 1;
223
+ }
224
+
225
+ .menu-item-arrow {
226
+ margin-left: 12px;
227
+ font-size: 10px;
228
+ color: #666;
229
+ }
230
+
231
+ .menu-separator {
232
+ height: 1px;
233
+ background: #e0e0e0;
234
+ margin: 4px 8px;
235
+ }
236
+
237
+ .submenu {
238
+ display: none;
239
+ position: fixed;
240
+ background: white;
241
+ border: 1px solid #ccc;
242
+ border-radius: 6px;
243
+ box-shadow: 0 4px 12px rgba(0,0,0,0.15);
244
+ min-width: 180px;
245
+ z-index: 10001;
246
+ }
247
+ </style>
248
+ ${this.renderMenuItems(this.menuItems)}
249
+ `, e;
250
+ }
251
+ /**
252
+ * Attach event listeners to menu items
253
+ */
254
+ attachMenuListeners(e, t) {
255
+ e.querySelectorAll(".menu-item:not(.has-submenu)").forEach((r, a) => {
256
+ let l = 0;
257
+ const s = ((u) => {
258
+ for (const c of u)
259
+ if (c.label !== "---sep" && !(c.items && c.items.length > 0)) {
260
+ if (l === a) return c;
261
+ l++;
262
+ }
263
+ return null;
264
+ })(t);
265
+ s && s.onclick && r.addEventListener("click", (u) => {
266
+ u.stopPropagation(), s.onclick(), this.hideMenu();
267
+ });
268
+ });
269
+ const n = this.getBoundingClientRect();
270
+ e.querySelectorAll(".menu-item.has-submenu").forEach((r) => {
271
+ r.addEventListener("mouseenter", () => {
272
+ const a = r.querySelector(".submenu");
273
+ if (a) {
274
+ const l = r.getBoundingClientRect(), p = a.getBoundingClientRect();
275
+ let s = l.right + 5, u = l.top;
276
+ s + p.width > n.right && (s = l.left - p.width - 5, s < n.left && (s = n.left)), u + p.height > n.bottom && (u = n.bottom - p.height, u < n.top && (u = n.top)), a.style.left = `${s}px`, a.style.top = `${u}px`;
277
+ }
278
+ });
279
+ });
280
+ }
281
+ /**
282
+ * Update menu button position
283
+ */
284
+ updateMenuButtonPosition() {
285
+ this.menuButton && (this.menuButton.className = `menu-button ${this.menuPosition} ${this.alwaysShowMenu ? "always-visible" : ""}`);
286
+ }
287
+ /**
288
+ * Update menu button visibility
289
+ */
290
+ updateMenuButtonVisibility() {
291
+ this.menuButton && (this.alwaysShowMenu ? this.menuButton.classList.add("always-visible") : this.menuButton.classList.remove("always-visible"));
292
+ }
293
+ /**
294
+ * Setup event listeners
295
+ */
296
+ setupEventListeners() {
297
+ this.menuButton && this.menuButton.addEventListener("click", this.handleMenuButtonClick.bind(this));
298
+ const e = this.shadowRoot.querySelector(".content-wrapper");
299
+ e && e.addEventListener("click", this.handleContentClick.bind(this));
300
+ }
301
+ /**
302
+ * Cleanup event listeners
303
+ */
304
+ cleanupEventListeners() {
305
+ this.menuButton && this.menuButton.removeEventListener("click", this.handleMenuButtonClick.bind(this));
306
+ const e = this.shadowRoot.querySelector(".content-wrapper");
307
+ e && e.removeEventListener("click", this.handleContentClick.bind(this));
308
+ }
309
+ /**
310
+ * Handle menu button click
311
+ */
312
+ handleMenuButtonClick(e) {
313
+ e.stopPropagation(), this.menuButton && (this.popoverMenu ? this.hideMenu() : this.showMenu());
314
+ }
315
+ /**
316
+ * Show the menu
317
+ */
318
+ showMenu() {
319
+ if (!this.menuButton || this.menuItems.length === 0) return;
320
+ this.popoverMenu && this.popoverMenu.remove(), this.popoverMenu = this.createAndShowPopover(), document.body.appendChild(this.popoverMenu);
321
+ const e = this.menuButton.getBoundingClientRect(), t = this.getBoundingClientRect();
322
+ this.popoverMenu.style.left = `${e.left}px`, this.popoverMenu.style.top = `${e.bottom + 4}px`, requestAnimationFrame(() => {
323
+ const o = this.popoverMenu.getBoundingClientRect();
324
+ let n = e.left, i = e.bottom + 4;
325
+ n + o.width > t.right && (n = t.right - o.width, n < t.left && (n = t.left)), n < t.left && (n = t.left), i + o.height > t.bottom && (i = e.top - o.height - 4, i < t.top && (i = t.top)), i < t.top && (i = t.top), this.popoverMenu.style.left = `${n}px`, this.popoverMenu.style.top = `${i}px`;
326
+ }), this.attachMenuListeners(this.popoverMenu, this.menuItems), setTimeout(() => {
327
+ document.addEventListener("click", this.handleDocumentClick.bind(this), { once: !0 });
328
+ }, 0);
329
+ }
330
+ /**
331
+ * Hide the menu
332
+ */
333
+ hideMenu() {
334
+ this.popoverMenu && (this.popoverMenu.remove(), this.popoverMenu = null);
335
+ }
336
+ /**
337
+ * Handle document click to close menu
338
+ */
339
+ handleDocumentClick(e) {
340
+ const t = e.target, o = this.popoverMenu;
341
+ o && !o.contains(t) && !this.menuButton?.contains(t) && this.hideMenu();
342
+ }
343
+ /**
344
+ * Handle content click - pass through to slotted elements
345
+ */
346
+ handleContentClick(e) {
347
+ const t = this.shadowRoot.querySelector("slot");
348
+ !t || t.assignedElements().length === 0 || e.stopPropagation();
349
+ }
350
+ }
351
+ const d = (h = "liwe3-container-box") => {
352
+ typeof window < "u" && !window.customElements.get(h) && customElements.define(h, m);
353
+ };
354
+ d();
355
+ export {
356
+ m as ContainerBoxElement,
357
+ d as defineContainerBox
358
+ };
359
+ //# sourceMappingURL=ContainerBox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContainerBox.js","sources":["../src/ContainerBox.ts"],"sourcesContent":["/**\n * ContainerBox Web Component\n * A container that wraps elements and shows a menu on hover\n */\n\nimport type { PopoverMenuItem } from './PopoverMenu';\n\nexport type MenuPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';\n\nexport type ContainerBoxConfig = {\n menuPosition?: MenuPosition;\n menuItems?: PopoverMenuItem[];\n alwaysShowMenu?: boolean;\n};\n\nexport class ContainerBoxElement extends HTMLElement {\n declare shadowRoot: ShadowRoot;\n private menuPosition: MenuPosition = 'bottom-left';\n private menuItems: PopoverMenuItem[] = [];\n private alwaysShowMenu: boolean = false;\n private popoverMenu: HTMLElement | null = null;\n private menuButton: HTMLElement | null = null;\n\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n }\n\n connectedCallback(): void {\n this.render();\n this.setupEventListeners();\n }\n\n disconnectedCallback(): void {\n this.cleanupEventListeners();\n }\n\n /**\n * Set menu position\n */\n setMenuPosition(position: MenuPosition): void {\n this.menuPosition = position;\n this.updateMenuButtonPosition();\n }\n\n /**\n * Get menu position\n */\n getMenuPosition(): MenuPosition {\n return this.menuPosition;\n }\n\n /**\n * Set menu items\n */\n setMenuItems(items: PopoverMenuItem[]): void {\n this.menuItems = items;\n this.updatePopoverMenu();\n }\n\n /**\n * Get menu items\n */\n getMenuItems(): PopoverMenuItem[] {\n return this.menuItems;\n }\n\n /**\n * Set whether menu button is always visible\n */\n setAlwaysShowMenu(value: boolean): void {\n this.alwaysShowMenu = value;\n this.updateMenuButtonVisibility();\n }\n\n /**\n * Get whether menu button is always visible\n */\n getAlwaysShowMenu(): boolean {\n return this.alwaysShowMenu;\n }\n\n /**\n * Render the component\n */\n private render(): void {\n this.shadowRoot.innerHTML = `\n <style>\n :host {\n display: block;\n position: relative;\n font-family: var(--font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);\n }\n\n .container-box {\n position: relative;\n width: 100%;\n height: 100%;\n }\n\n .content-wrapper {\n width: 100%;\n height: 100%;\n }\n\n .menu-button {\n position: absolute;\n background: var(--container-box-menu-bg, #fff);\n border: 1px solid var(--container-box-menu-border, #ddd);\n border-radius: var(--container-box-menu-radius, 4px);\n padding: var(--container-box-menu-padding, 6px 10px);\n cursor: pointer;\n box-shadow: var(--container-box-menu-shadow, 0 2px 8px rgba(0,0,0,0.15));\n z-index: 10;\n opacity: 0;\n transition: opacity 0.2s;\n display: flex;\n align-items: center;\n gap: 4px;\n font-size: 14px;\n color: var(--container-box-menu-color, #333);\n }\n\n .menu-button:hover {\n background: var(--container-box-menu-hover-bg, #f5f5f5);\n }\n\n .container-box:hover .menu-button {\n opacity: 1;\n }\n\n .menu-button.always-visible {\n opacity: 1;\n }\n\n .menu-button-icon {\n width: 16px;\n height: 16px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n /* Position variants */\n .menu-button.top-left {\n top: var(--container-box-menu-offset, 8px);\n left: var(--container-box-menu-offset, 8px);\n }\n\n .menu-button.top-right {\n top: var(--container-box-menu-offset, 8px);\n right: var(--container-box-menu-offset, 8px);\n }\n\n .menu-button.bottom-left {\n bottom: var(--container-box-menu-offset, 8px);\n left: var(--container-box-menu-offset, 8px);\n }\n\n .menu-button.bottom-right {\n bottom: var(--container-box-menu-offset, 8px);\n right: var(--container-box-menu-offset, 8px);\n }\n\n .popover-container {\n position: fixed;\n z-index: 10000;\n pointer-events: none;\n }\n\n .popover-container > * {\n pointer-events: auto;\n }\n </style>\n\n <div class=\"container-box\">\n <div class=\"content-wrapper\">\n <slot></slot>\n </div>\n <div class=\"menu-button ${this.menuPosition} ${this.alwaysShowMenu ? 'always-visible' : ''}\">\n <span class=\"menu-button-icon\">⋮</span>\n </div>\n </div>\n <div class=\"popover-container\"></div>\n `;\n\n this.menuButton = this.shadowRoot.querySelector('.menu-button');\n this.createPopoverMenu();\n }\n\n /**\n * Create the popover menu\n */\n private createPopoverMenu(): void {\n // We'll create the popover dynamically when needed\n }\n\n /**\n * Update popover menu items\n */\n private updatePopoverMenu(): void {\n // Menu items are stored and used when showing the menu\n }\n\n /**\n * Render menu items recursively\n */\n private renderMenuItems(items: PopoverMenuItem[]): string {\n return items.map(item => {\n if (item.label === '---sep') {\n return '<div class=\"menu-separator\"></div>';\n }\n\n const hasSubmenu = item.items && item.items.length > 0;\n const isDisabled = item.enabled === false;\n const disabledClass = isDisabled ? 'disabled' : '';\n const submenuClass = hasSubmenu ? 'has-submenu' : '';\n\n return `\n <div class=\"menu-item ${disabledClass} ${submenuClass}\" data-has-submenu=\"${hasSubmenu}\">\n <span class=\"menu-item-label\">${item.label}</span>\n ${hasSubmenu ? '<span class=\"menu-item-arrow\">▶</span>' : ''}\n ${hasSubmenu ? `<div class=\"submenu\">${this.renderMenuItems(item.items!)}</div>` : ''}\n </div>\n `;\n }).join('');\n }\n\n /**\n * Create and show the popover menu\n */\n private createAndShowPopover(): HTMLElement {\n const popover = document.createElement('div');\n popover.className = 'custom-popover-menu';\n popover.innerHTML = `\n <style>\n .custom-popover-menu {\n position: fixed;\n background: white;\n border: 1px solid #ccc;\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0,0,0,0.15);\n min-width: 180px;\n z-index: 10000;\n }\n\n .menu-item {\n padding: 10px 16px;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: space-between;\n transition: background-color 0.2s;\n position: relative;\n font-size: 14px;\n color: #333;\n }\n\n .menu-item:hover {\n background: #f5f5f5;\n }\n\n .menu-item.disabled {\n opacity: 0.5;\n cursor: not-allowed;\n pointer-events: none;\n }\n\n .menu-item.has-submenu:hover .submenu {\n display: block;\n }\n\n .menu-item-label {\n flex: 1;\n }\n\n .menu-item-arrow {\n margin-left: 12px;\n font-size: 10px;\n color: #666;\n }\n\n .menu-separator {\n height: 1px;\n background: #e0e0e0;\n margin: 4px 8px;\n }\n\n .submenu {\n display: none;\n position: fixed;\n background: white;\n border: 1px solid #ccc;\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0,0,0,0.15);\n min-width: 180px;\n z-index: 10001;\n }\n </style>\n ${this.renderMenuItems(this.menuItems)}\n `;\n\n return popover;\n }\n\n /**\n * Attach event listeners to menu items\n */\n private attachMenuListeners(popover: HTMLElement, items: PopoverMenuItem[]): void {\n const menuItems = popover.querySelectorAll('.menu-item:not(.has-submenu)');\n \n menuItems.forEach((element, index) => {\n let flatIndex = 0;\n const findItem = (items: PopoverMenuItem[]): PopoverMenuItem | null => {\n for (const item of items) {\n if (item.label === '---sep') continue;\n if (!(item.items && item.items.length > 0)) {\n if (flatIndex === index) return item;\n flatIndex++;\n }\n }\n return null;\n };\n\n const item = findItem(items);\n if (item && item.onclick) {\n element.addEventListener('click', (e) => {\n e.stopPropagation();\n item.onclick!();\n this.hideMenu();\n });\n }\n });\n\n // Handle submenu positioning within container boundaries\n const containerRect = this.getBoundingClientRect();\n const submenuItems = popover.querySelectorAll('.menu-item.has-submenu');\n \n submenuItems.forEach(element => {\n element.addEventListener('mouseenter', () => {\n const submenu = element.querySelector('.submenu') as HTMLElement;\n if (submenu) {\n const rect = element.getBoundingClientRect();\n const submenuRect = submenu.getBoundingClientRect();\n \n let left = rect.right + 5;\n let top = rect.top;\n \n // Check if submenu would overflow container on the right\n if (left + submenuRect.width > containerRect.right) {\n // Try positioning to the left of the parent item\n left = rect.left - submenuRect.width - 5;\n \n // If still overflowing left, position at container left edge\n if (left < containerRect.left) {\n left = containerRect.left;\n }\n }\n \n // Check if submenu would overflow container at the bottom\n if (top + submenuRect.height > containerRect.bottom) {\n // Align bottom of submenu with bottom of container\n top = containerRect.bottom - submenuRect.height;\n \n // If still overflowing at top, position at container top\n if (top < containerRect.top) {\n top = containerRect.top;\n }\n }\n \n submenu.style.left = `${left}px`;\n submenu.style.top = `${top}px`;\n }\n });\n });\n }\n\n /**\n * Update menu button position\n */\n private updateMenuButtonPosition(): void {\n if (!this.menuButton) return;\n\n this.menuButton.className = `menu-button ${this.menuPosition} ${this.alwaysShowMenu ? 'always-visible' : ''}`;\n }\n\n /**\n * Update menu button visibility\n */\n private updateMenuButtonVisibility(): void {\n if (!this.menuButton) return;\n\n if (this.alwaysShowMenu) {\n this.menuButton.classList.add('always-visible');\n } else {\n this.menuButton.classList.remove('always-visible');\n }\n }\n\n /**\n * Setup event listeners\n */\n private setupEventListeners(): void {\n if (this.menuButton) {\n this.menuButton.addEventListener('click', this.handleMenuButtonClick.bind(this));\n }\n\n // Allow clicks to pass through to slotted content\n const contentWrapper = this.shadowRoot.querySelector('.content-wrapper');\n if (contentWrapper) {\n contentWrapper.addEventListener('click', this.handleContentClick.bind(this));\n }\n }\n\n /**\n * Cleanup event listeners\n */\n private cleanupEventListeners(): void {\n if (this.menuButton) {\n this.menuButton.removeEventListener('click', this.handleMenuButtonClick.bind(this));\n }\n\n const contentWrapper = this.shadowRoot.querySelector('.content-wrapper');\n if (contentWrapper) {\n contentWrapper.removeEventListener('click', this.handleContentClick.bind(this));\n }\n }\n\n /**\n * Handle menu button click\n */\n private handleMenuButtonClick(e: Event): void {\n e.stopPropagation();\n\n if (!this.menuButton) return;\n\n // Toggle menu visibility\n if (this.popoverMenu) {\n this.hideMenu();\n } else {\n this.showMenu();\n }\n }\n\n /**\n * Show the menu\n */\n private showMenu(): void {\n if (!this.menuButton || this.menuItems.length === 0) return;\n\n // Create the popover\n if (this.popoverMenu) {\n this.popoverMenu.remove();\n }\n\n this.popoverMenu = this.createAndShowPopover() as any;\n document.body.appendChild(this.popoverMenu as any);\n\n // Get button and container bounds\n const buttonRect = this.menuButton.getBoundingClientRect();\n const containerRect = this.getBoundingClientRect();\n \n // Temporarily position to measure\n (this.popoverMenu as any).style.left = `${buttonRect.left}px`;\n (this.popoverMenu as any).style.top = `${buttonRect.bottom + 4}px`;\n \n // Wait for next frame to get accurate measurements\n requestAnimationFrame(() => {\n const menuRect = (this.popoverMenu as any).getBoundingClientRect();\n \n let left = buttonRect.left;\n let top = buttonRect.bottom + 4;\n \n // Check if menu would overflow container on the right\n if (left + menuRect.width > containerRect.right) {\n // Try to align right edge of menu with right edge of container\n left = containerRect.right - menuRect.width;\n \n // If still overflowing left, align with left edge of container\n if (left < containerRect.left) {\n left = containerRect.left;\n }\n }\n \n // Check if menu would overflow container on the left\n if (left < containerRect.left) {\n left = containerRect.left;\n }\n \n // Check if menu would overflow container at the bottom\n if (top + menuRect.height > containerRect.bottom) {\n // Try positioning above the button\n top = buttonRect.top - menuRect.height - 4;\n \n // If still overflowing at top, position at container top\n if (top < containerRect.top) {\n top = containerRect.top;\n }\n }\n \n // Check if menu would overflow container at the top\n if (top < containerRect.top) {\n top = containerRect.top;\n }\n \n // Apply final position\n (this.popoverMenu as any).style.left = `${left}px`;\n (this.popoverMenu as any).style.top = `${top}px`;\n });\n\n // Attach event listeners\n this.attachMenuListeners(this.popoverMenu as any, this.menuItems);\n\n // Add click listener to close menu when clicking outside\n setTimeout(() => {\n document.addEventListener('click', this.handleDocumentClick.bind(this), { once: true });\n }, 0);\n }\n\n /**\n * Hide the menu\n */\n private hideMenu(): void {\n if (this.popoverMenu) {\n (this.popoverMenu as any).remove();\n this.popoverMenu = null;\n }\n }\n\n /**\n * Handle document click to close menu\n */\n private handleDocumentClick(e: Event): void {\n const target = e.target as Node;\n const popoverElement = this.popoverMenu as any;\n if (popoverElement && !popoverElement.contains(target) && !this.menuButton?.contains(target)) {\n this.hideMenu();\n }\n }\n\n /**\n * Handle content click - pass through to slotted elements\n */\n private handleContentClick(e: Event): void {\n // Get the slotted elements\n const slot = this.shadowRoot.querySelector('slot');\n if (!slot) return;\n\n const assignedElements = slot.assignedElements();\n if (assignedElements.length === 0) return;\n\n // The click naturally propagates to slotted content\n // We just need to ensure it doesn't trigger the menu\n e.stopPropagation();\n }\n}\n\n/**\n * Conditionally defines the custom element if in a browser environment.\n */\nconst defineContainerBox = (tagName = 'liwe3-container-box'): void => {\n if (typeof window !== 'undefined' && !window.customElements.get(tagName)) {\n customElements.define(tagName, ContainerBoxElement);\n }\n};\n\n// Auto-register with default tag name\ndefineContainerBox();\n\nexport { defineContainerBox };\n"],"names":["ContainerBoxElement","position","items","value","item","hasSubmenu","popover","element","index","flatIndex","e","containerRect","submenu","rect","submenuRect","left","top","contentWrapper","buttonRect","menuRect","target","popoverElement","slot","defineContainerBox","tagName"],"mappings":"AAeO,MAAMA,UAA4B,YAAY;AAAA,EAQnD,cAAc;AACZ,UAAA,GAPF,KAAQ,eAA6B,eACrC,KAAQ,YAA+B,CAAA,GACvC,KAAQ,iBAA0B,IAClC,KAAQ,cAAkC,MAC1C,KAAQ,aAAiC,MAIvC,KAAK,aAAa,EAAE,MAAM,OAAA,CAAQ;AAAA,EACpC;AAAA,EAEA,oBAA0B;AACxB,SAAK,OAAA,GACL,KAAK,oBAAA;AAAA,EACP;AAAA,EAEA,uBAA6B;AAC3B,SAAK,sBAAA;AAAA,EACP;AAAA;AAAA;AAAA;AAAA,EAKA,gBAAgBC,GAA8B;AAC5C,SAAK,eAAeA,GACpB,KAAK,yBAAA;AAAA,EACP;AAAA;AAAA;AAAA;AAAA,EAKA,kBAAgC;AAC9B,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,aAAaC,GAAgC;AAC3C,SAAK,YAAYA,GACjB,KAAK,kBAAA;AAAA,EACP;AAAA;AAAA;AAAA;AAAA,EAKA,eAAkC;AAChC,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,kBAAkBC,GAAsB;AACtC,SAAK,iBAAiBA,GACtB,KAAK,2BAAA;AAAA,EACP;AAAA;AAAA;AAAA;AAAA,EAKA,oBAA6B;AAC3B,WAA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AKpBK,IAAML,EAAc,QACtBK,IAAML,EAAc,MAIrB,KAAK,YAAoB,MAAM,OAAO,GAAGI,CAAI,MAC7C,KAAK,YAAoB,MAAM,MAAM,GAAGC,CAAG;AAAA,IAC9C,CAAC,GAGD,KAAK,oBAAoB,KAAK,aAAoB,KAAK,SAAS,GAGhE,WAAW,MAAM;AACf,eAAS,iBAAiB,SAAS,KAAK,oBAAoB,KAAK,IAAI,GAAG,EAAE,MAAM,IAAM;AAAA,IACxF,GAAG,CAAC;AAAA,EACN;AAAA;AAAA;AAAA;AAAA,EAKQ,WAAiB;AACvB,IAAI,KAAK,gBACN,KAAK,YAAoB,OAAA,GAC1B,KAAK,cAAc;AAAA,EAEvB;AAAA;AAAA;AAAA;AAAA,EAKQ,oBAAoB,GAAgB;AAC1C,UAAMI,IAAS,EAAE,QACXC,IAAiB,KAAK;AAC5B,IAAIA,KAAkB,CAACA,EAAe,SAASD,CAAM,KAAK,CAAC,KAAK,YAAY,SAASA,CAAM,KACzF,KAAK,SAAA;AAAA,EAET;AAAA;AAAA;AAAA;AAAA,EAKQ,mBAAmB,GAAgB;AAEzC,UAAME,IAAO,KAAK,WAAW,cAAc,MAAM;AAIjD,IAHI,CAACA,KAEoBA,EAAK,iBAAA,EACT,WAAW,KAIhC,EAAE,gBAAA;AAAA,EACJ;AACF;AAKA,MAAMC,IAAqB,CAACC,IAAU,0BAAgC;AACpE,EAAI,OAAO,SAAW,OAAe,CAAC,OAAO,eAAe,IAAIA,CAAO,KACrE,eAAe,OAAOA,GAASxB,CAAmB;AAEtD;AAGAuB,EAAA;"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * DateSelector Web Component
3
+ * A customizable date picker with single date and range selection modes
4
+ */
5
+ export type DateRange = {
6
+ start: string | null;
7
+ end: string | null;
8
+ };
9
+ export declare class DateSelectorElement extends HTMLElement {
10
+ shadowRoot: ShadowRoot;
11
+ private currentDate;
12
+ private selectedDate;
13
+ private selectedRange;
14
+ private readonly MONTH_NAMES;
15
+ private readonly DAY_NAMES;
16
+ constructor();
17
+ static get observedAttributes(): string[];
18
+ attributeChangedCallback(name: string): void;
19
+ get rangeMode(): boolean;
20
+ set rangeMode(value: boolean);
21
+ /**
22
+ * Renders the date selector component
23
+ */
24
+ private render;
25
+ /**
26
+ * Generates year options for the dropdown (current year ±10 years)
27
+ */
28
+ private generateYearOptions;
29
+ /**
30
+ * Generates the calendar grid with day headers and day cells
31
+ */
32
+ private generateCalendarGrid;
33
+ /**
34
+ * Checks if two date strings match
35
+ */
36
+ private dateMatches;
37
+ /**
38
+ * Checks if a date is within the selected range
39
+ */
40
+ private isDateInRange;
41
+ /**
42
+ * Attaches main event listeners (called once during construction)
43
+ */
44
+ private attachEventListeners;
45
+ /**
46
+ * Called after each render to setup any post-render event listeners
47
+ */
48
+ private attachEventListenersToShadowRoot;
49
+ /**
50
+ * Navigates to the previous or next month
51
+ */
52
+ private navigateMonth;
53
+ /**
54
+ * Navigates to a specific year
55
+ */
56
+ private navigateToYear;
57
+ /**
58
+ * Handles click on a day cell
59
+ */
60
+ private handleDayClick;
61
+ /**
62
+ * Handles single date selection
63
+ */
64
+ private handleSingleSelection;
65
+ /**
66
+ * Handles range selection
67
+ */
68
+ private handleRangeSelection;
69
+ /**
70
+ * Updates hover effect when selecting a range
71
+ */
72
+ private updateRangeHover;
73
+ /**
74
+ * Clears the hover effect for range selection
75
+ */
76
+ private clearRangeHover;
77
+ /**
78
+ * Sets the selected date programmatically (single date mode only)
79
+ */
80
+ setDate(dateStr: string): void;
81
+ /**
82
+ * Sets the selected range programmatically (range mode only)
83
+ */
84
+ setRange(startDate: string, endDate: string): void;
85
+ /**
86
+ * Gets the currently selected date
87
+ */
88
+ getSelectedDate(): string | null;
89
+ /**
90
+ * Gets the currently selected range
91
+ */
92
+ getSelectedRange(): DateRange;
93
+ /**
94
+ * Clears the current selection
95
+ */
96
+ clear(): void;
97
+ }
98
+ /**
99
+ * Conditionally defines the custom element if in a browser environment.
100
+ */
101
+ declare const defineDateSelector: (tagName?: string) => void;
102
+ export { defineDateSelector };
103
+ //# sourceMappingURL=DateSelector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateSelector.d.ts","sourceRoot":"","sources":["../src/DateSelector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB,CAAC;AAEF,qBAAa,mBAAoB,SAAQ,WAAW;IAC1C,UAAU,EAAE,UAAU,CAAC;IAC/B,OAAO,CAAC,WAAW,CAAoB;IACvC,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,aAAa,CAAyC;IAG9D,OAAO,CAAC,QAAQ,CAAC,WAAW,CAG1B;IAEF,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA+D;;IASzF,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAQ5C,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,IAAI,SAAS,CAAC,KAAK,EAAE,OAAO,EAM3B;IAED;;OAEG;IACH,OAAO,CAAC,MAAM;IAsKd;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAa3B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAkE5B;;OAEG;IACH,OAAO,CAAC,WAAW;IAInB;;OAEG;IACH,OAAO,CAAC,aAAa;IAUrB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAoC5B;;OAEG;IACH,OAAO,CAAC,gCAAgC;IAKxC;;OAEG;IACH,OAAO,CAAC,aAAa;IAiBrB;;OAEG;IACH,OAAO,CAAC,cAAc;IAKtB;;OAEG;IACH,OAAO,CAAC,cAAc;IAYtB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAU7B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA2B5B;;OAEG;IACH,OA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