@samtv12345/etherpad-webcomponents 0.0.0 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +173 -0
- package/dist/EpButton.d.ts +17 -0
- package/dist/EpButton.d.ts.map +1 -0
- package/dist/EpButton.js +168 -0
- package/dist/EpButton.js.map +1 -0
- package/dist/EpCard.d.ts +15 -0
- package/dist/EpCard.d.ts.map +1 -0
- package/dist/EpCard.js +126 -0
- package/dist/EpCard.js.map +1 -0
- package/dist/EpChatMessage.d.ts +15 -0
- package/dist/EpChatMessage.d.ts.map +1 -0
- package/dist/EpChatMessage.js +75 -0
- package/dist/EpChatMessage.js.map +1 -0
- package/dist/EpCheckbox.d.ts +16 -0
- package/dist/EpCheckbox.d.ts.map +1 -0
- package/dist/EpCheckbox.js +154 -0
- package/dist/EpCheckbox.js.map +1 -0
- package/dist/EpColorPicker.d.ts +16 -0
- package/dist/EpColorPicker.d.ts.map +1 -0
- package/dist/EpColorPicker.js +191 -0
- package/dist/EpColorPicker.js.map +1 -0
- package/dist/EpColorWheel.d.ts +61 -0
- package/dist/EpColorWheel.d.ts.map +1 -0
- package/dist/EpColorWheel.js +428 -0
- package/dist/EpColorWheel.js.map +1 -0
- package/dist/EpDropdown.d.ts +44 -0
- package/dist/EpDropdown.d.ts.map +1 -0
- package/dist/EpDropdown.js +298 -0
- package/dist/EpDropdown.js.map +1 -0
- package/dist/EpDropdownItem.d.ts +16 -0
- package/dist/EpDropdownItem.d.ts.map +1 -0
- package/dist/EpDropdownItem.js +88 -0
- package/dist/EpDropdownItem.js.map +1 -0
- package/dist/EpEditor.d.ts +108 -0
- package/dist/EpEditor.d.ts.map +1 -0
- package/dist/EpEditor.js +277 -0
- package/dist/EpEditor.js.map +1 -0
- package/dist/EpInput.d.ts +20 -0
- package/dist/EpInput.d.ts.map +1 -0
- package/dist/EpInput.js +154 -0
- package/dist/EpInput.js.map +1 -0
- package/dist/EpModal.d.ts +45 -0
- package/dist/EpModal.d.ts.map +1 -0
- package/dist/EpModal.js +212 -0
- package/dist/EpModal.js.map +1 -0
- package/dist/EpNotification.d.ts +32 -0
- package/dist/EpNotification.d.ts.map +1 -0
- package/dist/EpNotification.js +215 -0
- package/dist/EpNotification.js.map +1 -0
- package/dist/EpSelect.d.ts +38 -0
- package/dist/EpSelect.d.ts.map +1 -0
- package/dist/EpSelect.js +270 -0
- package/dist/EpSelect.js.map +1 -0
- package/dist/EpTabs.d.ts +64 -0
- package/dist/EpTabs.d.ts.map +1 -0
- package/dist/EpTabs.js +296 -0
- package/dist/EpTabs.js.map +1 -0
- package/dist/EpTheme.d.ts +40 -0
- package/dist/EpTheme.d.ts.map +1 -0
- package/dist/EpTheme.js +136 -0
- package/dist/EpTheme.js.map +1 -0
- package/dist/EpToast.d.ts +37 -0
- package/dist/EpToast.d.ts.map +1 -0
- package/dist/EpToast.js +220 -0
- package/dist/EpToast.js.map +1 -0
- package/dist/EpToolbarSelect.d.ts +24 -0
- package/dist/EpToolbarSelect.d.ts.map +1 -0
- package/dist/EpToolbarSelect.js +138 -0
- package/dist/EpToolbarSelect.js.map +1 -0
- package/dist/EpUserBadge.d.ts +15 -0
- package/dist/EpUserBadge.d.ts.map +1 -0
- package/dist/EpUserBadge.js +90 -0
- package/dist/EpUserBadge.js.map +1 -0
- package/dist/collab/clientMessage.d.ts +102 -0
- package/dist/collab/clientMessage.d.ts.map +1 -0
- package/dist/collab/clientMessage.js +132 -0
- package/dist/collab/clientMessage.js.map +1 -0
- package/dist/editor/AceEditor.d.ts +205 -0
- package/dist/editor/AceEditor.d.ts.map +1 -0
- package/dist/editor/AceEditor.js +2879 -0
- package/dist/editor/AceEditor.js.map +1 -0
- package/dist/editor/AttributeManager.d.ts +25 -0
- package/dist/editor/AttributeManager.d.ts.map +1 -0
- package/dist/editor/AttributeManager.js +236 -0
- package/dist/editor/AttributeManager.js.map +1 -0
- package/dist/editor/AttributeMap.d.ts +13 -0
- package/dist/editor/AttributeMap.d.ts.map +1 -0
- package/dist/editor/AttributeMap.js +37 -0
- package/dist/editor/AttributeMap.js.map +1 -0
- package/dist/editor/AttributePool.d.ts +22 -0
- package/dist/editor/AttributePool.d.ts.map +1 -0
- package/dist/editor/AttributePool.js +101 -0
- package/dist/editor/AttributePool.js.map +1 -0
- package/dist/editor/Builder.d.ts +15 -0
- package/dist/editor/Builder.d.ts.map +1 -0
- package/dist/editor/Builder.js +47 -0
- package/dist/editor/Builder.js.map +1 -0
- package/dist/editor/Changeset.d.ts +61 -0
- package/dist/editor/Changeset.d.ts.map +1 -0
- package/dist/editor/Changeset.js +942 -0
- package/dist/editor/Changeset.js.map +1 -0
- package/dist/editor/ChangesetUtils.d.ts +11 -0
- package/dist/editor/ChangesetUtils.d.ts.map +1 -0
- package/dist/editor/ChangesetUtils.js +30 -0
- package/dist/editor/ChangesetUtils.js.map +1 -0
- package/dist/editor/MergingOpAssembler.d.ts +13 -0
- package/dist/editor/MergingOpAssembler.d.ts.map +1 -0
- package/dist/editor/MergingOpAssembler.js +60 -0
- package/dist/editor/MergingOpAssembler.js.map +1 -0
- package/dist/editor/Op.d.ts +10 -0
- package/dist/editor/Op.d.ts.map +1 -0
- package/dist/editor/Op.js +18 -0
- package/dist/editor/Op.js.map +1 -0
- package/dist/editor/OpAssembler.d.ts +9 -0
- package/dist/editor/OpAssembler.d.ts.map +1 -0
- package/dist/editor/OpAssembler.js +16 -0
- package/dist/editor/OpAssembler.js.map +1 -0
- package/dist/editor/OpIter.d.ts +9 -0
- package/dist/editor/OpIter.d.ts.map +1 -0
- package/dist/editor/OpIter.js +22 -0
- package/dist/editor/OpIter.js.map +1 -0
- package/dist/editor/SmartOpAssembler.d.ts +21 -0
- package/dist/editor/SmartOpAssembler.d.ts.map +1 -0
- package/dist/editor/SmartOpAssembler.js +71 -0
- package/dist/editor/SmartOpAssembler.js.map +1 -0
- package/dist/editor/StringAssembler.d.ts +7 -0
- package/dist/editor/StringAssembler.d.ts.map +1 -0
- package/dist/editor/StringAssembler.js +15 -0
- package/dist/editor/StringAssembler.js.map +1 -0
- package/dist/editor/StringIterator.d.ts +13 -0
- package/dist/editor/StringIterator.d.ts.map +1 -0
- package/dist/editor/StringIterator.js +29 -0
- package/dist/editor/StringIterator.js.map +1 -0
- package/dist/editor/TextLinesMutator.d.ts +31 -0
- package/dist/editor/TextLinesMutator.d.ts.map +1 -0
- package/dist/editor/TextLinesMutator.js +198 -0
- package/dist/editor/TextLinesMutator.js.map +1 -0
- package/dist/editor/ace2_common.d.ts +9 -0
- package/dist/editor/ace2_common.d.ts.map +1 -0
- package/dist/editor/ace2_common.js +31 -0
- package/dist/editor/ace2_common.js.map +1 -0
- package/dist/editor/attributes.d.ts +20 -0
- package/dist/editor/attributes.d.ts.map +1 -0
- package/dist/editor/attributes.js +54 -0
- package/dist/editor/attributes.js.map +1 -0
- package/dist/editor/browser_flags.d.ts +7 -0
- package/dist/editor/browser_flags.d.ts.map +1 -0
- package/dist/editor/browser_flags.js +8 -0
- package/dist/editor/browser_flags.js.map +1 -0
- package/dist/editor/changesettracker.d.ts +54 -0
- package/dist/editor/changesettracker.d.ts.map +1 -0
- package/dist/editor/changesettracker.js +193 -0
- package/dist/editor/changesettracker.js.map +1 -0
- package/dist/editor/colorutils.d.ts +22 -0
- package/dist/editor/colorutils.d.ts.map +1 -0
- package/dist/editor/colorutils.js +81 -0
- package/dist/editor/colorutils.js.map +1 -0
- package/dist/editor/contentcollector.d.ts +52 -0
- package/dist/editor/contentcollector.d.ts.map +1 -0
- package/dist/editor/contentcollector.js +692 -0
- package/dist/editor/contentcollector.js.map +1 -0
- package/dist/editor/core/EventBus.d.ts +187 -0
- package/dist/editor/core/EventBus.d.ts.map +1 -0
- package/dist/editor/core/EventBus.js +169 -0
- package/dist/editor/core/EventBus.js.map +1 -0
- package/dist/editor/cssmanager.d.ts +6 -0
- package/dist/editor/cssmanager.d.ts.map +1 -0
- package/dist/editor/cssmanager.js +35 -0
- package/dist/editor/cssmanager.js.map +1 -0
- package/dist/editor/domline.d.ts +35 -0
- package/dist/editor/domline.d.ts.map +1 -0
- package/dist/editor/domline.js +267 -0
- package/dist/editor/domline.js.map +1 -0
- package/dist/editor/html_escape.d.ts +3 -0
- package/dist/editor/html_escape.d.ts.map +1 -0
- package/dist/editor/html_escape.js +8 -0
- package/dist/editor/html_escape.js.map +1 -0
- package/dist/editor/linestylefilter.d.ts +22 -0
- package/dist/editor/linestylefilter.d.ts.map +1 -0
- package/dist/editor/linestylefilter.js +298 -0
- package/dist/editor/linestylefilter.js.map +1 -0
- package/dist/editor/skiplist.d.ts +51 -0
- package/dist/editor/skiplist.d.ts.map +1 -0
- package/dist/editor/skiplist.js +327 -0
- package/dist/editor/skiplist.js.map +1 -0
- package/dist/editor/types/AText.d.ts +5 -0
- package/dist/editor/types/AText.d.ts.map +1 -0
- package/dist/editor/types/AText.js +2 -0
- package/dist/editor/types/AText.js.map +1 -0
- package/dist/editor/types/Attribute.d.ts +2 -0
- package/dist/editor/types/Attribute.d.ts.map +1 -0
- package/dist/editor/types/Attribute.js +2 -0
- package/dist/editor/types/Attribute.js.map +1 -0
- package/dist/editor/types/ChangeSet.d.ts +7 -0
- package/dist/editor/types/ChangeSet.d.ts.map +1 -0
- package/dist/editor/types/ChangeSet.js +2 -0
- package/dist/editor/types/ChangeSet.js.map +1 -0
- package/dist/editor/types/ChangeSetBuilder.d.ts +7 -0
- package/dist/editor/types/ChangeSetBuilder.d.ts.map +1 -0
- package/dist/editor/types/ChangeSetBuilder.js +2 -0
- package/dist/editor/types/ChangeSetBuilder.js.map +1 -0
- package/dist/editor/types/RepModel.d.ts +25 -0
- package/dist/editor/types/RepModel.d.ts.map +1 -0
- package/dist/editor/types/RepModel.js +2 -0
- package/dist/editor/types/RepModel.js.map +1 -0
- package/dist/editor/undomodule.d.ts +30 -0
- package/dist/editor/undomodule.d.ts.map +1 -0
- package/dist/editor/undomodule.js +276 -0
- package/dist/editor/undomodule.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/themes.d.ts +81 -0
- package/dist/themes.d.ts.map +1 -0
- package/dist/themes.js +227 -0
- package/dist/themes.js.map +1 -0
- package/package.json +73 -7
package/dist/EpModal.js
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
export class EpModal extends LitElement {
|
|
3
|
+
constructor() {
|
|
4
|
+
super();
|
|
5
|
+
this._previousFocus = null;
|
|
6
|
+
this.open = false;
|
|
7
|
+
this.modalTitle = '';
|
|
8
|
+
this._boundKeyDown = this._handleKeyDown.bind(this);
|
|
9
|
+
}
|
|
10
|
+
updated(changed) {
|
|
11
|
+
if (changed.has('open')) {
|
|
12
|
+
if (this.open)
|
|
13
|
+
this._onOpen();
|
|
14
|
+
else
|
|
15
|
+
this._onClose();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
close(action) {
|
|
19
|
+
this.dispatchEvent(new CustomEvent('ep-modal-close', {
|
|
20
|
+
bubbles: true, composed: true, detail: { action },
|
|
21
|
+
}));
|
|
22
|
+
this.open = false;
|
|
23
|
+
}
|
|
24
|
+
render() {
|
|
25
|
+
return html `
|
|
26
|
+
<div class="overlay" part="overlay" @click="${() => this.close()}"></div>
|
|
27
|
+
<div class="dialog" role="dialog" aria-modal="true"
|
|
28
|
+
aria-labelledby="ep-modal-title" tabindex="-1">
|
|
29
|
+
<div class="header">
|
|
30
|
+
<h2 class="title" id="ep-modal-title">${this.modalTitle}</h2>
|
|
31
|
+
<button class="close-btn" aria-label="Close"
|
|
32
|
+
@click="${() => this.close()}">×</button>
|
|
33
|
+
</div>
|
|
34
|
+
<div class="body"><slot></slot></div>
|
|
35
|
+
<div class="actions"><slot name="actions"></slot></div>
|
|
36
|
+
</div>
|
|
37
|
+
`;
|
|
38
|
+
}
|
|
39
|
+
_onOpen() {
|
|
40
|
+
this._previousFocus = document.activeElement instanceof HTMLElement
|
|
41
|
+
? document.activeElement : null;
|
|
42
|
+
document.addEventListener('keydown', this._boundKeyDown);
|
|
43
|
+
const dialog = this.renderRoot?.querySelector('.dialog');
|
|
44
|
+
requestAnimationFrame(() => dialog?.focus());
|
|
45
|
+
}
|
|
46
|
+
_onClose() {
|
|
47
|
+
document.removeEventListener('keydown', this._boundKeyDown);
|
|
48
|
+
this._previousFocus?.focus();
|
|
49
|
+
this._previousFocus = null;
|
|
50
|
+
}
|
|
51
|
+
_handleKeyDown(e) {
|
|
52
|
+
if (e.key === 'Escape') {
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
e.stopPropagation();
|
|
55
|
+
this.close();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (e.key === 'Tab')
|
|
59
|
+
this._trapFocus(e);
|
|
60
|
+
}
|
|
61
|
+
_trapFocus(e) {
|
|
62
|
+
const selector = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
63
|
+
const shadowEls = Array.from(this.renderRoot.querySelectorAll(selector));
|
|
64
|
+
const lightEls = Array.from(this.querySelectorAll(selector));
|
|
65
|
+
const focusable = [...shadowEls, ...lightEls].filter(el => !el.hasAttribute('disabled') && el.offsetParent !== null);
|
|
66
|
+
if (!focusable.length)
|
|
67
|
+
return;
|
|
68
|
+
const first = focusable[0];
|
|
69
|
+
const last = focusable[focusable.length - 1];
|
|
70
|
+
const active = this.renderRoot.activeElement ?? document.activeElement;
|
|
71
|
+
if (e.shiftKey) {
|
|
72
|
+
if (active === first || !focusable.includes(active)) {
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
last.focus();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
if (active === last || !focusable.includes(active)) {
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
first.focus();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
static confirm(options) {
|
|
85
|
+
return new Promise(resolve => {
|
|
86
|
+
const modal = document.createElement('ep-modal');
|
|
87
|
+
modal.modalTitle = options.title;
|
|
88
|
+
const body = document.createElement('p');
|
|
89
|
+
body.textContent = options.message;
|
|
90
|
+
body.style.margin = '0';
|
|
91
|
+
modal.appendChild(body);
|
|
92
|
+
const actions = document.createElement('div');
|
|
93
|
+
actions.setAttribute('slot', 'actions');
|
|
94
|
+
const cancelBtn = document.createElement('button');
|
|
95
|
+
cancelBtn.textContent = options.cancelText ?? 'Cancel';
|
|
96
|
+
cancelBtn.addEventListener('click', () => { resolve(false); modal.remove(); });
|
|
97
|
+
const confirmBtn = document.createElement('button');
|
|
98
|
+
confirmBtn.textContent = options.confirmText ?? 'Confirm';
|
|
99
|
+
confirmBtn.addEventListener('click', () => { resolve(true); modal.remove(); });
|
|
100
|
+
actions.append(cancelBtn, confirmBtn);
|
|
101
|
+
modal.appendChild(actions);
|
|
102
|
+
document.body.appendChild(modal);
|
|
103
|
+
modal.addEventListener('ep-modal-close', () => { resolve(false); modal.remove(); });
|
|
104
|
+
modal.open = true;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
static prompt(options) {
|
|
108
|
+
return new Promise(resolve => {
|
|
109
|
+
const modal = document.createElement('ep-modal');
|
|
110
|
+
modal.modalTitle = options.title;
|
|
111
|
+
const container = document.createElement('div');
|
|
112
|
+
const msg = document.createElement('p');
|
|
113
|
+
msg.textContent = options.message;
|
|
114
|
+
msg.style.margin = '0';
|
|
115
|
+
const input = document.createElement('input');
|
|
116
|
+
input.type = 'text';
|
|
117
|
+
input.placeholder = options.placeholder ?? '';
|
|
118
|
+
input.style.cssText = 'width:100%;box-sizing:border-box;padding:8px 10px;border:1px solid var(--middle-color,#d2d2d2);border-radius:calc(var(--radius, 4px) - 1px);font-size:14px;margin-top:12px;outline:none;background:var(--bg-soft-color,#f2f3f4);color:var(--text-color,#485365);';
|
|
119
|
+
container.append(msg, input);
|
|
120
|
+
modal.appendChild(container);
|
|
121
|
+
const actions = document.createElement('div');
|
|
122
|
+
actions.setAttribute('slot', 'actions');
|
|
123
|
+
const cancelBtn = document.createElement('button');
|
|
124
|
+
cancelBtn.textContent = 'Cancel';
|
|
125
|
+
cancelBtn.addEventListener('click', () => { resolve(null); modal.remove(); });
|
|
126
|
+
const confirmBtn = document.createElement('button');
|
|
127
|
+
confirmBtn.textContent = 'OK';
|
|
128
|
+
confirmBtn.addEventListener('click', () => { resolve(input.value); modal.remove(); });
|
|
129
|
+
actions.append(cancelBtn, confirmBtn);
|
|
130
|
+
modal.appendChild(actions);
|
|
131
|
+
document.body.appendChild(modal);
|
|
132
|
+
modal.addEventListener('ep-modal-close', () => { resolve(null); modal.remove(); });
|
|
133
|
+
modal.open = true;
|
|
134
|
+
requestAnimationFrame(() => input.focus());
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
EpModal.properties = {
|
|
139
|
+
open: { type: Boolean, reflect: true },
|
|
140
|
+
modalTitle: { attribute: 'modal-title' },
|
|
141
|
+
};
|
|
142
|
+
EpModal.styles = css `
|
|
143
|
+
:host {
|
|
144
|
+
--ep-font: var(--main-font-family, Quicksand, Cantarell, "Open Sans", "Helvetica Neue", sans-serif);
|
|
145
|
+
position: fixed;
|
|
146
|
+
inset: 0;
|
|
147
|
+
z-index: 10001;
|
|
148
|
+
display: none;
|
|
149
|
+
align-items: center;
|
|
150
|
+
justify-content: center;
|
|
151
|
+
font-family: var(--ep-font);
|
|
152
|
+
font-size: 14px;
|
|
153
|
+
color: var(--text-color, #485365);
|
|
154
|
+
}
|
|
155
|
+
:host([open]) { display: flex; }
|
|
156
|
+
.overlay {
|
|
157
|
+
position: fixed; inset: 0;
|
|
158
|
+
/* Matches Etherpad's dialog backdrop (#settings-dialog::backdrop). */
|
|
159
|
+
background: rgba(0, 0, 0, 0.45);
|
|
160
|
+
backdrop-filter: blur(2px);
|
|
161
|
+
animation: ep-modal-fade-in 0.15s ease;
|
|
162
|
+
}
|
|
163
|
+
.dialog {
|
|
164
|
+
position: relative; z-index: 1;
|
|
165
|
+
background: var(--bg-color, white);
|
|
166
|
+
border-radius: var(--radius-large, 5px);
|
|
167
|
+
box-shadow: var(--shadow, 0 0 0 1px rgba(99, 114, 130, 0.16), 0 8px 16px rgba(27, 39, 51, 0.08));
|
|
168
|
+
max-width: 480px; width: calc(100vw - 32px);
|
|
169
|
+
max-height: calc(100vh - 64px); overflow: auto;
|
|
170
|
+
animation: ep-modal-scale-in 0.2s ease; outline: none;
|
|
171
|
+
}
|
|
172
|
+
.header {
|
|
173
|
+
display: flex; align-items: center; justify-content: space-between;
|
|
174
|
+
padding: 20px 25px 0;
|
|
175
|
+
}
|
|
176
|
+
.title { margin: 0; font-size: 1.2rem; font-weight: 700; line-height: 1.4; color: var(--text-color, #485365); }
|
|
177
|
+
.close-btn {
|
|
178
|
+
background: none; border: none; cursor: pointer; padding: 4px;
|
|
179
|
+
margin: -4px -4px 0 8px; color: var(--text-soft-color, #576273);
|
|
180
|
+
opacity: 0.5; transition: opacity 0.15s ease; font-size: 18px; line-height: 1;
|
|
181
|
+
display: flex; align-items: center; justify-content: center; border-radius: var(--radius, 4px);
|
|
182
|
+
}
|
|
183
|
+
.close-btn:hover, .close-btn:focus-visible { opacity: 1; }
|
|
184
|
+
.close-btn:focus-visible { outline: 2px solid var(--primary-color, #64d29b); outline-offset: 2px; }
|
|
185
|
+
.body { padding: 20px 25px; line-height: 1.6; }
|
|
186
|
+
.actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 0 25px 20px; }
|
|
187
|
+
.actions ::slotted(button), .actions button {
|
|
188
|
+
padding: 5px 20px; border-radius: var(--radius, 4px); font-size: 14px; font-weight: 700;
|
|
189
|
+
text-transform: uppercase; cursor: pointer;
|
|
190
|
+
transition: background 0.15s ease, border-color 0.15s ease;
|
|
191
|
+
font-family: inherit; line-height: 1.5;
|
|
192
|
+
}
|
|
193
|
+
.btn-cancel { background: transparent; border: 1px solid var(--middle-color, #d2d2d2); color: var(--text-color, #485365); }
|
|
194
|
+
.btn-cancel:hover { background: var(--bg-soft-color, #f2f3f4); }
|
|
195
|
+
.btn-confirm { background: var(--text-color, #485365); border: 1px solid var(--text-color, #485365); color: white; }
|
|
196
|
+
.btn-confirm:hover { background: var(--dark-color, #576273); }
|
|
197
|
+
.prompt-input {
|
|
198
|
+
width: 100%; box-sizing: border-box; padding: 8px 10px;
|
|
199
|
+
border: 1px solid var(--middle-color, #d2d2d2); border-radius: calc(var(--radius, 4px) - 1px);
|
|
200
|
+
font-size: 14px; font-family: inherit;
|
|
201
|
+
background: var(--bg-soft-color, #f2f3f4); color: var(--text-color, #485365);
|
|
202
|
+
margin-top: 12px; outline: none; transition: border-color 0.15s ease;
|
|
203
|
+
}
|
|
204
|
+
.prompt-input:focus { border-color: var(--dark-color, #576273); }
|
|
205
|
+
.prompt-input::placeholder { color: var(--text-soft-color, #576273); }
|
|
206
|
+
@keyframes ep-modal-fade-in { from { opacity: 0; } to { opacity: 1; } }
|
|
207
|
+
@keyframes ep-modal-scale-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
|
|
208
|
+
`;
|
|
209
|
+
if (!customElements.get('ep-modal')) {
|
|
210
|
+
customElements.define('ep-modal', EpModal);
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=EpModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EpModal.js","sourceRoot":"","sources":["../src/EpModal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkB,MAAM,KAAK,CAAC;AAe5D,MAAM,OAAO,OAAQ,SAAQ,UAAU;IAgFrC;QACE,KAAK,EAAE,CAAC;QAJF,mBAAc,GAAuB,IAAI,CAAC;QAKhD,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,cA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AAI,GAAG,IAAI,CAAC;YAClB,qBAAqB,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;IACL,CAAC;;AAnNe,kBAAU,GAAG;IAC3B,IAAI,EAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;IAC5C,UAAU,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE;CACzC,AAHyB,CAGxB;AAEc,cAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkE3B,AAlEqB,CAkEpB;AA+IJ,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;IACpC,cAAc,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
type NotificationPosition = 'top' | 'bottom';
|
|
3
|
+
type NotificationType = 'success' | 'error' | 'info';
|
|
4
|
+
interface NotificationOptions {
|
|
5
|
+
text: string;
|
|
6
|
+
type?: NotificationType;
|
|
7
|
+
duration?: number;
|
|
8
|
+
position?: NotificationPosition;
|
|
9
|
+
}
|
|
10
|
+
export declare class EpNotification extends LitElement {
|
|
11
|
+
static styles: import("lit").CSSResult;
|
|
12
|
+
type: NotificationType;
|
|
13
|
+
position: NotificationPosition;
|
|
14
|
+
duration: number;
|
|
15
|
+
private _dismissTimer;
|
|
16
|
+
connectedCallback(): void;
|
|
17
|
+
disconnectedCallback(): void;
|
|
18
|
+
dismiss(): void;
|
|
19
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
20
|
+
private _startAutoClose;
|
|
21
|
+
private _clearTimer;
|
|
22
|
+
static show(options: NotificationOptions): EpNotification;
|
|
23
|
+
static success(text: string, duration?: number): EpNotification;
|
|
24
|
+
static error(text: string, duration?: number): EpNotification;
|
|
25
|
+
}
|
|
26
|
+
declare global {
|
|
27
|
+
interface HTMLElementTagNameMap {
|
|
28
|
+
'ep-notification': EpNotification;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=EpNotification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EpNotification.d.ts","sourceRoot":"","sources":["../src/EpNotification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAI5C,KAAK,oBAAoB,GAAG,KAAK,GAAG,QAAQ,CAAC;AAC7C,KAAK,gBAAgB,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAErD,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,oBAAoB,CAAC;CACjC;AA+BD,qBACa,cAAe,SAAQ,UAAU;IAC5C,MAAM,CAAC,MAAM,0BA2FX;IAE2B,IAAI,EAAE,gBAAgB,CAAU;IAChC,QAAQ,EAAE,oBAAoB,CAAS;IACxC,QAAQ,SAAQ;IAE5C,OAAO,CAAC,aAAa,CAA8C;IAEnE,iBAAiB;IAOjB,oBAAoB;IAKpB,OAAO;IAgBP,MAAM;IAYN,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,WAAW;IAOnB,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,mBAAmB,GAAG,cAAc;IAUzD,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;IAI9C,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;CAG7C;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,iBAAiB,EAAE,cAAc,CAAC;KACnC;CACF"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var EpNotification_1;
|
|
8
|
+
import { LitElement, html, css } from 'lit';
|
|
9
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
10
|
+
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
11
|
+
const iconSvg = {
|
|
12
|
+
success: `<svg class="icon" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"/></svg>`,
|
|
13
|
+
error: `<svg class="icon" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm1-11a1 1 0 10-2 0v4a1 1 0 102 0V7zm-1 8a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd"/></svg>`,
|
|
14
|
+
info: `<svg class="icon" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd"/></svg>`,
|
|
15
|
+
};
|
|
16
|
+
const ensureContainer = (position) => {
|
|
17
|
+
const id = `ep-notification-container-${position}`;
|
|
18
|
+
let container = document.getElementById(id);
|
|
19
|
+
if (container)
|
|
20
|
+
return container;
|
|
21
|
+
container = document.createElement('div');
|
|
22
|
+
container.id = id;
|
|
23
|
+
Object.assign(container.style, {
|
|
24
|
+
position: 'fixed',
|
|
25
|
+
[position === 'top' ? 'top' : 'bottom']: '16px',
|
|
26
|
+
right: '16px',
|
|
27
|
+
zIndex: '10000',
|
|
28
|
+
display: 'flex',
|
|
29
|
+
flexDirection: position === 'top' ? 'column' : 'column-reverse',
|
|
30
|
+
gap: '8px',
|
|
31
|
+
pointerEvents: 'none',
|
|
32
|
+
maxWidth: '100vw',
|
|
33
|
+
width: '420px',
|
|
34
|
+
});
|
|
35
|
+
document.body.appendChild(container);
|
|
36
|
+
return container;
|
|
37
|
+
};
|
|
38
|
+
let EpNotification = EpNotification_1 = class EpNotification extends LitElement {
|
|
39
|
+
constructor() {
|
|
40
|
+
super(...arguments);
|
|
41
|
+
this.type = 'info';
|
|
42
|
+
this.position = 'top';
|
|
43
|
+
this.duration = 3000;
|
|
44
|
+
this._dismissTimer = null;
|
|
45
|
+
}
|
|
46
|
+
connectedCallback() {
|
|
47
|
+
super.connectedCallback();
|
|
48
|
+
this.style.setProperty('--ep-slide-dir', this.position === 'bottom' ? '1' : '-1');
|
|
49
|
+
requestAnimationFrame(() => this.setAttribute('visible', ''));
|
|
50
|
+
this._startAutoClose();
|
|
51
|
+
}
|
|
52
|
+
disconnectedCallback() {
|
|
53
|
+
super.disconnectedCallback();
|
|
54
|
+
this._clearTimer();
|
|
55
|
+
}
|
|
56
|
+
dismiss() {
|
|
57
|
+
this._clearTimer();
|
|
58
|
+
this.removeAttribute('visible');
|
|
59
|
+
this.setAttribute('removing', '');
|
|
60
|
+
const onDone = () => {
|
|
61
|
+
this.removeEventListener('transitionend', onDone);
|
|
62
|
+
this.remove();
|
|
63
|
+
for (const pos of ['top', 'bottom']) {
|
|
64
|
+
const c = document.getElementById(`ep-notification-container-${pos}`);
|
|
65
|
+
if (c && c.children.length === 0)
|
|
66
|
+
c.remove();
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
this.addEventListener('transitionend', onDone);
|
|
70
|
+
setTimeout(onDone, 350);
|
|
71
|
+
}
|
|
72
|
+
render() {
|
|
73
|
+
const icon = iconSvg[this.type] ?? iconSvg.info;
|
|
74
|
+
return html `
|
|
75
|
+
<div class="notification" role="alert" aria-live="assertive">
|
|
76
|
+
${unsafeHTML(icon)}
|
|
77
|
+
<div class="body"><slot></slot></div>
|
|
78
|
+
<button class="close" aria-label="Close notification"
|
|
79
|
+
@click="${() => this.dismiss()}">×</button>
|
|
80
|
+
</div>
|
|
81
|
+
`;
|
|
82
|
+
}
|
|
83
|
+
_startAutoClose() {
|
|
84
|
+
if (this.duration > 0) {
|
|
85
|
+
this._dismissTimer = setTimeout(() => this.dismiss(), this.duration);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
_clearTimer() {
|
|
89
|
+
if (this._dismissTimer != null) {
|
|
90
|
+
clearTimeout(this._dismissTimer);
|
|
91
|
+
this._dismissTimer = null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
static show(options) {
|
|
95
|
+
const el = document.createElement('ep-notification');
|
|
96
|
+
el.type = options.type ?? 'info';
|
|
97
|
+
el.duration = options.duration ?? 3000;
|
|
98
|
+
el.position = options.position ?? 'top';
|
|
99
|
+
el.textContent = options.text;
|
|
100
|
+
ensureContainer(el.position).appendChild(el);
|
|
101
|
+
return el;
|
|
102
|
+
}
|
|
103
|
+
static success(text, duration) {
|
|
104
|
+
return EpNotification_1.show({ text, type: 'success', duration });
|
|
105
|
+
}
|
|
106
|
+
static error(text, duration) {
|
|
107
|
+
return EpNotification_1.show({ text, type: 'error', duration: duration ?? 5000 });
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
EpNotification.styles = css `
|
|
111
|
+
:host {
|
|
112
|
+
--ep-font: var(--main-font-family, Quicksand, Cantarell, "Open Sans", "Helvetica Neue", sans-serif);
|
|
113
|
+
--ep-radius: var(--radius-large, 5px);
|
|
114
|
+
--ep-shadow: var(--shadow, 0 0 0 1px rgba(99, 114, 130, 0.16), 0 8px 16px rgba(27, 39, 51, 0.08));
|
|
115
|
+
|
|
116
|
+
display: block;
|
|
117
|
+
pointer-events: auto;
|
|
118
|
+
font-family: var(--ep-font);
|
|
119
|
+
font-size: 14px;
|
|
120
|
+
line-height: 1.5;
|
|
121
|
+
max-width: 420px;
|
|
122
|
+
width: 100%;
|
|
123
|
+
box-sizing: border-box;
|
|
124
|
+
opacity: 0;
|
|
125
|
+
transform: translateY(calc(var(--ep-slide-dir, -1) * 12px));
|
|
126
|
+
transition: opacity 0.25s ease, transform 0.25s ease;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
:host([visible]) {
|
|
130
|
+
opacity: 1;
|
|
131
|
+
transform: translateY(0);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
:host([removing]) {
|
|
135
|
+
opacity: 0;
|
|
136
|
+
transform: translateY(calc(var(--ep-slide-dir, -1) * 12px));
|
|
137
|
+
transition: opacity 0.2s ease, transform 0.2s ease;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.notification {
|
|
141
|
+
display: flex;
|
|
142
|
+
align-items: flex-start;
|
|
143
|
+
gap: 10px;
|
|
144
|
+
padding: 12px 16px;
|
|
145
|
+
border-radius: var(--ep-radius);
|
|
146
|
+
box-shadow: var(--ep-shadow);
|
|
147
|
+
background: var(--bg-color, white);
|
|
148
|
+
color: var(--text-color, #485365);
|
|
149
|
+
border-left: 3px solid var(--middle-color, #d2d2d2);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
:host([type="success"]) .notification {
|
|
153
|
+
border-left-color: var(--success-color, var(--primary-color, #64d29b));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
:host([type="error"]) .notification {
|
|
157
|
+
border-left-color: var(--danger-color, #d1242f);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
:host([type="info"]) .notification {
|
|
161
|
+
border-left-color: var(--dark-color, #576273);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.icon {
|
|
165
|
+
flex-shrink: 0;
|
|
166
|
+
width: 18px;
|
|
167
|
+
height: 18px;
|
|
168
|
+
margin-top: 1px;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
:host([type="success"]) .icon { color: var(--success-color, var(--primary-color, #64d29b)); }
|
|
172
|
+
:host([type="error"]) .icon { color: var(--danger-color, #d1242f); }
|
|
173
|
+
:host([type="info"]) .icon { color: var(--dark-color, #576273); }
|
|
174
|
+
|
|
175
|
+
.body { flex: 1; min-width: 0; word-wrap: break-word; }
|
|
176
|
+
|
|
177
|
+
.close {
|
|
178
|
+
flex-shrink: 0;
|
|
179
|
+
background: none;
|
|
180
|
+
border: none;
|
|
181
|
+
color: var(--text-soft-color, #576273);
|
|
182
|
+
cursor: pointer;
|
|
183
|
+
padding: 0;
|
|
184
|
+
opacity: 0.6;
|
|
185
|
+
transition: opacity 0.15s ease;
|
|
186
|
+
line-height: 1;
|
|
187
|
+
font-size: 18px;
|
|
188
|
+
width: 20px;
|
|
189
|
+
height: 20px;
|
|
190
|
+
display: flex;
|
|
191
|
+
align-items: center;
|
|
192
|
+
justify-content: center;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.close:hover, .close:focus-visible { opacity: 1; }
|
|
196
|
+
.close:focus-visible {
|
|
197
|
+
outline: 2px solid var(--primary-color, #64d29b);
|
|
198
|
+
outline-offset: 2px;
|
|
199
|
+
border-radius: 2px;
|
|
200
|
+
}
|
|
201
|
+
`;
|
|
202
|
+
__decorate([
|
|
203
|
+
property({ reflect: true })
|
|
204
|
+
], EpNotification.prototype, "type", void 0);
|
|
205
|
+
__decorate([
|
|
206
|
+
property({ reflect: true })
|
|
207
|
+
], EpNotification.prototype, "position", void 0);
|
|
208
|
+
__decorate([
|
|
209
|
+
property({ type: Number })
|
|
210
|
+
], EpNotification.prototype, "duration", void 0);
|
|
211
|
+
EpNotification = EpNotification_1 = __decorate([
|
|
212
|
+
customElement('ep-notification')
|
|
213
|
+
], EpNotification);
|
|
214
|
+
export { EpNotification };
|
|
215
|
+
//# sourceMappingURL=EpNotification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EpNotification.js","sourceRoot":"","sources":["../src/EpNotification.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAY3D,MAAM,OAAO,GAA2B;IACtC,OAAO,EAAE,wOAAwO;IACjP,KAAK,EAAE,wNAAwN;IAC/N,IAAI,EAAE,sPAAsP;CAC7P,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,QAA8B,EAAe,EAAE;IACtE,MAAM,EAAE,GAAG,6BAA6B,QAAQ,EAAE,CAAC;IACnD,IAAI,SAAS,GAAG,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;IAC5C,IAAI,SAAS;QAAE,OAAO,SAAS,CAAC;IAEhC,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC1C,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC;IAClB,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE;QAC7B,QAAQ,EAAE,OAAO;QACjB,CAAC,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,MAAM;QAC/C,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,OAAO;QACf,OAAO,EAAE,MAAM;QACf,aAAa,EAAE,QAAQ,KAAK,KAAK,CAA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
}
|
|
7
|
+
/**
|
|
8
|
+
* `<ep-select>` — a styled form select, matching Etherpad colibris's
|
|
9
|
+
* nice-select look (the plugin Etherpad uses to skin native `<select>`s).
|
|
10
|
+
*
|
|
11
|
+
* @fires ep-select:change - When a value is chosen. Detail: `{ value, label }`
|
|
12
|
+
*/
|
|
13
|
+
export declare class EpSelect extends LitElement {
|
|
14
|
+
static styles: import("lit").CSSResult;
|
|
15
|
+
options: EpSelectOption[];
|
|
16
|
+
value: string;
|
|
17
|
+
placeholder: string;
|
|
18
|
+
name: string;
|
|
19
|
+
disabled: boolean;
|
|
20
|
+
open: boolean;
|
|
21
|
+
private _focusIndex;
|
|
22
|
+
private _onDocClick;
|
|
23
|
+
connectedCallback(): void;
|
|
24
|
+
disconnectedCallback(): void;
|
|
25
|
+
private get _selected();
|
|
26
|
+
private _toggle;
|
|
27
|
+
private _firstEnabled;
|
|
28
|
+
private _select;
|
|
29
|
+
private _move;
|
|
30
|
+
private _onKeydown;
|
|
31
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
32
|
+
}
|
|
33
|
+
declare global {
|
|
34
|
+
interface HTMLElementTagNameMap {
|
|
35
|
+
'ep-select': EpSelect;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=EpSelect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EpSelect.d.ts","sourceRoot":"","sources":["../src/EpSelect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAI5C,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;GAKG;AACH,qBACa,QAAS,SAAQ,UAAU;IACtC,MAAM,CAAC,MAAM,0BA8GX;IAEyB,OAAO,EAAE,cAAc,EAAE,CAAM;IAC7B,KAAK,SAAM;IAC5B,WAAW,SAAM;IACjB,IAAI,SAAM;IACsB,QAAQ,UAAS;IACjB,IAAI,UAAS;IAEhD,OAAO,CAAC,WAAW,CAAM;IAElC,OAAO,CAAC,WAAW,CAEjB;IAEF,iBAAiB;IAKjB,oBAAoB;IAKpB,OAAO,KAAK,SAAS,GAEpB;IAED,OAAO,CAAC,OAAO;IASf,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,OAAO;IAYf,OAAO,CAAC,KAAK;IASb,OAAO,CAAC,UAAU;IAwBlB,MAAM;CA2BP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,QAAQ,CAAC;KACvB;CACF"}
|