cmat 0.0.111 → 0.0.113

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 (256) hide show
  1. package/fesm2022/cmat-components-adapter.mjs +531 -536
  2. package/fesm2022/cmat-components-adapter.mjs.map +1 -1
  3. package/fesm2022/cmat-components-breadcrumb.mjs +521 -356
  4. package/fesm2022/cmat-components-breadcrumb.mjs.map +1 -1
  5. package/fesm2022/cmat-components-card.mjs +150 -42
  6. package/fesm2022/cmat-components-card.mjs.map +1 -1
  7. package/fesm2022/cmat-components-carousel.mjs +1120 -629
  8. package/fesm2022/cmat-components-carousel.mjs.map +1 -1
  9. package/fesm2022/cmat-components-cascade.mjs +861 -441
  10. package/fesm2022/cmat-components-cascade.mjs.map +1 -1
  11. package/fesm2022/cmat-components-chip-input.mjs +580 -335
  12. package/fesm2022/cmat-components-chip-input.mjs.map +1 -1
  13. package/fesm2022/cmat-components-code-editor.mjs +197 -105
  14. package/fesm2022/cmat-components-code-editor.mjs.map +1 -1
  15. package/fesm2022/cmat-components-color-picker.mjs +1762 -825
  16. package/fesm2022/cmat-components-color-picker.mjs.map +1 -1
  17. package/fesm2022/cmat-components-custom-formly.mjs +5196 -2531
  18. package/fesm2022/cmat-components-custom-formly.mjs.map +1 -1
  19. package/fesm2022/cmat-components-data-picker.mjs +1901 -1073
  20. package/fesm2022/cmat-components-data-picker.mjs.map +1 -1
  21. package/fesm2022/cmat-components-date-range.mjs +701 -456
  22. package/fesm2022/cmat-components-date-range.mjs.map +1 -1
  23. package/fesm2022/cmat-components-date-time-display.mjs +137 -30
  24. package/fesm2022/cmat-components-date-time-display.mjs.map +1 -1
  25. package/fesm2022/cmat-components-drawer.mjs +410 -258
  26. package/fesm2022/cmat-components-drawer.mjs.map +1 -1
  27. package/fesm2022/cmat-components-empty-state.mjs +201 -41
  28. package/fesm2022/cmat-components-empty-state.mjs.map +1 -1
  29. package/fesm2022/cmat-components-file-preview.mjs +198 -35
  30. package/fesm2022/cmat-components-file-preview.mjs.map +1 -1
  31. package/fesm2022/cmat-components-filter-toolbar.mjs +320 -72
  32. package/fesm2022/cmat-components-filter-toolbar.mjs.map +1 -1
  33. package/fesm2022/cmat-components-form-actions.mjs +102 -26
  34. package/fesm2022/cmat-components-form-actions.mjs.map +1 -1
  35. package/fesm2022/cmat-components-fullscreen.mjs +167 -47
  36. package/fesm2022/cmat-components-fullscreen.mjs.map +1 -1
  37. package/fesm2022/cmat-components-highlight.mjs +203 -112
  38. package/fesm2022/cmat-components-highlight.mjs.map +1 -1
  39. package/fesm2022/cmat-components-image-viewer.mjs +489 -215
  40. package/fesm2022/cmat-components-image-viewer.mjs.map +1 -1
  41. package/fesm2022/cmat-components-inline-loading.mjs +117 -27
  42. package/fesm2022/cmat-components-inline-loading.mjs.map +1 -1
  43. package/fesm2022/cmat-components-json-editor.mjs +276 -230
  44. package/fesm2022/cmat-components-json-editor.mjs.map +1 -1
  45. package/fesm2022/cmat-components-knob-input.mjs +615 -420
  46. package/fesm2022/cmat-components-knob-input.mjs.map +1 -1
  47. package/fesm2022/cmat-components-loading-overlay.mjs +53 -25
  48. package/fesm2022/cmat-components-loading-overlay.mjs.map +1 -1
  49. package/fesm2022/cmat-components-masonry.mjs +120 -40
  50. package/fesm2022/cmat-components-masonry.mjs.map +1 -1
  51. package/fesm2022/cmat-components-material-color-picker.mjs +332 -155
  52. package/fesm2022/cmat-components-material-color-picker.mjs.map +1 -1
  53. package/fesm2022/cmat-components-material-datetimepicker.mjs +4283 -2504
  54. package/fesm2022/cmat-components-material-datetimepicker.mjs.map +1 -1
  55. package/fesm2022/cmat-components-navigation.mjs +3080 -1404
  56. package/fesm2022/cmat-components-navigation.mjs.map +1 -1
  57. package/fesm2022/cmat-components-opt-input.mjs +540 -466
  58. package/fesm2022/cmat-components-opt-input.mjs.map +1 -1
  59. package/fesm2022/cmat-components-org-chart.mjs +528 -125
  60. package/fesm2022/cmat-components-org-chart.mjs.map +1 -1
  61. package/fesm2022/cmat-components-page-header.mjs +141 -32
  62. package/fesm2022/cmat-components-page-header.mjs.map +1 -1
  63. package/fesm2022/cmat-components-pagination.mjs +866 -534
  64. package/fesm2022/cmat-components-pagination.mjs.map +1 -1
  65. package/fesm2022/cmat-components-password-strength.mjs +873 -434
  66. package/fesm2022/cmat-components-password-strength.mjs.map +1 -1
  67. package/fesm2022/cmat-components-popover.mjs +1012 -731
  68. package/fesm2022/cmat-components-popover.mjs.map +1 -1
  69. package/fesm2022/cmat-components-progress-bar.mjs +98 -35
  70. package/fesm2022/cmat-components-progress-bar.mjs.map +1 -1
  71. package/fesm2022/cmat-components-qrcode.mjs +463 -287
  72. package/fesm2022/cmat-components-qrcode.mjs.map +1 -1
  73. package/fesm2022/cmat-components-rating.mjs +377 -203
  74. package/fesm2022/cmat-components-rating.mjs.map +1 -1
  75. package/fesm2022/cmat-components-rich-text-editor.mjs +153 -39
  76. package/fesm2022/cmat-components-rich-text-editor.mjs.map +1 -1
  77. package/fesm2022/cmat-components-select-search.mjs +926 -496
  78. package/fesm2022/cmat-components-select-search.mjs.map +1 -1
  79. package/fesm2022/cmat-components-select-table.mjs +1280 -842
  80. package/fesm2022/cmat-components-select-table.mjs.map +1 -1
  81. package/fesm2022/cmat-components-select-tree.mjs +998 -690
  82. package/fesm2022/cmat-components-select-tree.mjs.map +1 -1
  83. package/fesm2022/cmat-components-skeleton.mjs +143 -57
  84. package/fesm2022/cmat-components-skeleton.mjs.map +1 -1
  85. package/fesm2022/cmat-components-speed-dial.mjs +457 -303
  86. package/fesm2022/cmat-components-speed-dial.mjs.map +1 -1
  87. package/fesm2022/cmat-components-status-tag.mjs +136 -44
  88. package/fesm2022/cmat-components-status-tag.mjs.map +1 -1
  89. package/fesm2022/cmat-components-table-toolbar.mjs +120 -28
  90. package/fesm2022/cmat-components-table-toolbar.mjs.map +1 -1
  91. package/fesm2022/cmat-components-timeline.mjs +464 -168
  92. package/fesm2022/cmat-components-timeline.mjs.map +1 -1
  93. package/fesm2022/cmat-components-toast.mjs +346 -262
  94. package/fesm2022/cmat-components-toast.mjs.map +1 -1
  95. package/fesm2022/cmat-components-transfer-picker.mjs +1427 -593
  96. package/fesm2022/cmat-components-transfer-picker.mjs.map +1 -1
  97. package/fesm2022/cmat-components-treetable.mjs +372 -112
  98. package/fesm2022/cmat-components-treetable.mjs.map +1 -1
  99. package/fesm2022/cmat-components-upload.mjs +904 -410
  100. package/fesm2022/cmat-components-upload.mjs.map +1 -1
  101. package/fesm2022/cmat-components-x6-angular-shape.mjs +153 -170
  102. package/fesm2022/cmat-components-x6-angular-shape.mjs.map +1 -1
  103. package/fesm2022/cmat-directives-animate-on-scroll.mjs +220 -138
  104. package/fesm2022/cmat-directives-animate-on-scroll.mjs.map +1 -1
  105. package/fesm2022/cmat-directives-arrow-cursor.mjs +246 -193
  106. package/fesm2022/cmat-directives-arrow-cursor.mjs.map +1 -1
  107. package/fesm2022/cmat-directives-autofocus.mjs +43 -25
  108. package/fesm2022/cmat-directives-autofocus.mjs.map +1 -1
  109. package/fesm2022/cmat-directives-data-exporter.mjs +537 -338
  110. package/fesm2022/cmat-directives-data-exporter.mjs.map +1 -1
  111. package/fesm2022/cmat-directives-debounce.mjs +162 -76
  112. package/fesm2022/cmat-directives-debounce.mjs.map +1 -1
  113. package/fesm2022/cmat-directives-digit-only.mjs +457 -356
  114. package/fesm2022/cmat-directives-digit-only.mjs.map +1 -1
  115. package/fesm2022/cmat-directives-equal-validator.mjs +70 -53
  116. package/fesm2022/cmat-directives-equal-validator.mjs.map +1 -1
  117. package/fesm2022/cmat-directives-seamless-auto-scroll.mjs +180 -132
  118. package/fesm2022/cmat-directives-seamless-auto-scroll.mjs.map +1 -1
  119. package/fesm2022/cmat-lib-mock-api.mjs +207 -195
  120. package/fesm2022/cmat-lib-mock-api.mjs.map +1 -1
  121. package/fesm2022/cmat-pipes-bytes.mjs +50 -30
  122. package/fesm2022/cmat-pipes-bytes.mjs.map +1 -1
  123. package/fesm2022/cmat-pipes-date-format.mjs +41 -25
  124. package/fesm2022/cmat-pipes-date-format.mjs.map +1 -1
  125. package/fesm2022/cmat-pipes-find-by-key.mjs +44 -26
  126. package/fesm2022/cmat-pipes-find-by-key.mjs.map +1 -1
  127. package/fesm2022/cmat-pipes-group-by.mjs +50 -38
  128. package/fesm2022/cmat-pipes-group-by.mjs.map +1 -1
  129. package/fesm2022/cmat-pipes-keys.mjs +44 -31
  130. package/fesm2022/cmat-pipes-keys.mjs.map +1 -1
  131. package/fesm2022/cmat-pipes-secure.mjs +60 -49
  132. package/fesm2022/cmat-pipes-secure.mjs.map +1 -1
  133. package/fesm2022/cmat-pipes-uppercase.mjs +39 -22
  134. package/fesm2022/cmat-pipes-uppercase.mjs.map +1 -1
  135. package/fesm2022/cmat-reports.mjs +2761 -0
  136. package/fesm2022/cmat-reports.mjs.map +1 -0
  137. package/fesm2022/cmat-services-alert.mjs +249 -277
  138. package/fesm2022/cmat-services-alert.mjs.map +1 -1
  139. package/fesm2022/cmat-services-config.mjs +110 -81
  140. package/fesm2022/cmat-services-config.mjs.map +1 -1
  141. package/fesm2022/cmat-services-confirmation.mjs +184 -73
  142. package/fesm2022/cmat-services-confirmation.mjs.map +1 -1
  143. package/fesm2022/cmat-services-data.mjs +136 -125
  144. package/fesm2022/cmat-services-data.mjs.map +1 -1
  145. package/fesm2022/cmat-services-export-as.mjs +165 -183
  146. package/fesm2022/cmat-services-export-as.mjs.map +1 -1
  147. package/fesm2022/cmat-services-loading.mjs +116 -95
  148. package/fesm2022/cmat-services-loading.mjs.map +1 -1
  149. package/fesm2022/cmat-services-local-storage.mjs +75 -66
  150. package/fesm2022/cmat-services-local-storage.mjs.map +1 -1
  151. package/fesm2022/cmat-services-media-watcher.mjs +69 -64
  152. package/fesm2022/cmat-services-media-watcher.mjs.map +1 -1
  153. package/fesm2022/cmat-services-platform.mjs +48 -45
  154. package/fesm2022/cmat-services-platform.mjs.map +1 -1
  155. package/fesm2022/cmat-services-print.mjs +984 -1109
  156. package/fesm2022/cmat-services-print.mjs.map +1 -1
  157. package/fesm2022/cmat-services-splash-screen.mjs +53 -38
  158. package/fesm2022/cmat-services-splash-screen.mjs.map +1 -1
  159. package/fesm2022/cmat-services-title.mjs +57 -47
  160. package/fesm2022/cmat-services-title.mjs.map +1 -1
  161. package/fesm2022/cmat-services-translation.mjs +79 -68
  162. package/fesm2022/cmat-services-translation.mjs.map +1 -1
  163. package/fesm2022/cmat-services-utils.mjs +424 -517
  164. package/fesm2022/cmat-services-utils.mjs.map +1 -1
  165. package/fesm2022/cmat-validators.mjs +23 -33
  166. package/fesm2022/cmat-validators.mjs.map +1 -1
  167. package/fesm2022/cmat-version.mjs +12 -16
  168. package/fesm2022/cmat-version.mjs.map +1 -1
  169. package/fesm2022/cmat.mjs +39805 -22511
  170. package/fesm2022/cmat.mjs.map +1 -1
  171. package/package.json +5 -1
  172. package/types/cmat-components-adapter.d.ts +145 -156
  173. package/types/cmat-components-breadcrumb.d.ts +108 -86
  174. package/types/cmat-components-card.d.ts +34 -18
  175. package/types/cmat-components-carousel.d.ts +251 -134
  176. package/types/cmat-components-cascade.d.ts +158 -117
  177. package/types/cmat-components-chip-input.d.ts +105 -71
  178. package/types/cmat-components-code-editor.d.ts +59 -34
  179. package/types/cmat-components-color-picker.d.ts +378 -236
  180. package/types/cmat-components-custom-formly.d.ts +776 -814
  181. package/types/cmat-components-data-picker.d.ts +502 -360
  182. package/types/cmat-components-date-range.d.ts +106 -77
  183. package/types/cmat-components-date-time-display.d.ts +36 -13
  184. package/types/cmat-components-drawer.d.ts +91 -61
  185. package/types/cmat-components-empty-state.d.ts +47 -17
  186. package/types/cmat-components-file-preview.d.ts +42 -14
  187. package/types/cmat-components-filter-toolbar.d.ts +57 -25
  188. package/types/cmat-components-form-actions.d.ts +18 -10
  189. package/types/cmat-components-fullscreen.d.ts +21 -13
  190. package/types/cmat-components-highlight.d.ts +33 -26
  191. package/types/cmat-components-image-viewer.d.ts +119 -58
  192. package/types/cmat-components-inline-loading.d.ts +24 -11
  193. package/types/cmat-components-json-editor.d.ts +39 -28
  194. package/types/cmat-components-knob-input.d.ts +172 -101
  195. package/types/cmat-components-loading-overlay.d.ts +8 -11
  196. package/types/cmat-components-masonry.d.ts +27 -14
  197. package/types/cmat-components-material-color-picker.d.ts +56 -42
  198. package/types/cmat-components-material-datetimepicker.d.ts +817 -454
  199. package/types/cmat-components-navigation.d.ts +295 -221
  200. package/types/cmat-components-opt-input.d.ts +111 -90
  201. package/types/cmat-components-org-chart.d.ts +53 -35
  202. package/types/cmat-components-page-header.d.ts +37 -14
  203. package/types/cmat-components-pagination.d.ts +144 -107
  204. package/types/cmat-components-password-strength.d.ts +197 -86
  205. package/types/cmat-components-popover.d.ts +264 -166
  206. package/types/cmat-components-progress-bar.d.ts +17 -14
  207. package/types/cmat-components-qrcode.d.ts +111 -42
  208. package/types/cmat-components-rating.d.ts +105 -59
  209. package/types/cmat-components-rich-text-editor.d.ts +39 -16
  210. package/types/cmat-components-select-search.d.ts +195 -99
  211. package/types/cmat-components-select-table.d.ts +241 -142
  212. package/types/cmat-components-select-tree.d.ts +185 -118
  213. package/types/cmat-components-skeleton.d.ts +55 -32
  214. package/types/cmat-components-speed-dial.d.ts +86 -61
  215. package/types/cmat-components-status-tag.d.ts +42 -24
  216. package/types/cmat-components-table-toolbar.d.ts +30 -12
  217. package/types/cmat-components-timeline.d.ts +83 -51
  218. package/types/cmat-components-toast.d.ts +84 -85
  219. package/types/cmat-components-transfer-picker.d.ts +228 -181
  220. package/types/cmat-components-treetable.d.ts +63 -39
  221. package/types/cmat-components-upload.d.ts +205 -106
  222. package/types/cmat-components-x6-angular-shape.d.ts +29 -37
  223. package/types/cmat-directives-animate-on-scroll.d.ts +48 -30
  224. package/types/cmat-directives-arrow-cursor.d.ts +55 -35
  225. package/types/cmat-directives-autofocus.d.ts +8 -11
  226. package/types/cmat-directives-data-exporter.d.ts +71 -40
  227. package/types/cmat-directives-debounce.d.ts +31 -28
  228. package/types/cmat-directives-digit-only.d.ts +90 -53
  229. package/types/cmat-directives-equal-validator.d.ts +11 -14
  230. package/types/cmat-directives-seamless-auto-scroll.d.ts +42 -29
  231. package/types/cmat-lib-mock-api.d.ts +46 -55
  232. package/types/cmat-pipes-bytes.d.ts +7 -10
  233. package/types/cmat-pipes-date-format.d.ts +7 -10
  234. package/types/cmat-pipes-find-by-key.d.ts +8 -12
  235. package/types/cmat-pipes-group-by.d.ts +11 -15
  236. package/types/cmat-pipes-keys.d.ts +10 -13
  237. package/types/cmat-pipes-secure.d.ts +14 -17
  238. package/types/cmat-pipes-uppercase.d.ts +7 -10
  239. package/types/cmat-reports.d.ts +1138 -0
  240. package/types/cmat-services-alert.d.ts +80 -87
  241. package/types/cmat-services-config.d.ts +37 -43
  242. package/types/cmat-services-confirmation.d.ts +31 -37
  243. package/types/cmat-services-data.d.ts +18 -21
  244. package/types/cmat-services-export-as.d.ts +28 -33
  245. package/types/cmat-services-loading.d.ts +27 -31
  246. package/types/cmat-services-local-storage.d.ts +17 -21
  247. package/types/cmat-services-media-watcher.d.ts +14 -18
  248. package/types/cmat-services-platform.d.ts +8 -11
  249. package/types/cmat-services-print.d.ts +97 -102
  250. package/types/cmat-services-splash-screen.d.ts +11 -14
  251. package/types/cmat-services-title.d.ts +9 -12
  252. package/types/cmat-services-translation.d.ts +19 -22
  253. package/types/cmat-services-utils.d.ts +76 -80
  254. package/types/cmat-validators.d.ts +5 -8
  255. package/types/cmat-version.d.ts +8 -10
  256. package/types/cmat.d.ts +7551 -5204
@@ -1,139 +1,221 @@
1
- import * as i0 from '@angular/core';
2
- import { Injectable, input, inject, ElementRef, Renderer2, Directive } from '@angular/core';
3
- import { Subscription, EMPTY, fromEvent } from 'rxjs';
4
-
5
- class ScrollService {
6
- constructor() {
7
- this._scrollSub = new Subscription();
8
- this._resizeSub = new Subscription();
9
- this.manageScrollPos();
10
- this.scrollObs =
11
- typeof window !== 'undefined' ? fromEvent(window, 'scroll') : EMPTY;
12
- this._scrollSub = this.scrollObs.subscribe(() => this.manageScrollPos());
13
- this.resizeObs =
14
- typeof window !== 'undefined' ? fromEvent(window, 'resize') : EMPTY;
15
- this._resizeSub = this.resizeObs.subscribe(() => this.manageScrollPos());
16
- }
17
- ngOnDestroy() {
18
- this._scrollSub.unsubscribe();
19
- this._resizeSub.unsubscribe();
20
- }
21
- manageScrollPos() {
22
- this.pos = typeof window !== 'undefined' ? window.scrollY : 0;
23
- }
24
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ScrollService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
25
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ScrollService, providedIn: 'root' }); }
26
- }
27
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ScrollService, decorators: [{
28
- type: Injectable,
29
- args: [{
30
- providedIn: 'root'
31
- }]
32
- }], ctorParameters: () => [] });
33
-
34
- class CmatAnimationOnScrollDirective {
35
- constructor() {
36
- this.animationName = input(null, /* @ts-ignore */
37
- ...(ngDevMode ? [{ debugName: "animationName" }] : /* istanbul ignore next */ [])); // use fadeIn as default if not specified, specify null for no animation
38
- this.offset = input(80, /* @ts-ignore */
39
- ...(ngDevMode ? [{ debugName: "offset" }] : /* istanbul ignore next */ [])); // for scroll Listener
40
- this.useScroll = input(/* @ts-ignore */
41
- ...(ngDevMode ? [undefined, { debugName: "useScroll" }] : /* istanbul ignore next */ []));
42
- this.threshold = input(/* @ts-ignore */
43
- ...(ngDevMode ? [undefined, { debugName: "threshold" }] : /* istanbul ignore next */ [])); // for intersection observer only for the time being
44
- this._scrollSub = new Subscription();
45
- this._resizeSub = new Subscription();
46
- this._elementRef = inject(ElementRef);
47
- this._renderer = inject(Renderer2);
48
- this._scroll = inject(ScrollService);
49
- }
50
- get id() {
51
- return this._elementRef.nativeElement.id;
52
- }
53
- ngOnInit() {
54
- if (!this.animationName()) {
55
- return;
56
- }
57
- this._isVisible = false;
58
- const shouldUseScroll = this.useScroll() ?? (this.useScroll() === false ? false : true);
59
- const thresholdValue = this.threshold() ?? 0.5;
60
- if ('IntersectionObserver' in window && shouldUseScroll) {
61
- const options = {
62
- root: null,
63
- threshold: thresholdValue,
64
- rootMargin: '0px',
65
- };
66
- const observer = new IntersectionObserver((entries) => {
67
- entries.forEach((entry) => {
68
- if (!entry.isIntersecting) {
69
- return;
70
- }
71
- this.addAnimationClass();
72
- });
73
- }, options);
74
- observer.observe(this._elementRef.nativeElement);
75
- return;
76
- }
77
- this._scrollSub = this._scroll.scrollObs.subscribe(() => this.manageVisibility());
78
- this._resizeSub = this._scroll.resizeObs.subscribe(() => this.manageVisibility());
79
- }
80
- ngAfterViewInit() {
81
- setTimeout(() => this.manageVisibility(), 1);
82
- }
83
- ngOnDestroy() {
84
- this._scrollSub.unsubscribe();
85
- this._resizeSub.unsubscribe();
86
- }
87
- manageVisibility() {
88
- if (this._isVisible) {
89
- return;
90
- }
91
- this.getWinHeight();
92
- this.getOffsetTop();
93
- const scrollTrigger = this._offsetTop + this.offset() - this._winHeight;
94
- if (this._scroll.pos >= scrollTrigger) {
95
- this.addAnimationClass();
96
- }
97
- }
98
- addAnimationClass() {
99
- if (!this.animationName()) {
100
- return;
101
- }
102
- this._isVisible = true;
103
- this.setClass(this.animationName());
104
- }
105
- setClass(classes) {
106
- for (const c of classes.split(' ')) {
107
- this._renderer.addClass(this._elementRef.nativeElement, c);
108
- }
109
- }
110
- getWinHeight() {
111
- this._winHeight = typeof window !== 'undefined' ? window.innerHeight : 0;
112
- }
113
- getOffsetTop() {
114
- if (typeof this._elementRef.nativeElement.getBoundingClientRect === 'function') {
115
- const viewportTop = this._elementRef.nativeElement.getBoundingClientRect().top;
116
- const clientTop = this._elementRef.nativeElement.clientTop;
117
- this._offsetTop = viewportTop + this._scroll.pos - clientTop;
118
- }
119
- else {
120
- this._offsetTop = 0;
121
- }
122
- }
123
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatAnimationOnScrollDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
124
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.2.0", type: CmatAnimationOnScrollDirective, isStandalone: true, selector: "[cmatAnimateOnScroll]", inputs: { animationName: { classPropertyName: "animationName", publicName: "animationName", isSignal: true, isRequired: false, transformFunction: null }, offset: { classPropertyName: "offset", publicName: "offset", isSignal: true, isRequired: false, transformFunction: null }, useScroll: { classPropertyName: "useScroll", publicName: "useScroll", isSignal: true, isRequired: false, transformFunction: null }, threshold: { classPropertyName: "threshold", publicName: "threshold", isSignal: true, isRequired: false, transformFunction: null } }, providers: [ScrollService], ngImport: i0 }); }
125
- }
126
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatAnimationOnScrollDirective, decorators: [{
127
- type: Directive,
128
- args: [{
129
- selector: '[cmatAnimateOnScroll]',
130
- providers: [ScrollService]
131
- }]
132
- }], propDecorators: { animationName: [{ type: i0.Input, args: [{ isSignal: true, alias: "animationName", required: false }] }], offset: [{ type: i0.Input, args: [{ isSignal: true, alias: "offset", required: false }] }], useScroll: [{ type: i0.Input, args: [{ isSignal: true, alias: "useScroll", required: false }] }], threshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "threshold", required: false }] }] } });
133
-
134
- /**
135
- * Generated bundle index. Do not edit.
136
- */
137
-
1
+ import * as i0 from "@angular/core";
2
+ import { Directive, ElementRef, Injectable, Renderer2, inject, input } from "@angular/core";
3
+ import { EMPTY, Subscription, fromEvent } from "rxjs";
4
+ var ScrollService = class ScrollService {
5
+ constructor() {
6
+ this._scrollSub = new Subscription();
7
+ this._resizeSub = new Subscription();
8
+ this.manageScrollPos();
9
+ this.scrollObs = typeof window !== "undefined" ? fromEvent(window, "scroll") : EMPTY;
10
+ this._scrollSub = this.scrollObs.subscribe(() => this.manageScrollPos());
11
+ this.resizeObs = typeof window !== "undefined" ? fromEvent(window, "resize") : EMPTY;
12
+ this._resizeSub = this.resizeObs.subscribe(() => this.manageScrollPos());
13
+ }
14
+ ngOnDestroy() {
15
+ this._scrollSub.unsubscribe();
16
+ this._resizeSub.unsubscribe();
17
+ }
18
+ manageScrollPos() {
19
+ this.pos = typeof window !== "undefined" ? window.scrollY : 0;
20
+ }
21
+ static {
22
+ this.ɵfac = i0.ɵɵngDeclareFactory({
23
+ minVersion: "12.0.0",
24
+ version: "22.2.3",
25
+ ngImport: i0,
26
+ type: ScrollService,
27
+ deps: [],
28
+ target: i0.ɵɵFactoryTarget.Injectable
29
+ });
30
+ }
31
+ static {
32
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
33
+ minVersion: "12.0.0",
34
+ version: "22.2.3",
35
+ ngImport: i0,
36
+ type: ScrollService,
37
+ providedIn: "root"
38
+ });
39
+ }
40
+ };
41
+ i0.ɵɵngDeclareClassMetadata({
42
+ minVersion: "12.0.0",
43
+ version: "22.2.3",
44
+ ngImport: i0,
45
+ type: ScrollService,
46
+ decorators: [{
47
+ type: Injectable,
48
+ args: [{ providedIn: "root" }]
49
+ }],
50
+ ctorParameters: () => []
51
+ });
52
+ var CmatAnimationOnScrollDirective = class CmatAnimationOnScrollDirective {
53
+ constructor() {
54
+ this.animationName = input(null, ...ngDevMode ? [{ debugName: "animationName" }] : /* istanbul ignore next */ []);
55
+ this.offset = input(80, ...ngDevMode ? [{ debugName: "offset" }] : /* istanbul ignore next */ []);
56
+ this.useScroll = input(...ngDevMode ? [void 0, { debugName: "useScroll" }] : /* istanbul ignore next */ []);
57
+ this.threshold = input(...ngDevMode ? [void 0, { debugName: "threshold" }] : /* istanbul ignore next */ []);
58
+ this._scrollSub = new Subscription();
59
+ this._resizeSub = new Subscription();
60
+ this._elementRef = inject(ElementRef);
61
+ this._renderer = inject(Renderer2);
62
+ this._scroll = inject(ScrollService);
63
+ }
64
+ get id() {
65
+ return this._elementRef.nativeElement.id;
66
+ }
67
+ ngOnInit() {
68
+ if (!this.animationName()) return;
69
+ this._isVisible = false;
70
+ const shouldUseScroll = this.useScroll() ?? (this.useScroll() === false ? false : true);
71
+ const thresholdValue = this.threshold() ?? .5;
72
+ if ("IntersectionObserver" in window && shouldUseScroll) {
73
+ new IntersectionObserver((entries) => {
74
+ entries.forEach((entry) => {
75
+ if (!entry.isIntersecting) return;
76
+ this.addAnimationClass();
77
+ });
78
+ }, {
79
+ root: null,
80
+ threshold: thresholdValue,
81
+ rootMargin: "0px"
82
+ }).observe(this._elementRef.nativeElement);
83
+ return;
84
+ }
85
+ this._scrollSub = this._scroll.scrollObs.subscribe(() => this.manageVisibility());
86
+ this._resizeSub = this._scroll.resizeObs.subscribe(() => this.manageVisibility());
87
+ }
88
+ ngAfterViewInit() {
89
+ setTimeout(() => this.manageVisibility(), 1);
90
+ }
91
+ ngOnDestroy() {
92
+ this._scrollSub.unsubscribe();
93
+ this._resizeSub.unsubscribe();
94
+ }
95
+ manageVisibility() {
96
+ if (this._isVisible) return;
97
+ this.getWinHeight();
98
+ this.getOffsetTop();
99
+ const scrollTrigger = this._offsetTop + this.offset() - this._winHeight;
100
+ if (this._scroll.pos >= scrollTrigger) this.addAnimationClass();
101
+ }
102
+ addAnimationClass() {
103
+ if (!this.animationName()) return;
104
+ this._isVisible = true;
105
+ this.setClass(this.animationName());
106
+ }
107
+ setClass(classes) {
108
+ for (const c of classes.split(" ")) this._renderer.addClass(this._elementRef.nativeElement, c);
109
+ }
110
+ getWinHeight() {
111
+ this._winHeight = typeof window !== "undefined" ? window.innerHeight : 0;
112
+ }
113
+ getOffsetTop() {
114
+ if (typeof this._elementRef.nativeElement.getBoundingClientRect === "function") {
115
+ const viewportTop = this._elementRef.nativeElement.getBoundingClientRect().top;
116
+ const clientTop = this._elementRef.nativeElement.clientTop;
117
+ this._offsetTop = viewportTop + this._scroll.pos - clientTop;
118
+ } else this._offsetTop = 0;
119
+ }
120
+ static {
121
+ this.ɵfac = i0.ɵɵngDeclareFactory({
122
+ minVersion: "12.0.0",
123
+ version: "22.2.3",
124
+ ngImport: i0,
125
+ type: CmatAnimationOnScrollDirective,
126
+ deps: [],
127
+ target: i0.ɵɵFactoryTarget.Directive
128
+ });
129
+ }
130
+ static {
131
+ this.ɵdir = i0.ɵɵngDeclareDirective({
132
+ minVersion: "17.1.0",
133
+ version: "22.2.3",
134
+ type: CmatAnimationOnScrollDirective,
135
+ isStandalone: true,
136
+ selector: "[cmatAnimateOnScroll]",
137
+ inputs: {
138
+ animationName: {
139
+ classPropertyName: "animationName",
140
+ publicName: "animationName",
141
+ isSignal: true,
142
+ isRequired: false,
143
+ transformFunction: null
144
+ },
145
+ offset: {
146
+ classPropertyName: "offset",
147
+ publicName: "offset",
148
+ isSignal: true,
149
+ isRequired: false,
150
+ transformFunction: null
151
+ },
152
+ useScroll: {
153
+ classPropertyName: "useScroll",
154
+ publicName: "useScroll",
155
+ isSignal: true,
156
+ isRequired: false,
157
+ transformFunction: null
158
+ },
159
+ threshold: {
160
+ classPropertyName: "threshold",
161
+ publicName: "threshold",
162
+ isSignal: true,
163
+ isRequired: false,
164
+ transformFunction: null
165
+ }
166
+ },
167
+ providers: [ScrollService],
168
+ ngImport: i0
169
+ });
170
+ }
171
+ };
172
+ i0.ɵɵngDeclareClassMetadata({
173
+ minVersion: "12.0.0",
174
+ version: "22.2.3",
175
+ ngImport: i0,
176
+ type: CmatAnimationOnScrollDirective,
177
+ decorators: [{
178
+ type: Directive,
179
+ args: [{
180
+ selector: "[cmatAnimateOnScroll]",
181
+ providers: [ScrollService]
182
+ }]
183
+ }],
184
+ propDecorators: {
185
+ animationName: [{
186
+ type: i0.Input,
187
+ args: [{
188
+ isSignal: true,
189
+ alias: "animationName",
190
+ required: false
191
+ }]
192
+ }],
193
+ offset: [{
194
+ type: i0.Input,
195
+ args: [{
196
+ isSignal: true,
197
+ alias: "offset",
198
+ required: false
199
+ }]
200
+ }],
201
+ useScroll: [{
202
+ type: i0.Input,
203
+ args: [{
204
+ isSignal: true,
205
+ alias: "useScroll",
206
+ required: false
207
+ }]
208
+ }],
209
+ threshold: [{
210
+ type: i0.Input,
211
+ args: [{
212
+ isSignal: true,
213
+ alias: "threshold",
214
+ required: false
215
+ }]
216
+ }]
217
+ }
218
+ });
138
219
  export { CmatAnimationOnScrollDirective };
139
- //# sourceMappingURL=cmat-directives-animate-on-scroll.mjs.map
220
+
221
+ //# sourceMappingURL=cmat-directives-animate-on-scroll.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cmat-directives-animate-on-scroll.mjs","sources":["../../../projects/cmat/directives/animate-on-scroll/scroll.service.ts","../../../projects/cmat/directives/animate-on-scroll/animate-on-scroll.directive.ts","../../../projects/cmat/directives/animate-on-scroll/cmat-directives-animate-on-scroll.ts"],"sourcesContent":["import { Injectable, OnDestroy } from '@angular/core';\r\nimport { Observable, Subscription, EMPTY, fromEvent } from 'rxjs';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class ScrollService implements OnDestroy {\r\n scrollObs: Observable<any>;\r\n resizeObs: Observable<any>;\r\n pos: number;\r\n private _scrollSub: Subscription = new Subscription();\r\n private _resizeSub: Subscription = new Subscription();\r\n\r\n constructor() {\r\n this.manageScrollPos();\r\n this.scrollObs =\r\n typeof window !== 'undefined' ? fromEvent(window, 'scroll') : EMPTY;\r\n this._scrollSub = this.scrollObs.subscribe(() => this.manageScrollPos());\r\n this.resizeObs =\r\n typeof window !== 'undefined' ? fromEvent(window, 'resize') : EMPTY;\r\n this._resizeSub = this.resizeObs.subscribe(() => this.manageScrollPos());\r\n }\r\n\r\n ngOnDestroy(): void {\r\n this._scrollSub.unsubscribe();\r\n this._resizeSub.unsubscribe();\r\n }\r\n\r\n private manageScrollPos(): void {\r\n this.pos = typeof window !== 'undefined' ? window.scrollY : 0;\r\n }\r\n}\r\n","import { AfterViewInit, Directive, ElementRef, OnDestroy, OnInit, Renderer2, inject, input } from '@angular/core';\r\nimport { Subscription } from 'rxjs';\r\nimport { ScrollService } from './scroll.service';\r\n\r\n@Directive({\r\n selector: '[cmatAnimateOnScroll]',\r\n providers:[ScrollService]\r\n})\r\nexport class CmatAnimationOnScrollDirective implements OnInit, OnDestroy, AfterViewInit {\r\n readonly animationName = input<string | null>(null); // use fadeIn as default if not specified, specify null for no animation\r\n readonly offset = input<number>(80); // for scroll Listener\r\n readonly useScroll = input<boolean>();\r\n readonly threshold = input<number>(); // for intersection observer only for the time being\r\n\r\n private _offsetTop: number;\r\n private _isVisible: boolean;\r\n private _winHeight: number;\r\n private _scrollSub: Subscription = new Subscription();\r\n private _resizeSub: Subscription = new Subscription();\r\n private _elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\r\n private _renderer = inject(Renderer2);\r\n private _scroll = inject(ScrollService);\r\n\r\n private get id(): string {\r\n return this._elementRef.nativeElement.id;\r\n }\r\n\r\n ngOnInit(): void {\r\n if (!this.animationName()) {\r\n return;\r\n }\r\n this._isVisible = false;\r\n const shouldUseScroll = this.useScroll() ?? (this.useScroll() === false ? false : true);\r\n const thresholdValue = this.threshold() ?? 0.5;\r\n \r\n if ('IntersectionObserver' in window && shouldUseScroll) {\r\n const options: IntersectionObserverInit = {\r\n root: null,\r\n threshold: thresholdValue,\r\n rootMargin: '0px',\r\n };\r\n const observer: IntersectionObserver = new IntersectionObserver(\r\n (entries) => {\r\n entries.forEach((entry) => {\r\n if (!entry.isIntersecting) {\r\n return;\r\n }\r\n this.addAnimationClass();\r\n });\r\n },\r\n options\r\n );\r\n observer.observe(this._elementRef.nativeElement);\r\n return;\r\n }\r\n this._scrollSub = this._scroll.scrollObs.subscribe(() =>\r\n this.manageVisibility()\r\n );\r\n this._resizeSub = this._scroll.resizeObs.subscribe(() =>\r\n this.manageVisibility()\r\n );\r\n }\r\n\r\n ngAfterViewInit(): void {\r\n setTimeout(() => this.manageVisibility(), 1);\r\n }\r\n\r\n ngOnDestroy(): void {\r\n this._scrollSub.unsubscribe();\r\n this._resizeSub.unsubscribe();\r\n }\r\n\r\n private manageVisibility(): void {\r\n if (this._isVisible) {\r\n return;\r\n }\r\n this.getWinHeight();\r\n this.getOffsetTop();\r\n const scrollTrigger = this._offsetTop + this.offset() - this._winHeight;\r\n if (this._scroll.pos >= scrollTrigger) {\r\n this.addAnimationClass();\r\n }\r\n }\r\n\r\n private addAnimationClass(): void {\r\n if (!this.animationName()) {\r\n return;\r\n }\r\n this._isVisible = true;\r\n this.setClass(this.animationName()!);\r\n }\r\n\r\n private setClass(classes: string): void {\r\n for (const c of classes.split(' ')) {\r\n this._renderer.addClass(this._elementRef.nativeElement, c);\r\n }\r\n }\r\n\r\n private getWinHeight(): void {\r\n this._winHeight = typeof window !== 'undefined' ? window.innerHeight : 0;\r\n }\r\n\r\n private getOffsetTop(): void {\r\n if (\r\n typeof this._elementRef.nativeElement.getBoundingClientRect === 'function'\r\n ) {\r\n const viewportTop =\r\n this._elementRef.nativeElement.getBoundingClientRect().top;\r\n const clientTop = this._elementRef.nativeElement.clientTop;\r\n this._offsetTop = viewportTop + this._scroll.pos - clientTop;\r\n } else {\r\n this._offsetTop = 0;\r\n }\r\n }\r\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MAMa,aAAa,CAAA;AAOtB,IAAA,WAAA,GAAA;AAHQ,QAAA,IAAA,CAAA,UAAU,GAAiB,IAAI,YAAY,EAAE;AAC7C,QAAA,IAAA,CAAA,UAAU,GAAiB,IAAI,YAAY,EAAE;QAGjD,IAAI,CAAC,eAAe,EAAE;AACtB,QAAA,IAAI,CAAC,SAAS;AACV,YAAA,OAAO,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,KAAK;AACvE,QAAA,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC;AACxE,QAAA,IAAI,CAAC,S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A,EAAA,SAAA,EAAA,EAAA,iBAAA,EAAA,WAAA,EAAA,UAAA,EAAA,WAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,SAAA,EAAA,EAAA,iBAAA,EAAA,WAAA,EAAA,UAAA,EAAA,WAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,SAAA,EAF7B,CAAC,aAAa,CAAC,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;2FAEhB,8BAA8B,EAAA,UAAA,EAAA,CAAA;kBAJ1C,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACP,oBAAA,QAAQ,EAAE,uBAAuB;oBACjC,SAAS,EAAC,CAAC,aAAa;AAC3B,iBAAA;;;ACPD;;AAEG;;"}
1
+ {"version":3,"file":"cmat-directives-animate-on-scroll.mjs","names":[],"sources":["../../../projects/cmat/directives/animate-on-scroll/scroll.service.ts","../../../projects/cmat/directives/animate-on-scroll/animate-on-scroll.directive.ts"],"sourcesContent":["import { Injectable, OnDestroy } from '@angular/core';\r\nimport { Observable, Subscription, EMPTY, fromEvent } from 'rxjs';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class ScrollService implements OnDestroy {\r\n scrollObs: Observable<any>;\r\n resizeObs: Observable<any>;\r\n pos: number;\r\n private _scrollSub: Subscription = new Subscription();\r\n private _resizeSub: Subscription = new Subscription();\r\n\r\n constructor() {\r\n this.manageScrollPos();\r\n this.scrollObs =\r\n typeof window !== 'undefined' ? fromEvent(window, 'scroll') : EMPTY;\r\n this._scrollSub = this.scrollObs.subscribe(() => this.manageScrollPos());\r\n this.resizeObs =\r\n typeof window !== 'undefined' ? fromEvent(window, 'resize') : EMPTY;\r\n this._resizeSub = this.resizeObs.subscribe(() => this.manageScrollPos());\r\n }\r\n\r\n ngOnDestroy(): void {\r\n this._scrollSub.unsubscribe();\r\n this._resizeSub.unsubscribe();\r\n }\r\n\r\n private manageScrollPos(): void {\r\n this.pos = typeof window !== 'undefined' ? window.scrollY : 0;\r\n }\r\n}\r\n","import { AfterViewInit, Directive, ElementRef, OnDestroy, OnInit, Renderer2, inject, input } from '@angular/core';\r\nimport { Subscription } from 'rxjs';\r\nimport { ScrollService } from './scroll.service';\r\n\r\n@Directive({\r\n selector: '[cmatAnimateOnScroll]',\r\n providers:[ScrollService]\r\n})\r\nexport class CmatAnimationOnScrollDirective implements OnInit, OnDestroy, AfterViewInit {\r\n readonly animationName = input<string | null>(null); // use fadeIn as default if not specified, specify null for no animation\r\n readonly offset = input<number>(80); // for scroll Listener\r\n readonly useScroll = input<boolean>();\r\n readonly threshold = input<number>(); // for intersection observer only for the time being\r\n\r\n private _offsetTop: number;\r\n private _isVisible: boolean;\r\n private _winHeight: number;\r\n private _scrollSub: Subscription = new Subscription();\r\n private _resizeSub: Subscription = new Subscription();\r\n private _elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\r\n private _renderer = inject(Renderer2);\r\n private _scroll = inject(ScrollService);\r\n\r\n private get id(): string {\r\n return this._elementRef.nativeElement.id;\r\n }\r\n\r\n ngOnInit(): void {\r\n if (!this.animationName()) {\r\n return;\r\n }\r\n this._isVisible = false;\r\n const shouldUseScroll = this.useScroll() ?? (this.useScroll() === false ? false : true);\r\n const thresholdValue = this.threshold() ?? 0.5;\r\n \r\n if ('IntersectionObserver' in window && shouldUseScroll) {\r\n const options: IntersectionObserverInit = {\r\n root: null,\r\n threshold: thresholdValue,\r\n rootMargin: '0px',\r\n };\r\n const observer: IntersectionObserver = new IntersectionObserver(\r\n (entries) => {\r\n entries.forEach((entry) => {\r\n if (!entry.isIntersecting) {\r\n return;\r\n }\r\n this.addAnimationClass();\r\n });\r\n },\r\n options\r\n );\r\n observer.observe(this._elementRef.nativeElement);\r\n return;\r\n }\r\n this._scrollSub = this._scroll.scrollObs.subscribe(() =>\r\n this.manageVisibility()\r\n );\r\n this._resizeSub = this._scroll.resizeObs.subscribe(() =>\r\n this.manageVisibility()\r\n );\r\n }\r\n\r\n ngAfterViewInit(): void {\r\n setTimeout(() => this.manageVisibility(), 1);\r\n }\r\n\r\n ngOnDestroy(): void {\r\n this._scrollSub.unsubscribe();\r\n this._resizeSub.unsubscribe();\r\n }\r\n\r\n private manageVisibility(): void {\r\n if (this._isVisible) {\r\n return;\r\n }\r\n this.getWinHeight();\r\n this.getOffsetTop();\r\n const scrollTrigger = this._offsetTop + this.offset() - this._winHeight;\r\n if (this._scroll.pos >= scrollTrigger) {\r\n this.addAnimationClass();\r\n }\r\n }\r\n\r\n private addAnimationClass(): void {\r\n if (!this.animationName()) {\r\n return;\r\n }\r\n this._isVisible = true;\r\n this.setClass(this.animationName()!);\r\n }\r\n\r\n private setClass(classes: string): void {\r\n for (const c of classes.split(' ')) {\r\n this._renderer.addClass(this._elementRef.nativeElement, c);\r\n }\r\n }\r\n\r\n private getWinHeight(): void {\r\n this._winHeight = typeof window !== 'undefined' ? window.innerHeight : 0;\r\n }\r\n\r\n private getOffsetTop(): void {\r\n if (\r\n typeof this._elementRef.nativeElement.getBoundingClientRect === 'function'\r\n ) {\r\n const viewportTop =\r\n this._elementRef.nativeElement.getBoundingClientRect().top;\r\n const clientTop = this._elementRef.nativeElement.clientTop;\r\n this._offsetTop = viewportTop + this._scroll.pos - clientTop;\r\n } else {\r\n this._offsetTop = 0;\r\n }\r\n }\r\n}"],"mappings":";;;AAMA,IAAa,gBAAb,MAAa,cAAa;CAOtB,cAAA;EAHQ,KAAA,aAA2B,IAAI,aAAY;EAC3C,KAAA,aAA2B,IAAI,aAAY;EAG/C,KAAK,gBAAe;EACpB,KAAK,YACD,OAAO,WAAW,cAAc,UAAU,QAAQ,QAAQ,IAAI;EAClE,KAAK,aAAa,KAAK,UAAU,gBAAgB,KAAK,gBAAe,CAAE;EACvE,KAAK,YACD,OAAO,WAAW,cAAc,UAAU,QAAQ,QAAQ,IAA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