@area8975/ui 0.2.2-dev.49 → 0.2.2-dev.50
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/README.md +3 -2
- package/fesm2022/area8975-ui-alert.mjs +113 -0
- package/fesm2022/area8975-ui-alert.mjs.map +1 -0
- package/fesm2022/area8975-ui-avatar.mjs +157 -0
- package/fesm2022/area8975-ui-avatar.mjs.map +1 -0
- package/fesm2022/area8975-ui-badge.mjs +116 -0
- package/fesm2022/area8975-ui-badge.mjs.map +1 -0
- package/fesm2022/area8975-ui-button.mjs +314 -0
- package/fesm2022/area8975-ui-button.mjs.map +1 -0
- package/fesm2022/area8975-ui-calendar.mjs +549 -0
- package/fesm2022/area8975-ui-calendar.mjs.map +1 -0
- package/fesm2022/area8975-ui-card-header.mjs +96 -0
- package/fesm2022/area8975-ui-card-header.mjs.map +1 -0
- package/fesm2022/area8975-ui-card.mjs +73 -0
- package/fesm2022/area8975-ui-card.mjs.map +1 -0
- package/fesm2022/area8975-ui-chart-palette.mjs +225 -0
- package/fesm2022/area8975-ui-chart-palette.mjs.map +1 -0
- package/fesm2022/area8975-ui-charts.mjs +2813 -0
- package/fesm2022/area8975-ui-charts.mjs.map +1 -0
- package/fesm2022/area8975-ui-checkbox.mjs +202 -0
- package/fesm2022/area8975-ui-checkbox.mjs.map +1 -0
- package/fesm2022/area8975-ui-colour.mjs +200 -0
- package/fesm2022/area8975-ui-colour.mjs.map +1 -0
- package/fesm2022/area8975-ui-container.mjs +40 -0
- package/fesm2022/area8975-ui-container.mjs.map +1 -0
- package/fesm2022/area8975-ui-counter.mjs +246 -0
- package/fesm2022/area8975-ui-counter.mjs.map +1 -0
- package/fesm2022/area8975-ui-date-range-picker.mjs +554 -0
- package/fesm2022/area8975-ui-date-range-picker.mjs.map +1 -0
- package/fesm2022/area8975-ui-datepicker.mjs +547 -0
- package/fesm2022/area8975-ui-datepicker.mjs.map +1 -0
- package/fesm2022/area8975-ui-disclosure.mjs +279 -0
- package/fesm2022/area8975-ui-disclosure.mjs.map +1 -0
- package/fesm2022/area8975-ui-drawer.mjs +106 -0
- package/fesm2022/area8975-ui-drawer.mjs.map +1 -0
- package/fesm2022/area8975-ui-dropdown-button.mjs +141 -0
- package/fesm2022/area8975-ui-dropdown-button.mjs.map +1 -0
- package/fesm2022/area8975-ui-dropdown-menu.mjs +96 -0
- package/fesm2022/area8975-ui-dropdown-menu.mjs.map +1 -0
- package/fesm2022/area8975-ui-dropdown.mjs +208 -0
- package/fesm2022/area8975-ui-dropdown.mjs.map +1 -0
- package/fesm2022/area8975-ui-dropzone.mjs +332 -0
- package/fesm2022/area8975-ui-dropzone.mjs.map +1 -0
- package/fesm2022/area8975-ui-field.mjs +191 -0
- package/fesm2022/area8975-ui-field.mjs.map +1 -0
- package/fesm2022/area8975-ui-file-input.mjs +340 -0
- package/fesm2022/area8975-ui-file-input.mjs.map +1 -0
- package/fesm2022/area8975-ui-file.mjs +47 -0
- package/fesm2022/area8975-ui-file.mjs.map +1 -0
- package/fesm2022/area8975-ui-format.mjs +70 -0
- package/fesm2022/area8975-ui-format.mjs.map +1 -0
- package/fesm2022/area8975-ui-input-addon.mjs +42 -0
- package/fesm2022/area8975-ui-input-addon.mjs.map +1 -0
- package/fesm2022/area8975-ui-input-group.mjs +86 -0
- package/fesm2022/area8975-ui-input-group.mjs.map +1 -0
- package/fesm2022/area8975-ui-input.mjs +682 -0
- package/fesm2022/area8975-ui-input.mjs.map +1 -0
- package/fesm2022/area8975-ui-kpi.mjs +167 -0
- package/fesm2022/area8975-ui-kpi.mjs.map +1 -0
- package/fesm2022/area8975-ui-layout.mjs +63 -0
- package/fesm2022/area8975-ui-layout.mjs.map +1 -0
- package/fesm2022/area8975-ui-loading.mjs +76 -0
- package/fesm2022/area8975-ui-loading.mjs.map +1 -0
- package/fesm2022/area8975-ui-modal-close-btn.mjs +89 -0
- package/fesm2022/area8975-ui-modal-close-btn.mjs.map +1 -0
- package/fesm2022/area8975-ui-modal.mjs +235 -0
- package/fesm2022/area8975-ui-modal.mjs.map +1 -0
- package/fesm2022/area8975-ui-money.mjs +230 -0
- package/fesm2022/area8975-ui-money.mjs.map +1 -0
- package/fesm2022/area8975-ui-overlay.mjs +317 -0
- package/fesm2022/area8975-ui-overlay.mjs.map +1 -0
- package/fesm2022/area8975-ui-pagination.mjs +152 -0
- package/fesm2022/area8975-ui-pagination.mjs.map +1 -0
- package/fesm2022/area8975-ui-private.mjs +63 -0
- package/fesm2022/area8975-ui-private.mjs.map +1 -0
- package/fesm2022/area8975-ui-progress.mjs +307 -0
- package/fesm2022/area8975-ui-progress.mjs.map +1 -0
- package/fesm2022/area8975-ui-radio.mjs +199 -0
- package/fesm2022/area8975-ui-radio.mjs.map +1 -0
- package/fesm2022/area8975-ui-rich-text-editor.mjs +778 -0
- package/fesm2022/area8975-ui-rich-text-editor.mjs.map +1 -0
- package/fesm2022/area8975-ui-search.mjs +266 -0
- package/fesm2022/area8975-ui-search.mjs.map +1 -0
- package/fesm2022/area8975-ui-segmented.mjs +118 -0
- package/fesm2022/area8975-ui-segmented.mjs.map +1 -0
- package/fesm2022/area8975-ui-select.mjs +926 -0
- package/fesm2022/area8975-ui-select.mjs.map +1 -0
- package/fesm2022/area8975-ui-sidebar-group.mjs +60 -0
- package/fesm2022/area8975-ui-sidebar-group.mjs.map +1 -0
- package/fesm2022/area8975-ui-sidebar-item.mjs +107 -0
- package/fesm2022/area8975-ui-sidebar-item.mjs.map +1 -0
- package/fesm2022/area8975-ui-sidebar.mjs +109 -0
- package/fesm2022/area8975-ui-sidebar.mjs.map +1 -0
- package/fesm2022/area8975-ui-skeleton.mjs +116 -0
- package/fesm2022/area8975-ui-skeleton.mjs.map +1 -0
- package/fesm2022/area8975-ui-stat.mjs +55 -0
- package/fesm2022/area8975-ui-stat.mjs.map +1 -0
- package/fesm2022/area8975-ui-switch.mjs +132 -0
- package/fesm2022/area8975-ui-switch.mjs.map +1 -0
- package/fesm2022/area8975-ui-tab.mjs +217 -0
- package/fesm2022/area8975-ui-tab.mjs.map +1 -0
- package/fesm2022/area8975-ui-table-filters.mjs +499 -0
- package/fesm2022/area8975-ui-table-filters.mjs.map +1 -0
- package/fesm2022/area8975-ui-table.mjs +1237 -0
- package/fesm2022/area8975-ui-table.mjs.map +1 -0
- package/fesm2022/area8975-ui-textarea.mjs +375 -0
- package/fesm2022/area8975-ui-textarea.mjs.map +1 -0
- package/fesm2022/area8975-ui-theme.mjs +246 -0
- package/fesm2022/area8975-ui-theme.mjs.map +1 -0
- package/fesm2022/area8975-ui-time-select.mjs +170 -0
- package/fesm2022/area8975-ui-time-select.mjs.map +1 -0
- package/fesm2022/area8975-ui-toast.mjs +269 -0
- package/fesm2022/area8975-ui-toast.mjs.map +1 -0
- package/fesm2022/area8975-ui-toaster.mjs +117 -0
- package/fesm2022/area8975-ui-toaster.mjs.map +1 -0
- package/fesm2022/area8975-ui-tooltip.mjs +196 -0
- package/fesm2022/area8975-ui-tooltip.mjs.map +1 -0
- package/fesm2022/area8975-ui-user-menu.mjs +186 -0
- package/fesm2022/area8975-ui-user-menu.mjs.map +1 -0
- package/fesm2022/area8975-ui.mjs +0 -16520
- package/package.json +237 -1
- package/types/area8975-ui-alert.d.ts +25 -0
- package/types/area8975-ui-avatar.d.ts +40 -0
- package/types/area8975-ui-badge.d.ts +31 -0
- package/types/area8975-ui-button.d.ts +129 -0
- package/types/area8975-ui-calendar.d.ts +177 -0
- package/types/area8975-ui-card-header.d.ts +28 -0
- package/types/area8975-ui-card.d.ts +18 -0
- package/types/area8975-ui-chart-palette.d.ts +176 -0
- package/types/area8975-ui-charts.d.ts +747 -0
- package/types/area8975-ui-checkbox.d.ts +61 -0
- package/types/area8975-ui-colour.d.ts +31 -0
- package/types/area8975-ui-container.d.ts +5 -0
- package/types/area8975-ui-counter.d.ts +43 -0
- package/types/area8975-ui-date-range-picker.d.ts +132 -0
- package/types/area8975-ui-datepicker.d.ts +124 -0
- package/types/area8975-ui-disclosure.d.ts +79 -0
- package/types/area8975-ui-drawer.d.ts +25 -0
- package/types/area8975-ui-dropdown-button.d.ts +32 -0
- package/types/area8975-ui-dropdown-menu.d.ts +25 -0
- package/types/area8975-ui-dropdown.d.ts +56 -0
- package/types/area8975-ui-dropzone.d.ts +96 -0
- package/types/area8975-ui-field.d.ts +72 -0
- package/types/area8975-ui-file-input.d.ts +72 -0
- package/types/area8975-ui-file.d.ts +21 -0
- package/types/area8975-ui-format.d.ts +37 -0
- package/types/area8975-ui-input-addon.d.ts +10 -0
- package/types/area8975-ui-input-group.d.ts +18 -0
- package/types/area8975-ui-input.d.ts +224 -0
- package/types/area8975-ui-kpi.d.ts +36 -0
- package/types/area8975-ui-layout.d.ts +7 -0
- package/types/area8975-ui-loading.d.ts +16 -0
- package/types/area8975-ui-modal-close-btn.d.ts +14 -0
- package/types/area8975-ui-modal.d.ts +45 -0
- package/types/area8975-ui-money.d.ts +77 -0
- package/types/area8975-ui-overlay.d.ts +75 -0
- package/types/area8975-ui-pagination.d.ts +27 -0
- package/types/area8975-ui-private.d.ts +20 -0
- package/types/area8975-ui-progress.d.ts +127 -0
- package/types/area8975-ui-radio.d.ts +61 -0
- package/types/area8975-ui-rich-text-editor.d.ts +165 -0
- package/types/area8975-ui-search.d.ts +56 -0
- package/types/area8975-ui-segmented.d.ts +41 -0
- package/types/area8975-ui-select.d.ts +293 -0
- package/types/area8975-ui-sidebar-group.d.ts +15 -0
- package/types/area8975-ui-sidebar-item.d.ts +20 -0
- package/types/area8975-ui-sidebar.d.ts +16 -0
- package/types/area8975-ui-skeleton.d.ts +35 -0
- package/types/area8975-ui-stat.d.ts +13 -0
- package/types/area8975-ui-switch.d.ts +32 -0
- package/types/area8975-ui-tab.d.ts +45 -0
- package/types/area8975-ui-table-filters.d.ts +138 -0
- package/types/area8975-ui-table.d.ts +371 -0
- package/types/area8975-ui-textarea.d.ts +126 -0
- package/types/area8975-ui-theme.d.ts +61 -0
- package/types/area8975-ui-time-select.d.ts +35 -0
- package/types/area8975-ui-toast.d.ts +78 -0
- package/types/area8975-ui-toaster.d.ts +23 -0
- package/types/area8975-ui-tooltip.d.ts +47 -0
- package/types/area8975-ui-user-menu.d.ts +39 -0
- package/types/area8975-ui.d.ts +1 -4546
- package/fesm2022/area8975-ui.mjs.map +0 -1
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { DOCUMENT } from "@angular/common";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { Component, DestroyRef, Injectable, InjectionToken, booleanAttribute, computed, effect, inject, input, makeEnvironmentProviders, provideAppInitializer, signal } from "@angular/core";
|
|
4
|
+
import { UiSegmentedComponent } from "@area8975/ui/segmented";
|
|
5
|
+
var UiDarkClass = class UiDarkClass {
|
|
6
|
+
isDark = signal(false, ...ngDevMode ? [{ debugName: "isDark" }] : /* istanbul ignore next */ []);
|
|
7
|
+
constructor() {
|
|
8
|
+
const root = inject(DOCUMENT).documentElement;
|
|
9
|
+
const read = () => this.isDark.set(root.classList.contains("dark"));
|
|
10
|
+
read();
|
|
11
|
+
if (typeof MutationObserver === "undefined") return;
|
|
12
|
+
const observer = new MutationObserver(read);
|
|
13
|
+
observer.observe(root, {
|
|
14
|
+
attributes: true,
|
|
15
|
+
attributeFilter: ["class"]
|
|
16
|
+
});
|
|
17
|
+
inject(DestroyRef).onDestroy(() => observer.disconnect());
|
|
18
|
+
}
|
|
19
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
20
|
+
minVersion: "12.0.0",
|
|
21
|
+
version: "22.2.1",
|
|
22
|
+
ngImport: i0,
|
|
23
|
+
type: UiDarkClass,
|
|
24
|
+
deps: [],
|
|
25
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
26
|
+
});
|
|
27
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
28
|
+
minVersion: "12.0.0",
|
|
29
|
+
version: "22.2.1",
|
|
30
|
+
ngImport: i0,
|
|
31
|
+
type: UiDarkClass,
|
|
32
|
+
providedIn: "root"
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
36
|
+
minVersion: "12.0.0",
|
|
37
|
+
version: "22.2.1",
|
|
38
|
+
ngImport: i0,
|
|
39
|
+
type: UiDarkClass,
|
|
40
|
+
decorators: [{
|
|
41
|
+
type: Injectable,
|
|
42
|
+
args: [{ providedIn: "root" }]
|
|
43
|
+
}],
|
|
44
|
+
ctorParameters: () => []
|
|
45
|
+
});
|
|
46
|
+
const UI_THEME_CONFIG = new InjectionToken("UI_THEME_CONFIG", {
|
|
47
|
+
providedIn: "root",
|
|
48
|
+
factory: () => ({ storageKey: "ui-theme" })
|
|
49
|
+
});
|
|
50
|
+
const PREFERENCES = [
|
|
51
|
+
"system",
|
|
52
|
+
"light",
|
|
53
|
+
"dark"
|
|
54
|
+
];
|
|
55
|
+
var UiThemeService = class UiThemeService {
|
|
56
|
+
document = inject(DOCUMENT);
|
|
57
|
+
storageKey = inject(UI_THEME_CONFIG).storageKey;
|
|
58
|
+
media = this.document.defaultView?.matchMedia?.("(prefers-color-scheme: dark)");
|
|
59
|
+
preference = signal(this.stored(), ...ngDevMode ? [{ debugName: "preference" }] : /* istanbul ignore next */ []);
|
|
60
|
+
systemDark = signal(this.media?.matches ?? false, ...ngDevMode ? [{ debugName: "systemDark" }] : /* istanbul ignore next */ []);
|
|
61
|
+
isDark = computed(() => {
|
|
62
|
+
const preference = this.preference();
|
|
63
|
+
return preference === "dark" || preference === "system" && this.systemDark();
|
|
64
|
+
}, ...ngDevMode ? [{ debugName: "isDark" }] : /* istanbul ignore next */ []);
|
|
65
|
+
constructor() {
|
|
66
|
+
const onChange = (event) => this.systemDark.set(event.matches);
|
|
67
|
+
this.media?.addEventListener("change", onChange);
|
|
68
|
+
inject(DestroyRef).onDestroy(() => this.media?.removeEventListener("change", onChange));
|
|
69
|
+
effect(() => {
|
|
70
|
+
const root = this.document.documentElement;
|
|
71
|
+
const dark = this.isDark();
|
|
72
|
+
root.classList.toggle("dark", dark);
|
|
73
|
+
root.style.colorScheme = dark ? "dark" : "light";
|
|
74
|
+
});
|
|
75
|
+
effect(() => {
|
|
76
|
+
const preference = this.preference();
|
|
77
|
+
try {
|
|
78
|
+
this.document.defaultView?.localStorage.setItem(this.storageKey, preference);
|
|
79
|
+
} catch {}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
stored() {
|
|
83
|
+
try {
|
|
84
|
+
const value = this.document.defaultView?.localStorage.getItem(this.storageKey);
|
|
85
|
+
return PREFERENCES.includes(value) ? value : "system";
|
|
86
|
+
} catch {
|
|
87
|
+
return "system";
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
91
|
+
minVersion: "12.0.0",
|
|
92
|
+
version: "22.2.1",
|
|
93
|
+
ngImport: i0,
|
|
94
|
+
type: UiThemeService,
|
|
95
|
+
deps: [],
|
|
96
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
97
|
+
});
|
|
98
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
99
|
+
minVersion: "12.0.0",
|
|
100
|
+
version: "22.2.1",
|
|
101
|
+
ngImport: i0,
|
|
102
|
+
type: UiThemeService,
|
|
103
|
+
providedIn: "root"
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
107
|
+
minVersion: "12.0.0",
|
|
108
|
+
version: "22.2.1",
|
|
109
|
+
ngImport: i0,
|
|
110
|
+
type: UiThemeService,
|
|
111
|
+
decorators: [{
|
|
112
|
+
type: Injectable,
|
|
113
|
+
args: [{ providedIn: "root" }]
|
|
114
|
+
}],
|
|
115
|
+
ctorParameters: () => []
|
|
116
|
+
});
|
|
117
|
+
function provideUiTheme(config = {}) {
|
|
118
|
+
return makeEnvironmentProviders([{
|
|
119
|
+
provide: UI_THEME_CONFIG,
|
|
120
|
+
useValue: {
|
|
121
|
+
storageKey: "ui-theme",
|
|
122
|
+
...config
|
|
123
|
+
}
|
|
124
|
+
}, provideAppInitializer(() => {
|
|
125
|
+
inject(UiThemeService);
|
|
126
|
+
})]);
|
|
127
|
+
}
|
|
128
|
+
var UiThemeSwitchComponent = class UiThemeSwitchComponent {
|
|
129
|
+
theme = inject(UiThemeService);
|
|
130
|
+
ariaLabel = input("Theme", ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
|
|
131
|
+
fill = input(false, {
|
|
132
|
+
...ngDevMode ? { debugName: "fill" } : /* istanbul ignore next */ {},
|
|
133
|
+
transform: booleanAttribute
|
|
134
|
+
});
|
|
135
|
+
options = [
|
|
136
|
+
{
|
|
137
|
+
value: "system",
|
|
138
|
+
label: "System"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
value: "light",
|
|
142
|
+
label: "Light"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
value: "dark",
|
|
146
|
+
label: "Dark"
|
|
147
|
+
}
|
|
148
|
+
];
|
|
149
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
150
|
+
minVersion: "12.0.0",
|
|
151
|
+
version: "22.2.1",
|
|
152
|
+
ngImport: i0,
|
|
153
|
+
type: UiThemeSwitchComponent,
|
|
154
|
+
deps: [],
|
|
155
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
156
|
+
});
|
|
157
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
158
|
+
minVersion: "17.1.0",
|
|
159
|
+
version: "22.2.1",
|
|
160
|
+
type: UiThemeSwitchComponent,
|
|
161
|
+
isStandalone: true,
|
|
162
|
+
selector: "ui-theme-switch",
|
|
163
|
+
inputs: {
|
|
164
|
+
ariaLabel: {
|
|
165
|
+
classPropertyName: "ariaLabel",
|
|
166
|
+
publicName: "ariaLabel",
|
|
167
|
+
isSignal: true,
|
|
168
|
+
isRequired: false,
|
|
169
|
+
transformFunction: null
|
|
170
|
+
},
|
|
171
|
+
fill: {
|
|
172
|
+
classPropertyName: "fill",
|
|
173
|
+
publicName: "fill",
|
|
174
|
+
isSignal: true,
|
|
175
|
+
isRequired: false,
|
|
176
|
+
transformFunction: null
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
host: { properties: { "class.block": "fill()" } },
|
|
180
|
+
ngImport: i0,
|
|
181
|
+
template: `
|
|
182
|
+
<ui-segmented
|
|
183
|
+
[options]="options"
|
|
184
|
+
[(value)]="theme.preference"
|
|
185
|
+
[ariaLabel]="ariaLabel()"
|
|
186
|
+
[fill]="fill()"
|
|
187
|
+
/>
|
|
188
|
+
`,
|
|
189
|
+
isInline: true,
|
|
190
|
+
dependencies: [{
|
|
191
|
+
kind: "component",
|
|
192
|
+
type: UiSegmentedComponent,
|
|
193
|
+
selector: "ui-segmented",
|
|
194
|
+
inputs: [
|
|
195
|
+
"options",
|
|
196
|
+
"value",
|
|
197
|
+
"ariaLabel",
|
|
198
|
+
"fill"
|
|
199
|
+
],
|
|
200
|
+
outputs: ["valueChange"]
|
|
201
|
+
}]
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
205
|
+
minVersion: "12.0.0",
|
|
206
|
+
version: "22.2.1",
|
|
207
|
+
ngImport: i0,
|
|
208
|
+
type: UiThemeSwitchComponent,
|
|
209
|
+
decorators: [{
|
|
210
|
+
type: Component,
|
|
211
|
+
args: [{
|
|
212
|
+
selector: "ui-theme-switch",
|
|
213
|
+
imports: [UiSegmentedComponent],
|
|
214
|
+
host: { "[class.block]": "fill()" },
|
|
215
|
+
template: `
|
|
216
|
+
<ui-segmented
|
|
217
|
+
[options]="options"
|
|
218
|
+
[(value)]="theme.preference"
|
|
219
|
+
[ariaLabel]="ariaLabel()"
|
|
220
|
+
[fill]="fill()"
|
|
221
|
+
/>
|
|
222
|
+
`
|
|
223
|
+
}]
|
|
224
|
+
}],
|
|
225
|
+
propDecorators: {
|
|
226
|
+
ariaLabel: [{
|
|
227
|
+
type: i0.Input,
|
|
228
|
+
args: [{
|
|
229
|
+
isSignal: true,
|
|
230
|
+
alias: "ariaLabel",
|
|
231
|
+
required: false
|
|
232
|
+
}]
|
|
233
|
+
}],
|
|
234
|
+
fill: [{
|
|
235
|
+
type: i0.Input,
|
|
236
|
+
args: [{
|
|
237
|
+
isSignal: true,
|
|
238
|
+
alias: "fill",
|
|
239
|
+
required: false
|
|
240
|
+
}]
|
|
241
|
+
}]
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
export { UI_THEME_CONFIG, UiDarkClass, UiThemeService, UiThemeSwitchComponent, provideUiTheme };
|
|
245
|
+
|
|
246
|
+
//# sourceMappingURL=area8975-ui-theme.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"area8975-ui-theme.mjs","names":[],"sources":["../../../projects/ui/theme/dark-class.ts","../../../projects/ui/theme/theme.ts","../../../projects/ui/theme/theme-switch.component.ts"],"sourcesContent":["import { DOCUMENT } from '@angular/common';\nimport { DestroyRef, inject, Injectable, signal } from '@angular/core';\n\n\n@Injectable({ providedIn: 'root' })\nexport class UiDarkClass {\n readonly isDark = signal(false);\n\n constructor() {\n const root = inject(DOCUMENT).documentElement;\n const read = () => this.isDark.set(root.classList.contains('dark'));\n\n read();\n\n if (typeof MutationObserver === 'undefined') {\n return;\n }\n\n const observer = new MutationObserver(read);\n\n observer.observe(root, { attributes: true, attributeFilter: ['class'] });\n inject(DestroyRef).onDestroy(() => observer.disconnect());\n }\n}\n","import { DOCUMENT } from '@angular/common';\nimport {\n computed,\n DestroyRef,\n effect,\n type EnvironmentProviders,\n inject,\n Injectable,\n InjectionToken,\n makeEnvironmentProviders,\n provideAppInitializer,\n signal\n} from '@angular/core';\n\n\n/** What the user picked, `system` follows the OS setting. */\nexport type UiThemePreference = 'system' | 'light' | 'dark';\n\nexport interface UiThemeConfig {\n storageKey: string;\n}\n\nexport const UI_THEME_CONFIG = new InjectionToken<UiThemeConfig>('UI_THEME_CONFIG', {\n providedIn: 'root',\n factory: () => ({ storageKey: 'ui-theme' })\n});\n\nconst PREFERENCES: readonly UiThemePreference[] = ['system', 'light', 'dark'];\n\n/**\n * Add this to `index.html`'s `<head>` so the stored theme applies before boot:\n *\n * ```html\n * <script>\n * try {\n * const preference = localStorage.getItem('ui-theme') ?? 'system';\n * const dark = preference === 'dark' ||\n * (preference === 'system' && matchMedia('(prefers-color-scheme: dark)').matches);\n * document.documentElement.classList.toggle('dark', dark);\n * } catch {}\n * </script>\n * ```\n */\n@Injectable({ providedIn: 'root' })\nexport class UiThemeService {\n private readonly document = inject(DOCUMENT);\n private readonly storageKey = inject(UI_THEME_CONFIG).storageKey;\n private readonly media = this.document.defaultView?.matchMedia?.('(prefers-color-scheme: dark)');\n\n readonly preference = signal<UiThemePreference>(this.stored());\n\n private readonly systemDark = signal(this.media?.matches ?? false);\n\n readonly isDark = computed(() => {\n const preference = this.preference();\n\n return preference === 'dark' || (preference === 'system' && this.systemDark());\n });\n\n constructor() {\n const onChange = (event: MediaQueryListEvent) => this.systemDark.set(event.matches);\n\n this.media?.addEventListener('change', onChange);\n inject(DestroyRef).onDestroy(() => this.media?.removeEventListener('change', onChange));\n\n effect(() => {\n const root = this.document.documentElement;\n const dark = this.isDark();\n\n root.classList.toggle('dark', dark);\n root.style.colorScheme = dark ? 'dark' : 'light';\n });\n\n effect(() => {\n const preference = this.preference();\n\n try {\n this.document.defaultView?.localStorage.setItem(this.storageKey, preference);\n } catch {\n // storage can be blocked, the theme still applies for this visit\n }\n });\n }\n\n private stored(): UiThemePreference {\n try {\n const value = this.document.defaultView?.localStorage.getItem(this.storageKey);\n\n return PREFERENCES.includes(value as UiThemePreference) ? value as UiThemePreference : 'system';\n } catch {\n return 'system';\n }\n }\n}\n\nexport function provideUiTheme(config: Partial<UiThemeConfig> = {}): EnvironmentProviders {\n return makeEnvironmentProviders([\n { provide: UI_THEME_CONFIG, useValue: { storageKey: 'ui-theme', ...config } },\n provideAppInitializer(() => {\n inject(UiThemeService);\n })\n ]);\n}\n","import { booleanAttribute, Component, inject, input } from '@angular/core';\n\nimport type { SegmentedOption } from '@area8975/ui/segmented';\nimport { UiSegmentedComponent } from '@area8975/ui/segmented';\n\nimport { type UiThemePreference, UiThemeService } from './theme';\n\n\n@Component({\n selector: 'ui-theme-switch',\n imports: [UiSegmentedComponent],\n host: { '[class.block]': 'fill()' },\n template: `\n <ui-segmented\n [options]=\"options\"\n [(value)]=\"theme.preference\"\n [ariaLabel]=\"ariaLabel()\"\n [fill]=\"fill()\"\n />\n `\n})\nexport class UiThemeSwitchComponent {\n protected readonly theme = inject(UiThemeService);\n\n readonly ariaLabel = input<string>('Theme');\n\n readonly fill = input(false, { transform: booleanAttribute });\n\n protected readonly options: SegmentedOption<UiThemePreference>[] = [\n { value: 'system', label: 'System' },\n { value: 'light', label: 'Light' },\n { value: 'dark', label: 'Dark' }\n ];\n}\n"],"mappings":";;;;AAKA,IAAa,cAAb,MAAa,YAAW;CACX,SAAS,OAAO,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,SAAA,CAAA,+BAAA,CAAA,CAAA;CAE/B,cAAA;EACI,MAAM,OAAO,OAAO,QAAQ,CAAC,CAAC;EAC9B,MAAM,aAAa,KAAK,OAAO,IAAI,KAAK,UAAU,SAAS,MAAM,CAAC;EAElE,KAAI;EAEJ,IAAI,OAAO,qBAAqB,aAC5B;EAGJ,MAAM,WAAW,IAAI,iBAAiB,IAAI;EAE1C,SAAS,QAAQ,MAAM;GAAE,YAAY;GAAM,iBAAiB,CAAC,OAAO;EAAC,CAAE;EACvE,OAAO,UAAU,CAAC,CAAC,gBAAgB,SAAS,WAAU,CAAE;CAC5D;CAjBS,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAW,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAX,OAAA,QAAA,GAAA,sBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA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AAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAsB,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAtB,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAsB,cAAA;EAAA,UAAA;EAAA,QAAA;GAAA,WAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,MAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,MAAA,EAAA,YAAA,EAAA,eAAA,SAAA,EAAA;EAAA,UAAA;EAAA,UATrB;;;;;;;;EAOT,UAAA;EAAA,cAAA,CAAA;GAAA,MAAA;GAAA,MATS;GAAoB,UAAA;GAAA,QAAA;IAAA;IAAA;IAAA;IAAA;GAAA;GAAA,SAAA,CAAA,aAAA;EAAA,CAAA;CAAA,CAAA;;AAWrB,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAsB,YAAA,CAAA;EAblC,MAAA;EAAU,MAAA,CAAA;GACP,UAAU;GACV,SAAS,CAAC,oBAAoB;GAC9B,MAAM,EAAE,iBAAiB,SAAQ;GACjC,UAAU;;;;;;;;EAQb,CAAA"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { Component, booleanAttribute, computed, input, model } from "@angular/core";
|
|
3
|
+
import { parseTime, toTime } from "@area8975/ui/calendar";
|
|
4
|
+
import { SelectLocalDataSource, UiSelectComponent } from "@area8975/ui/select";
|
|
5
|
+
import { NgIcon, provideIcons } from "@ng-icons/core";
|
|
6
|
+
import { heroClock } from "@ng-icons/heroicons/outline";
|
|
7
|
+
var UiTimeSelectComponent = class UiTimeSelectComponent {
|
|
8
|
+
value = model("00:00", ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
|
|
9
|
+
minuteStep = input(5, ...ngDevMode ? [{ debugName: "minuteStep" }] : /* istanbul ignore next */ []);
|
|
10
|
+
disabled = input(false, {
|
|
11
|
+
...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
|
|
12
|
+
transform: booleanAttribute
|
|
13
|
+
});
|
|
14
|
+
hours = computed(() => parseTime(this.value())?.hours ?? 0, ...ngDevMode ? [{ debugName: "hours" }] : /* istanbul ignore next */ []);
|
|
15
|
+
minutes = computed(() => parseTime(this.value())?.minutes ?? 0, ...ngDevMode ? [{ debugName: "minutes" }] : /* istanbul ignore next */ []);
|
|
16
|
+
hourSource = new SelectLocalDataSource(Array.from({ length: 24 }, (_, hour) => hour), () => true);
|
|
17
|
+
minuteSource = computed(() => {
|
|
18
|
+
const step = Math.max(1, Math.floor(this.minuteStep()));
|
|
19
|
+
return new SelectLocalDataSource(Array.from({ length: Math.ceil(60 / step) }, (_, index) => index * step), () => true);
|
|
20
|
+
}, ...ngDevMode ? [{ debugName: "minuteSource" }] : /* istanbul ignore next */ []);
|
|
21
|
+
pad = (value) => String(value).padStart(2, "0");
|
|
22
|
+
setHours(hours) {
|
|
23
|
+
if (hours !== null) this.value.set(toTime(hours, this.minutes()));
|
|
24
|
+
}
|
|
25
|
+
setMinutes(minutes) {
|
|
26
|
+
if (minutes !== null) this.value.set(toTime(this.hours(), minutes));
|
|
27
|
+
}
|
|
28
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
29
|
+
minVersion: "12.0.0",
|
|
30
|
+
version: "22.2.1",
|
|
31
|
+
ngImport: i0,
|
|
32
|
+
type: UiTimeSelectComponent,
|
|
33
|
+
deps: [],
|
|
34
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
35
|
+
});
|
|
36
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
37
|
+
minVersion: "17.1.0",
|
|
38
|
+
version: "22.2.1",
|
|
39
|
+
type: UiTimeSelectComponent,
|
|
40
|
+
isStandalone: true,
|
|
41
|
+
selector: "ui-time-select",
|
|
42
|
+
inputs: {
|
|
43
|
+
value: {
|
|
44
|
+
classPropertyName: "value",
|
|
45
|
+
publicName: "value",
|
|
46
|
+
isSignal: true,
|
|
47
|
+
isRequired: false,
|
|
48
|
+
transformFunction: null
|
|
49
|
+
},
|
|
50
|
+
minuteStep: {
|
|
51
|
+
classPropertyName: "minuteStep",
|
|
52
|
+
publicName: "minuteStep",
|
|
53
|
+
isSignal: true,
|
|
54
|
+
isRequired: false,
|
|
55
|
+
transformFunction: null
|
|
56
|
+
},
|
|
57
|
+
disabled: {
|
|
58
|
+
classPropertyName: "disabled",
|
|
59
|
+
publicName: "disabled",
|
|
60
|
+
isSignal: true,
|
|
61
|
+
isRequired: false,
|
|
62
|
+
transformFunction: null
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
outputs: { value: "valueChange" },
|
|
66
|
+
host: { classAttribute: "inline-flex items-center gap-x-1" },
|
|
67
|
+
providers: [provideIcons({ heroClock })],
|
|
68
|
+
ngImport: i0,
|
|
69
|
+
template: "<ng-icon name=\"heroClock\" class=\"me-1 text-muted-foreground-1 shrink-0\" />\n\n<ui-select\n class=\"ui-time-select-part\"\n [dataSource]=\"hourSource\"\n [displayWith]=\"pad\"\n [pageSize]=\"24\"\n [selectedItem]=\"hours()\"\n [disabled]=\"disabled()\"\n (selectionChange)=\"setHours($event)\"\n/>\n\n<span class=\"text-muted-foreground-1\" aria-hidden=\"true\">:</span>\n\n<ui-select\n class=\"ui-time-select-part\"\n [dataSource]=\"minuteSource()\"\n [displayWith]=\"pad\"\n [pageSize]=\"60\"\n [selectedItem]=\"minutes()\"\n [disabled]=\"disabled()\"\n (selectionChange)=\"setMinutes($event)\"\n/>\n",
|
|
70
|
+
styles: [".ui-time-select-part{width:calc(var(--spacing, .25rem) * 20);flex-shrink:0}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"],
|
|
71
|
+
dependencies: [{
|
|
72
|
+
kind: "component",
|
|
73
|
+
type: UiSelectComponent,
|
|
74
|
+
selector: "ui-select",
|
|
75
|
+
inputs: [
|
|
76
|
+
"placement",
|
|
77
|
+
"closeBehaviour",
|
|
78
|
+
"dataSource",
|
|
79
|
+
"placeholder",
|
|
80
|
+
"id",
|
|
81
|
+
"describedBy",
|
|
82
|
+
"pageSize",
|
|
83
|
+
"searchMode",
|
|
84
|
+
"disabled",
|
|
85
|
+
"validationState",
|
|
86
|
+
"clearable",
|
|
87
|
+
"clearLabel",
|
|
88
|
+
"creatable",
|
|
89
|
+
"createLabel",
|
|
90
|
+
"groupBy",
|
|
91
|
+
"scrollToSelected",
|
|
92
|
+
"multiple",
|
|
93
|
+
"multipleDisplay",
|
|
94
|
+
"counterAfter",
|
|
95
|
+
"counterLabel",
|
|
96
|
+
"compareWith",
|
|
97
|
+
"displayWith",
|
|
98
|
+
"selectedItem",
|
|
99
|
+
"selectedItems"
|
|
100
|
+
],
|
|
101
|
+
outputs: [
|
|
102
|
+
"validationStateChange",
|
|
103
|
+
"selectionChange",
|
|
104
|
+
"create",
|
|
105
|
+
"selectedItemChange",
|
|
106
|
+
"selectedItemsChange"
|
|
107
|
+
]
|
|
108
|
+
}, {
|
|
109
|
+
kind: "component",
|
|
110
|
+
type: NgIcon,
|
|
111
|
+
selector: "ng-icon",
|
|
112
|
+
inputs: [
|
|
113
|
+
"name",
|
|
114
|
+
"svg",
|
|
115
|
+
"size",
|
|
116
|
+
"strokeWidth",
|
|
117
|
+
"color"
|
|
118
|
+
]
|
|
119
|
+
}]
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
123
|
+
minVersion: "12.0.0",
|
|
124
|
+
version: "22.2.1",
|
|
125
|
+
ngImport: i0,
|
|
126
|
+
type: UiTimeSelectComponent,
|
|
127
|
+
decorators: [{
|
|
128
|
+
type: Component,
|
|
129
|
+
args: [{
|
|
130
|
+
selector: "ui-time-select",
|
|
131
|
+
imports: [UiSelectComponent, NgIcon],
|
|
132
|
+
host: { class: "inline-flex items-center gap-x-1" },
|
|
133
|
+
providers: [provideIcons({ heroClock })],
|
|
134
|
+
template: "<ng-icon name=\"heroClock\" class=\"me-1 text-muted-foreground-1 shrink-0\" />\n\n<ui-select\n class=\"ui-time-select-part\"\n [dataSource]=\"hourSource\"\n [displayWith]=\"pad\"\n [pageSize]=\"24\"\n [selectedItem]=\"hours()\"\n [disabled]=\"disabled()\"\n (selectionChange)=\"setHours($event)\"\n/>\n\n<span class=\"text-muted-foreground-1\" aria-hidden=\"true\">:</span>\n\n<ui-select\n class=\"ui-time-select-part\"\n [dataSource]=\"minuteSource()\"\n [displayWith]=\"pad\"\n [pageSize]=\"60\"\n [selectedItem]=\"minutes()\"\n [disabled]=\"disabled()\"\n (selectionChange)=\"setMinutes($event)\"\n/>\n",
|
|
135
|
+
styles: [".ui-time-select-part{width:calc(var(--spacing, .25rem) * 20);flex-shrink:0}\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n"]
|
|
136
|
+
}]
|
|
137
|
+
}],
|
|
138
|
+
propDecorators: {
|
|
139
|
+
value: [{
|
|
140
|
+
type: i0.Input,
|
|
141
|
+
args: [{
|
|
142
|
+
isSignal: true,
|
|
143
|
+
alias: "value",
|
|
144
|
+
required: false
|
|
145
|
+
}]
|
|
146
|
+
}, {
|
|
147
|
+
type: i0.Output,
|
|
148
|
+
args: ["valueChange"]
|
|
149
|
+
}],
|
|
150
|
+
minuteStep: [{
|
|
151
|
+
type: i0.Input,
|
|
152
|
+
args: [{
|
|
153
|
+
isSignal: true,
|
|
154
|
+
alias: "minuteStep",
|
|
155
|
+
required: false
|
|
156
|
+
}]
|
|
157
|
+
}],
|
|
158
|
+
disabled: [{
|
|
159
|
+
type: i0.Input,
|
|
160
|
+
args: [{
|
|
161
|
+
isSignal: true,
|
|
162
|
+
alias: "disabled",
|
|
163
|
+
required: false
|
|
164
|
+
}]
|
|
165
|
+
}]
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
export { UiTimeSelectComponent };
|
|
169
|
+
|
|
170
|
+
//# sourceMappingURL=area8975-ui-time-select.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"area8975-ui-time-select.mjs","names":[],"sources":["../../../projects/ui/time-select/time-select.component.ts","../../../projects/ui/time-select/time-select.component.html"],"sourcesContent":["import {\n booleanAttribute,\n Component,\n computed,\n input,\n model\n} from '@angular/core';\n\nimport { parseTime, toTime } from '@area8975/ui/calendar';\nimport { UiSelectComponent } from '@area8975/ui/select';\nimport { SelectLocalDataSource } from '@area8975/ui/select';\nimport { NgIcon, provideIcons } from '@ng-icons/core';\nimport { heroClock } from '@ng-icons/heroicons/outline';\n\n\n@Component({\n selector: 'ui-time-select',\n templateUrl: './time-select.component.html',\n styleUrl: './time-select.component.css',\n imports: [UiSelectComponent, NgIcon],\n host: { class: 'inline-flex items-center gap-x-1' },\n providers: [provideIcons({ heroClock })]\n})\nexport class UiTimeSelectComponent {\n /** 24 hour \"HH:mm\" string. */\n readonly value = model<string>('00:00');\n\n readonly minuteStep = input<number>(5);\n readonly disabled = input(false, { transform: booleanAttribute });\n\n protected readonly hours = computed(() =>\n parseTime(this.value())?.hours ?? 0\n );\n protected readonly minutes = computed(() =>\n parseTime(this.value())?.minutes ?? 0\n );\n\n protected readonly hourSource = new SelectLocalDataSource(\n Array.from({ length: 24 }, (_, hour) => hour),\n () => true\n );\n\n protected readonly minuteSource = computed(() => {\n const step = Math.max(1, Math.floor(this.minuteStep()));\n\n return new SelectLocalDataSource(\n Array.from(\n { length: Math.ceil(60 / step) },\n (_, index) => index * step\n ),\n () => true\n );\n });\n\n protected readonly pad = (value: number) => String(value).padStart(2, '0');\n\n protected setHours(hours: number | null): void {\n if (hours !== null) {\n this.value.set(toTime(hours, this.minutes()));\n }\n }\n\n protected setMinutes(minutes: number | null): void {\n if (minutes !== null) {\n this.value.set(toTime(this.hours(), minutes));\n }\n }\n}\n","<ng-icon name=\"heroClock\" class=\"me-1 text-muted-foreground-1 shrink-0\" />\n\n<ui-select\n class=\"ui-time-select-part\"\n [dataSource]=\"hourSource\"\n [displayWith]=\"pad\"\n [pageSize]=\"24\"\n [selectedItem]=\"hours()\"\n [disabled]=\"disabled()\"\n (selectionChange)=\"setHours($event)\"\n/>\n\n<span class=\"text-muted-foreground-1\" aria-hidden=\"true\">:</span>\n\n<ui-select\n class=\"ui-time-select-part\"\n [dataSource]=\"minuteSource()\"\n [displayWith]=\"pad\"\n [pageSize]=\"60\"\n [selectedItem]=\"minutes()\"\n [disabled]=\"disabled()\"\n (selectionChange)=\"setMinutes($event)\"\n/>\n"],"mappings":";;;;;;AAuBA,IAAa,wBAAb,MAAa,sBAAqB;CAErB,QAAQ,MAAc,SAAQ,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CAE9B,aAAa,MAAc,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,aAAA,CAAA,+BAAA,CAAA,CAAA;CAC7B,WAAW,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,WAAA,+BAAA,CAAA;EAAI,WAAW;CAAgB,CAAA;CAE3C,QAAQ,eACvB,UAAU,KAAK,MAAK,CAAE,CAAC,EAAE,SAAS,GACrC,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CACkB,UAAU,eACzB,UAAU,KAAK,MAAK,CAAE,CAAC,EAAE,WAAW,GACvC,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAEkB,aAAa,IAAI,sBAChC,MAAM,KAAK,EAAE,QAAQ,GAAE,IAAK,GAAG,SAAS,IAAI,SACtC,IAAI;CAGK,eAAe,eAAc;EAC5C,MAAM,OAAO,KAAK,IAAI,GAAG,KAAK,MAAM,KAAK,WAAU,CAAE,CAAC;EAEtD,OAAO,IAAI,sBACP,MAAM,KACF,EAAE,QAAQ,K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