coer-elements 1.0.18 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. package/README.md +63 -1
  2. package/components/index.d.ts +5 -0
  3. package/components/lib/coer-accordion/coer-accordion.component.d.ts +32 -0
  4. package/components/lib/coer-button/coer-button.component.d.ts +46 -0
  5. package/components/lib/coer-checkbox/coer-checkbox.component.d.ts +29 -0
  6. package/components/lib/coer-datebox/coer-datebox.component.d.ts +58 -0
  7. package/components/lib/coer-dropdown/coer-dropdown.component.d.ts +69 -0
  8. package/components/lib/coer-filebox/coer-filebox.component.d.ts +36 -0
  9. package/components/lib/coer-form/coer-form.component.d.ts +36 -0
  10. package/components/lib/coer-grid/coer-grid.component.d.ts +53 -0
  11. package/components/lib/coer-grid/coer-grid.extension.d.ts +111 -0
  12. package/components/lib/coer-list/coer-list.component.d.ts +57 -0
  13. package/components/lib/coer-modal/coer-modal.component.d.ts +38 -0
  14. package/components/lib/coer-numberbox/coer-numberbox.component.d.ts +56 -0
  15. package/components/lib/coer-page-title/coer-page-title.component.d.ts +14 -0
  16. package/components/lib/coer-selectbox/coer-selectbox.component.d.ts +79 -0
  17. package/components/lib/coer-sidenav/coer-menu-option/coer-menu-option.component.d.ts +22 -0
  18. package/components/lib/coer-sidenav/coer-sidenav.component.d.ts +49 -0
  19. package/components/lib/coer-sidenav/coer-toolbar/coer-toolbar.component.d.ts +32 -0
  20. package/components/lib/coer-sidenav/coer-tree-accordion/coer-tree-accordion.component.d.ts +43 -0
  21. package/components/lib/coer-switch/coer-switch.component.d.ts +32 -0
  22. package/components/lib/coer-tab/coer-tab.component.d.ts +36 -0
  23. package/components/lib/coer-textarea/coer-textarea.component.d.ts +52 -0
  24. package/components/lib/coer-textbox/coer-textbox.component.d.ts +66 -0
  25. package/components/lib/components.module.d.ts +46 -0
  26. package/components/public-api.d.ts +21 -0
  27. package/directives/index.d.ts +5 -0
  28. package/directives/lib/coer-ref.directive.d.ts +14 -0
  29. package/directives/lib/directives.module.d.ts +8 -0
  30. package/directives/lib/life-cycle.directive.d.ts +16 -0
  31. package/directives/public-api.d.ts +3 -0
  32. package/extensions/index.d.ts +5 -0
  33. package/extensions/lib/object.extension.d.ts +1 -0
  34. package/extensions/lib/string.extension.d.ts +19 -0
  35. package/extensions/public-api.d.ts +2 -0
  36. package/fesm2022/coer-elements-components.mjs +4040 -0
  37. package/fesm2022/coer-elements-components.mjs.map +1 -0
  38. package/fesm2022/coer-elements-directives.mjs +84 -0
  39. package/fesm2022/coer-elements-directives.mjs.map +1 -0
  40. package/fesm2022/coer-elements-extensions.mjs +68 -0
  41. package/fesm2022/coer-elements-extensions.mjs.map +1 -0
  42. package/fesm2022/coer-elements-guards.mjs +28 -0
  43. package/fesm2022/coer-elements-guards.mjs.map +1 -0
  44. package/fesm2022/coer-elements-interceptors.mjs +64 -0
  45. package/fesm2022/coer-elements-interceptors.mjs.map +1 -0
  46. package/fesm2022/coer-elements-interfaces.mjs +6 -0
  47. package/fesm2022/coer-elements-interfaces.mjs.map +1 -0
  48. package/fesm2022/coer-elements-pages.mjs +441 -0
  49. package/fesm2022/coer-elements-pages.mjs.map +1 -0
  50. package/fesm2022/coer-elements-pipes.mjs +87 -0
  51. package/fesm2022/coer-elements-pipes.mjs.map +1 -0
  52. package/fesm2022/coer-elements-signals.mjs +35 -0
  53. package/fesm2022/coer-elements-signals.mjs.map +1 -0
  54. package/fesm2022/coer-elements-tools.mjs +1960 -0
  55. package/fesm2022/coer-elements-tools.mjs.map +1 -0
  56. package/fesm2022/coer-elements.mjs +68 -0
  57. package/fesm2022/coer-elements.mjs.map +1 -0
  58. package/guards/index.d.ts +5 -0
  59. package/guards/lib/login.guard.d.ts +2 -0
  60. package/guards/lib/page.guard.d.ts +2 -0
  61. package/guards/public-api.d.ts +2 -0
  62. package/images/loading.gif +0 -0
  63. package/images/no-image.png +0 -0
  64. package/images/no-user.png +0 -0
  65. package/index.d.ts +12 -0
  66. package/interceptors/index.d.ts +5 -0
  67. package/interceptors/lib/user.interceptor.d.ts +8 -0
  68. package/interceptors/lib/utc-offset.interceptor.d.ts +8 -0
  69. package/interceptors/public-api.d.ts +1 -0
  70. package/interfaces/index.d.ts +5 -0
  71. package/interfaces/lib/app-source.interface.d.ts +4 -0
  72. package/interfaces/lib/box-button.interface.d.ts +6 -0
  73. package/interfaces/lib/bulk-load.interface.d.ts +5 -0
  74. package/interfaces/lib/coer-filebox/file-image.interface.d.ts +14 -0
  75. package/interfaces/lib/coer-filebox/file.interface.d.ts +5 -0
  76. package/interfaces/lib/coer-grid/grid-button-by-row.interface.d.ts +6 -0
  77. package/interfaces/lib/coer-grid/grid-checkbox.interface.d.ts +5 -0
  78. package/interfaces/lib/coer-grid/grid-coer-numberbox.interface.d.ts +12 -0
  79. package/interfaces/lib/coer-grid/grid-coer-selectbox.interface.d.ts +9 -0
  80. package/interfaces/lib/coer-grid/grid-coer-switch.interface.d.ts +6 -0
  81. package/interfaces/lib/coer-grid/grid-coer-textbox.interface.d.ts +11 -0
  82. package/interfaces/lib/coer-grid/grid-column.interface.d.ts +24 -0
  83. package/interfaces/lib/coer-grid/grid-data-source.interface.d.ts +6 -0
  84. package/interfaces/lib/coer-grid/grid-header-button.interface.d.ts +8 -0
  85. package/interfaces/lib/coer-grid/grid-header-export-button.interface.d.ts +10 -0
  86. package/interfaces/lib/coer-grid/grid-header.interface.d.ts +5 -0
  87. package/interfaces/lib/coer-grid/grid-import.interface.d.ts +4 -0
  88. package/interfaces/lib/coer-grid/grid-input-checkbox.interface.d.ts +5 -0
  89. package/interfaces/lib/coer-grid/grid-input-switch-change.interface.d.ts +5 -0
  90. package/interfaces/lib/coer-grid/grid-input-textbox.interface.d.ts +5 -0
  91. package/interfaces/lib/coer-grid/grid-item.interface.d.ts +5 -0
  92. package/interfaces/lib/coer-grid/grid-keyup-enter.interface.d.ts +6 -0
  93. package/interfaces/lib/coer-grid/grid-length.interface.d.ts +5 -0
  94. package/interfaces/lib/coer-grid/grid-search.interface.d.ts +5 -0
  95. package/interfaces/lib/coer-grid/grid-sort.interface.d.ts +5 -0
  96. package/interfaces/lib/coer-menu/menu-access.interface.d.ts +7 -0
  97. package/interfaces/lib/coer-menu/menu-option-selected.interface.d.ts +9 -0
  98. package/interfaces/lib/coer-menu/menu-selected.interface.d.ts +10 -0
  99. package/interfaces/lib/coer-menu/menu.interface.d.ts +10 -0
  100. package/interfaces/lib/coer-ref.interface.d.ts +10 -0
  101. package/interfaces/lib/image.interface.d.ts +11 -0
  102. package/interfaces/lib/login-response.interface.d.ts +10 -0
  103. package/interfaces/lib/login.interface.d.ts +4 -0
  104. package/interfaces/lib/page-title/breadcrumb.interface.d.ts +6 -0
  105. package/interfaces/lib/page-title/go-back.interface.d.ts +6 -0
  106. package/interfaces/lib/page-title/information.interface.d.ts +4 -0
  107. package/interfaces/lib/screen-size.interface.d.ts +5 -0
  108. package/interfaces/lib/service/http-request.interface.d.ts +12 -0
  109. package/interfaces/lib/service/http-response.interface.d.ts +6 -0
  110. package/interfaces/lib/service/patch.interface.d.ts +5 -0
  111. package/interfaces/lib/toolbar-menu.interface.d.ts +5 -0
  112. package/interfaces/public-api.d.ts +41 -0
  113. package/package.json +67 -38
  114. package/pages/index.d.ts +5 -0
  115. package/pages/lib/coer-loading/loading.component.d.ts +5 -0
  116. package/pages/lib/coer-menu/coer-menu.component.d.ts +12 -0
  117. package/pages/lib/coer-system/coer-system.component.d.ts +64 -0
  118. package/pages/lib/coer-system/login/login.component.d.ts +31 -0
  119. package/pages/lib/home/home.component.d.ts +7 -0
  120. package/pages/lib/pages.module.d.ts +18 -0
  121. package/pages/public-api.d.ts +5 -0
  122. package/pipes/index.d.ts +5 -0
  123. package/pipes/lib/html.pipe.d.ts +10 -0
  124. package/pipes/lib/no-image.pipe.d.ts +7 -0
  125. package/pipes/lib/numeric-format.pipe.d.ts +7 -0
  126. package/pipes/lib/pipes.module.d.ts +9 -0
  127. package/pipes/public-api.d.ts +4 -0
  128. package/signals/index.d.ts +5 -0
  129. package/signals/lib/breakpoint.signal.d.ts +1 -0
  130. package/signals/lib/is-loading.signal.d.ts +1 -0
  131. package/signals/lib/is-menu-open.signal.d.ts +1 -0
  132. package/signals/lib/is-modal-open.signal.d.ts +1 -0
  133. package/signals/lib/menu-selected.signal.d.ts +2 -0
  134. package/signals/lib/navigation.signal.d.ts +2 -0
  135. package/signals/public-api.d.ts +6 -0
  136. package/styles/angular-material.scss +20 -0
  137. package/styles/animations.scss +11 -0
  138. package/styles/bootstrap.scss +1 -14
  139. package/styles/coer-elements.css +2054 -0
  140. package/styles/colors.scss +90 -49
  141. package/styles/containers.scss +44 -0
  142. package/styles/cursores.scss +19 -0
  143. package/styles/index.scss +58 -0
  144. package/styles/layout.scss +49 -0
  145. package/styles/position.scss +7 -0
  146. package/styles/scroll-bar.scss +20 -0
  147. package/tools/index.d.ts +5 -0
  148. package/tools/lib/breadcrumbs.class.d.ts +18 -0
  149. package/tools/lib/coer-alert/coer-alert.component.d.ts +23 -0
  150. package/tools/lib/coer-grid.templates.d.ts +11 -0
  151. package/tools/lib/colors.class.d.ts +21 -0
  152. package/tools/lib/control-value.class.d.ts +25 -0
  153. package/tools/lib/date-time.class.d.ts +21 -0
  154. package/tools/lib/elements-html.class.d.ts +8 -0
  155. package/tools/lib/files.class.d.ts +16 -0
  156. package/tools/lib/filters.class.d.ts +11 -0
  157. package/tools/lib/menu.class.d.ts +9 -0
  158. package/tools/lib/page.class.d.ts +83 -0
  159. package/tools/lib/screen.class.d.ts +13 -0
  160. package/tools/lib/section.class.d.ts +33 -0
  161. package/tools/lib/service.class.d.ts +42 -0
  162. package/tools/lib/source.class.d.ts +20 -0
  163. package/tools/lib/tools.d.ts +42 -0
  164. package/tools/lib/user.class.d.ts +11 -0
  165. package/tools/public-api.d.ts +17 -0
  166. package/Signals/index.ts +0 -7
  167. package/Tools/Breadcrumbs.class.ts +0 -84
  168. package/Tools/ControlValue.ts +0 -63
  169. package/Tools/DateTime.class.ts +0 -27
  170. package/Tools/Files.class.ts +0 -119
  171. package/Tools/Page.class.ts +0 -197
  172. package/Tools/Screen.class.ts +0 -50
  173. package/Tools/Source.class.ts +0 -107
  174. package/Tools/Tools.ts +0 -212
  175. package/components/coer-alert/coer-alert.component.html +0 -56
  176. package/components/coer-alert/coer-alert.component.scss +0 -100
  177. package/components/coer-alert/coer-alert.component.ts +0 -249
  178. package/components/index.ts +0 -96
  179. package/dist_browser/Tools/Breadcrumbs.class.js +0 -66
  180. package/dist_browser/Tools/ControlValue.js +0 -49
  181. package/dist_browser/Tools/DateTime.class.js +0 -25
  182. package/dist_browser/Tools/Files.class.js +0 -99
  183. package/dist_browser/Tools/Page.class.js +0 -213
  184. package/dist_browser/Tools/Screen.class.js +0 -68
  185. package/dist_browser/Tools/Source.class.js +0 -83
  186. package/dist_browser/Tools/Tools.js +0 -227
  187. package/dist_browser/components/coer-alert/coer-alert.component.js +0 -314
  188. package/dist_browser/index.js +0 -8
  189. package/dist_node/Tools/Breadcrumbs.class.js +0 -69
  190. package/dist_node/Tools/ControlValue.js +0 -53
  191. package/dist_node/Tools/DateTime.class.js +0 -28
  192. package/dist_node/Tools/Files.class.js +0 -102
  193. package/dist_node/Tools/Page.class.js +0 -216
  194. package/dist_node/Tools/Screen.class.js +0 -71
  195. package/dist_node/Tools/Source.class.js +0 -86
  196. package/dist_node/Tools/Tools.js +0 -230
  197. package/dist_node/components/coer-alert/coer-alert.component.js +0 -317
  198. package/dist_node/index.js +0 -24
  199. package/dist_node/interfaces/index.js +0 -2
  200. package/index.ts +0 -8
  201. package/interfaces/index.ts +0 -47
  202. package/styles/coer.scss +0 -95
  203. package/tsconfig.json +0 -29
@@ -0,0 +1,1960 @@
1
+ import * as i0 from '@angular/core';
2
+ import { signal, Component, forwardRef, inject, Inject, input, output } from '@angular/core';
3
+ import * as bootstrap from 'bootstrap';
4
+ import Swal from 'sweetalert2';
5
+ import { NG_VALUE_ACCESSOR } from '@angular/forms';
6
+ import moment from 'moment';
7
+ import * as XLSX from 'xlsx';
8
+ import { navigationSIGNAL } from 'coer-elements/signals';
9
+ import { Router, ActivatedRoute } from '@angular/router';
10
+ import { Observable } from 'rxjs';
11
+ import { HttpClient, HttpRequest } from '@angular/common/http';
12
+ import { saveAs } from 'file-saver';
13
+
14
+ const reference_signal = signal({});
15
+ const Tools = {
16
+ /** Generate a Guid */
17
+ GetGuid: (seed = 'coer-system') => {
18
+ let time = new Date().getTime();
19
+ seed = seed.toString().trim();
20
+ return seed + `-xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g, (c) => {
21
+ const random = (time + Math.random() * 16) % 16 | 0;
22
+ time = Math.floor(time / 16);
23
+ return (c == 'x' ? random : (random & 0x3 | 0x8)).toString(16);
24
+ });
25
+ },
26
+ /** Returns true if the value is null or undefined, false otherwise */
27
+ IsNull: (value) => {
28
+ return (value === undefined || value === null);
29
+ },
30
+ /** Returns true if the value is not null or undefined, false otherwise */
31
+ IsNotNull: (value) => {
32
+ return !Tools.IsNull(value);
33
+ },
34
+ /** Returns true if the value is null or undefined or contains only whitespace, false otherwise */
35
+ IsOnlyWhiteSpace: (value) => {
36
+ return Tools.IsNull(value) || (typeof value === 'string' && value.trim() === '');
37
+ },
38
+ /** Returns true if has string value and is not only whitespace, false otherwise */
39
+ IsNotOnlyWhiteSpace: (value) => {
40
+ return Tools.IsNotNull(value) && !Tools.IsOnlyWhiteSpace(value);
41
+ },
42
+ /** Avoid Null value */
43
+ AvoidNull: (value, type = null) => {
44
+ if (typeof value === 'string') {
45
+ if (type === null || type === 'string') {
46
+ return (Tools.IsNotNull(value) ? value : '');
47
+ }
48
+ else if (type === 'number') {
49
+ return (Tools.IsNotNull(value) ? Number(value) : 0);
50
+ }
51
+ else if (type === 'boolean') {
52
+ return (Tools.IsNotNull(value) ? (value.toUpperCase().trim() === 'TRUE') : false);
53
+ }
54
+ }
55
+ if (typeof value === 'number') {
56
+ if (type === null || type === 'number') {
57
+ return (Tools.IsNotNull(value) ? value : 0);
58
+ }
59
+ else if (type === 'string') {
60
+ return (Tools.IsNotNull(value) ? String(value) : '0');
61
+ }
62
+ else if (type === 'boolean') {
63
+ return (Tools.IsNotNull(value) ? (value >= 1) : false);
64
+ }
65
+ }
66
+ if (typeof value === "boolean") {
67
+ if (type === null || type === 'boolean') {
68
+ return (Tools.IsNotNull(value) ? value : false);
69
+ }
70
+ else if (type === 'string') {
71
+ return (Tools.IsNotNull(value) ? (value ? 'true' : 'false') : 'false');
72
+ }
73
+ else if (type === 'number') {
74
+ return (Tools.IsNotNull(value) ? (value ? 1 : 0) : 0);
75
+ }
76
+ }
77
+ switch (type) {
78
+ case 'string': return '';
79
+ case 'number': return 0;
80
+ case 'boolean': return false;
81
+ default: return '';
82
+ }
83
+ },
84
+ /** */
85
+ RemoveAccents: (value) => {
86
+ if (Tools.IsOnlyWhiteSpace(value))
87
+ return '';
88
+ return value.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
89
+ },
90
+ /** Break reference of a object or array */
91
+ BreakReference: (object) => {
92
+ if (object === null)
93
+ return object;
94
+ if (typeof object === 'undefined')
95
+ return object;
96
+ if (typeof object === 'string')
97
+ return object;
98
+ if (typeof object === 'number')
99
+ return object;
100
+ if (typeof object === 'boolean')
101
+ return object;
102
+ const OBJECT = JSON.parse(JSON.stringify(object));
103
+ return (Array.isArray(OBJECT)) ? [...OBJECT] : { ...OBJECT };
104
+ },
105
+ /** Clean extra whitespaces */
106
+ CleanUpBlanks: (text) => {
107
+ if (Tools.IsOnlyWhiteSpace(text))
108
+ return '';
109
+ let words = String(text).split(' ');
110
+ words = words.filter(x => x.length > 0);
111
+ return words.join(' ');
112
+ },
113
+ /** Get properties of an object */
114
+ GetPropertyList: (object) => {
115
+ const properties = [];
116
+ if (object === null)
117
+ return properties;
118
+ if (typeof object === 'undefined')
119
+ return properties;
120
+ if (typeof object === 'string')
121
+ return properties;
122
+ if (typeof object === 'number')
123
+ return properties;
124
+ if (typeof object === 'boolean')
125
+ return properties;
126
+ for (const property in object)
127
+ properties.push(String(property));
128
+ return properties;
129
+ },
130
+ /**
131
+ * Set an index and merge more arrays of the same type
132
+ * */
133
+ SetIndex: (array, ...args) => {
134
+ let index = 0;
135
+ for (const arg of args) {
136
+ array = Tools.BreakReference(array).concat(Tools.BreakReference(arg));
137
+ }
138
+ return Tools.BreakReference(array).map(item => Object.assign({ index: index++ }, item));
139
+ },
140
+ /** Set First Char To Lower */
141
+ FirstCharToLower: (text) => {
142
+ if (Tools.IsOnlyWhiteSpace(text))
143
+ return '';
144
+ const textArray = [];
145
+ for (let i = 0; i < text.length; i++) {
146
+ if (i === 0)
147
+ textArray.push(text[i].toLowerCase());
148
+ else
149
+ textArray.push(text[i]);
150
+ }
151
+ return textArray.join('');
152
+ },
153
+ /** Set First Char To Upper */
154
+ FirstCharToUpper: (text) => {
155
+ if (Tools.IsOnlyWhiteSpace(text))
156
+ return '';
157
+ const textArray = [];
158
+ for (let i = 0; i < text.length; i++) {
159
+ if (i === 0)
160
+ textArray.push(text[i].toUpperCase());
161
+ else
162
+ textArray.push(text[i]);
163
+ }
164
+ return textArray.join('');
165
+ },
166
+ /** Sort an array in ascending order by property */
167
+ SortBy: (array, property, propertyType = 'string') => {
168
+ switch (propertyType) {
169
+ case 'string': {
170
+ return array.sort((x, y) => {
171
+ if (String(x[property]).toUpperCase().trim() < String(y[property]).toUpperCase().trim())
172
+ return -1;
173
+ else if (String(x[property]).toUpperCase().trim() > String(y[property]).toUpperCase().trim())
174
+ return 1;
175
+ else
176
+ return 0;
177
+ });
178
+ }
179
+ case 'number': {
180
+ return array.sort((x, y) => Number(x[property] - Number(y[property])));
181
+ }
182
+ }
183
+ },
184
+ /** Sort an array in descending order by property */
185
+ SortByDesc: (array, property, propertyType = 'string') => {
186
+ switch (propertyType) {
187
+ case 'string': {
188
+ return array.sort((x, y) => {
189
+ if (String(x[property]).toUpperCase().trim() < String(y[property]).toUpperCase().trim())
190
+ return 1;
191
+ else if (String(x[property]).toUpperCase().trim() > String(y[property]).toUpperCase().trim())
192
+ return -1;
193
+ else
194
+ return 0;
195
+ });
196
+ }
197
+ case 'number': {
198
+ return array.sort((x, y) => Number(Number(y[property])) - x[property]);
199
+ }
200
+ }
201
+ },
202
+ /** Return a string with forman numeric */
203
+ GetNumericFormat: (value, decimals = 0) => {
204
+ if (Tools.IsOnlyWhiteSpace(value) || isNaN(Number(value))) {
205
+ return '0';
206
+ }
207
+ let valueInteger = '';
208
+ let valueDecimal = '';
209
+ value = value.toString().replaceAll(' ', '');
210
+ if (value.includes('.') || (decimals > 0)) {
211
+ valueInteger = value.includes('.') ? value.split('.')[0] : value;
212
+ if (decimals > 0) {
213
+ const PADDING = decimals - valueDecimal.length;
214
+ valueDecimal = value.includes('.') ? value.split('.')[1] : '';
215
+ for (let i = 0; i < PADDING; i++)
216
+ valueDecimal += '0';
217
+ valueDecimal = valueDecimal.substring(0, decimals);
218
+ valueDecimal = `.${valueDecimal}`;
219
+ }
220
+ }
221
+ else {
222
+ valueInteger = value;
223
+ }
224
+ let counter = 0;
225
+ const VALUE_INTEGER_ARRAY = [];
226
+ for (const char of valueInteger.split('').reverse()) {
227
+ if (counter == 3) {
228
+ VALUE_INTEGER_ARRAY.push(',');
229
+ counter = 0;
230
+ }
231
+ VALUE_INTEGER_ARRAY.push(char);
232
+ ++counter;
233
+ }
234
+ valueInteger = VALUE_INTEGER_ARRAY.reverse().join('');
235
+ return `${valueInteger}${valueDecimal}`;
236
+ },
237
+ /** Wait the time indicated */
238
+ Sleep: (milliseconds = 0, reference = null) => {
239
+ if (Tools.IsNull(reference)) {
240
+ return new Promise(Resolve => setTimeout(Resolve, milliseconds));
241
+ }
242
+ else
243
+ return new Promise(Resolve => {
244
+ reference = reference.replaceAll(' ', '_').toLowerCase();
245
+ if (reference_signal().hasOwnProperty(reference)) {
246
+ clearInterval(reference_signal()[reference]);
247
+ }
248
+ reference_signal.set(Object.assign(reference_signal(), {
249
+ [reference]: setTimeout(() => {
250
+ Resolve();
251
+ clearInterval(reference_signal()[reference]);
252
+ const _reference = { ...reference_signal() };
253
+ delete _reference[reference];
254
+ reference_signal.set({ ..._reference });
255
+ }, milliseconds)
256
+ }));
257
+ });
258
+ },
259
+ /** */
260
+ Distinct: (array, ...args) => {
261
+ for (const arg of args) {
262
+ array = Tools.BreakReference(array).concat(Tools.BreakReference(arg));
263
+ }
264
+ return Array.from(new Set(array));
265
+ },
266
+ /** */
267
+ Except: (array, filter, ...properties) => {
268
+ const result = [];
269
+ for (const item of array) {
270
+ if (typeof item === 'object' && Tools.IsNotNull(properties) && properties.length > 0) {
271
+ if (!filter.some(x => x[properties[0]] === item[properties[0]])) {
272
+ result.push(item);
273
+ }
274
+ }
275
+ }
276
+ return [...result];
277
+ }
278
+ };
279
+
280
+ class Colors {
281
+ static { this.blue = '#0d6efd'; }
282
+ static { this.gray = '#6c757d'; }
283
+ static { this.green = '#198754'; }
284
+ static { this.yellow = '#ffc107'; }
285
+ static { this.red = '#dc3545'; }
286
+ static { this.white = '#f5f5f5'; }
287
+ static { this.black = '#252525'; }
288
+ static { this.orange = '#fd6031'; }
289
+ static { this.purple = '#a615bc'; }
290
+ /** Returns the color palette in hexadecimal */
291
+ static { this.colorsHex = new Map([
292
+ ['blue', '#0d6efd'],
293
+ ['gray', '#6c757d'],
294
+ ['green', '#198754'],
295
+ ['yellow', '#ffc107'],
296
+ ['red', '#dc3545'],
297
+ ['white', '#f5f5f5'],
298
+ ['black', '#252525'],
299
+ ['orange', '#fd6031'],
300
+ ['purple', '#a615bc'],
301
+ ]); }
302
+ /** Returns the color palette in RGB */
303
+ static { this.ColorsRGB = new Map([
304
+ ['blue', [13, 110, 253]],
305
+ ['gray', [108, 117, 125]],
306
+ ['green', [25, 135, 84]],
307
+ ['yellow', [225, 193, 7]],
308
+ ['red', [220, 53, 69]],
309
+ ['white', [245, 245, 245]],
310
+ ['black', [37, 37, 37]],
311
+ ['orange', [253, 96, 49]],
312
+ ['purple', [166, 21, 188]],
313
+ ]); }
314
+ /** Returns a random color in hexadecimal */
315
+ static { this.GetRandomColorHex = () => "#xxxxxx".replace(/x/g, () => (Math.random() * 16 | 0).toString(16)); }
316
+ /** Returns the number of colors requested */
317
+ static GetColorHexList(quantity) {
318
+ const colors = [];
319
+ let counter = 0;
320
+ while (counter < quantity) {
321
+ for (const color of this.colorsHex.values()) {
322
+ colors.push(color);
323
+ if (++counter === quantity)
324
+ break;
325
+ }
326
+ }
327
+ return colors;
328
+ }
329
+ /** Returns the number of colors requested with opacity */
330
+ static GetColorRGBList(quantity) {
331
+ const colors = [];
332
+ let alpha = 1.0;
333
+ let counter = 0;
334
+ let lastColor = [...Array.from(this.ColorsRGB.keys())].pop();
335
+ while (counter < quantity) {
336
+ for (const [color, value] of this.ColorsRGB.entries()) {
337
+ colors.push(`rgba(${value[0]}, ${value[1]}, ${value[2]}, ${alpha})`);
338
+ if (color === lastColor)
339
+ alpha -= 0.2;
340
+ if (++counter === quantity)
341
+ break;
342
+ }
343
+ }
344
+ return colors;
345
+ }
346
+ }
347
+
348
+ class CoerAlert {
349
+ /** */
350
+ Success(message = null, title = null, icon = null, autohide = 3000) {
351
+ //Title
352
+ if (Tools.IsOnlyWhiteSpace(title))
353
+ title = 'Success';
354
+ const alertSuccessTitle = document.getElementById('alert-success-title');
355
+ alertSuccessTitle.textContent = title;
356
+ //Icon
357
+ icon = this.GetIcon(title, icon, 'bi-check-circle fa-beat');
358
+ const alertSuccessIcon = document.getElementById('alert-success-icon');
359
+ this.SetIcon(alertSuccessIcon, icon);
360
+ //Message
361
+ if (Tools.IsNull(message))
362
+ message = '';
363
+ const alertSuccessMessage = document.getElementById('alert-success-message');
364
+ alertSuccessMessage.innerHTML = message;
365
+ //Toast
366
+ const alertSuccess = document.getElementById('alert-success');
367
+ this.SetAutoHide(alertSuccess, autohide);
368
+ const toast = bootstrap.Toast.getOrCreateInstance(alertSuccess);
369
+ toast.show();
370
+ }
371
+ /** */
372
+ Error(message = null, title = null, icon = null, autohide = 3000) {
373
+ //Title
374
+ if (Tools.IsOnlyWhiteSpace(title))
375
+ title = 'Error';
376
+ const alertErrorTitle = document.getElementById('alert-error-title');
377
+ alertErrorTitle.textContent = title;
378
+ //Icon
379
+ icon = this.GetIcon(title, icon, 'bi-exclamation-octagon fa-beat');
380
+ const alertErrorIcon = document.getElementById('alert-error-icon');
381
+ this.SetIcon(alertErrorIcon, icon);
382
+ //Message
383
+ if (Tools.IsNull(message))
384
+ message = '';
385
+ const alertErrorBody = document.getElementById('alert-error-message');
386
+ alertErrorBody.innerHTML = message;
387
+ //Toast
388
+ const alertError = document.getElementById('alert-error');
389
+ this.SetAutoHide(alertError, autohide);
390
+ const toast = bootstrap.Toast.getOrCreateInstance(alertError);
391
+ toast.show();
392
+ }
393
+ /** */
394
+ Info(message = null, title = null, icon = null, autohide = 3000) {
395
+ //Title
396
+ if (Tools.IsOnlyWhiteSpace(title))
397
+ title = 'Info';
398
+ const alertInfoTitle = document.getElementById('alert-info-title');
399
+ alertInfoTitle.textContent = title;
400
+ //Icon
401
+ icon = this.GetIcon(title, icon, 'bi-info-circle fa-beat');
402
+ const alertInfoIcon = document.getElementById('alert-info-icon');
403
+ this.SetIcon(alertInfoIcon, icon);
404
+ //Message
405
+ if (Tools.IsNull(message))
406
+ message = '';
407
+ const alertInfoBody = document.getElementById('alert-info-message');
408
+ alertInfoBody.innerHTML = message;
409
+ //Toast
410
+ const alertInfo = document.getElementById('alert-info');
411
+ this.SetAutoHide(alertInfo, autohide);
412
+ const toast = bootstrap.Toast.getOrCreateInstance(alertInfo);
413
+ toast.show();
414
+ }
415
+ /** */
416
+ Warning(message = null, title = null, icon = null, autohide = 3000) {
417
+ //Title
418
+ if (Tools.IsOnlyWhiteSpace(title))
419
+ title = 'Warning';
420
+ const alertWarningTitle = document.getElementById('alert-warning-title');
421
+ alertWarningTitle.textContent = title;
422
+ //Icon
423
+ icon = this.GetIcon(title, icon, 'bi-exclamation-triangle-fill fa-beat');
424
+ const alertWarningIcon = document.getElementById('alert-warning-icon');
425
+ this.SetIcon(alertWarningIcon, icon);
426
+ //Message
427
+ if (Tools.IsNull(message))
428
+ message = '';
429
+ const alertWarningBody = document.getElementById('alert-warning-message');
430
+ alertWarningBody.innerHTML = message;
431
+ //Toast
432
+ const alertWarning = document.getElementById('alert-warning');
433
+ this.SetAutoHide(alertWarning, autohide);
434
+ const toast = bootstrap.Toast.getOrCreateInstance(alertWarning);
435
+ toast.show();
436
+ }
437
+ /** */
438
+ Close(alert) {
439
+ return new Promise(Resolve => {
440
+ const element = document.getElementById(alert);
441
+ const toast = bootstrap.Toast.getOrCreateInstance(element);
442
+ toast.hide();
443
+ setTimeout(() => { Resolve(); }, 200);
444
+ });
445
+ }
446
+ /** */
447
+ Confirm(message = 'Proceed?', alertType = 'warning', icon = null) {
448
+ return new Promise(Resolve => {
449
+ let color;
450
+ let iconType;
451
+ switch (alertType) {
452
+ case 'danger':
453
+ {
454
+ if (Tools.IsNull(icon))
455
+ icon = 'bi-exclamation-octagon';
456
+ iconType = 'error';
457
+ color = Colors.red;
458
+ break;
459
+ }
460
+ ;
461
+ case 'success':
462
+ {
463
+ if (Tools.IsNull(icon))
464
+ icon = 'bi-check-circle';
465
+ iconType = 'info';
466
+ color = Colors.green;
467
+ break;
468
+ }
469
+ ;
470
+ case 'info':
471
+ {
472
+ if (Tools.IsNull(icon))
473
+ icon = 'bi-info-circle';
474
+ iconType = 'error';
475
+ color = Colors.black;
476
+ break;
477
+ }
478
+ ;
479
+ default: {
480
+ if (Tools.IsNull(icon))
481
+ icon = 'bi-exclamation-triangle-fill';
482
+ iconType = 'warning';
483
+ color = Colors.yellow;
484
+ break;
485
+ }
486
+ }
487
+ switch (icon) {
488
+ case 'delete':
489
+ icon = 'fa-regular fa-trash-can';
490
+ break;
491
+ }
492
+ Swal.fire({
493
+ icon: iconType,
494
+ iconColor: 'transparent',
495
+ iconHtml: `<i class="${icon}" style="color: ${color};"></i>`,
496
+ html: message,
497
+ showConfirmButton: true,
498
+ confirmButtonText: 'Yes',
499
+ confirmButtonColor: color,
500
+ focusConfirm: true,
501
+ showDenyButton: true,
502
+ denyButtonColor: color,
503
+ focusDeny: false,
504
+ reverseButtons: true,
505
+ allowOutsideClick: false,
506
+ allowEscapeKey: false,
507
+ allowEnterKey: true,
508
+ customClass: {
509
+ denyButton: 'sweet-alert-button',
510
+ confirmButton: 'sweet-alert-button'
511
+ }
512
+ }).then(({ value }) => setTimeout(() => Resolve(value)));
513
+ });
514
+ }
515
+ /** */
516
+ SetIcon(element, icon) {
517
+ if (icon.toUpperCase() != 'NONE') {
518
+ for (const item of [...element.classList.value.split(' ')]) {
519
+ if (item.length > 0) {
520
+ element.classList.remove(item);
521
+ element.classList.remove('q');
522
+ }
523
+ }
524
+ icon = icon.trim();
525
+ const hasWhiteSpaces = / /;
526
+ if (hasWhiteSpaces.test(icon)) {
527
+ const classes = icon.split(' ');
528
+ for (const icon of classes)
529
+ element.classList.add(icon);
530
+ }
531
+ else
532
+ element.classList.add(icon);
533
+ }
534
+ }
535
+ /** */
536
+ SetAutoHide(element, autohide) {
537
+ element.removeAttribute('data-bs-autohide');
538
+ element.removeAttribute('data-bs-delay');
539
+ if (autohide && autohide > 0) {
540
+ if (autohide < 1000)
541
+ autohide = 1000;
542
+ element.setAttribute('data-bs-autohide', 'true');
543
+ element.setAttribute('data-bs-delay', String(autohide));
544
+ }
545
+ else
546
+ element.setAttribute('data-bs-autohide', 'false');
547
+ }
548
+ /** */
549
+ GetIcon(title, icon, iconDefault) {
550
+ if (icon == null || icon == '') {
551
+ title = title.replaceAll(' ', '').toUpperCase();
552
+ switch (title) {
553
+ case 'ENABLED': return 'fa-solid fa-thumbs-up fa-flip-horizontal';
554
+ case 'ACTIVE': return 'fa-solid fa-thumbs-up fa-flip-horizontal';
555
+ case 'ACTIVED': return 'fa-solid fa-thumbs-up fa-flip-horizontal';
556
+ case 'DISABLE': return 'fa-solid fa-thumbs-down fa-flip-horizontal';
557
+ case 'DISABLED': return 'fa-solid fa-thumbs-down fa-flip-horizontal';
558
+ case 'DELETE': return 'fa-regular fa-trash-can';
559
+ case 'DELETED': return 'fa-regular fa-trash-can';
560
+ default: return iconDefault;
561
+ }
562
+ }
563
+ return icon;
564
+ }
565
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: CoerAlert, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
566
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: CoerAlert, isStandalone: true, selector: "coer-alert", ngImport: i0, template: "<aside class=\"toast-container coer-alert\">\r\n <!-- Success -->\r\n <div id=\"alert-success\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-success-icon\"></i>\r\n <strong id=\"alert-success-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-success')\" class=\"btn-close btn-close-white\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-success-message\"></pre>\r\n </div>\r\n </div>\r\n\r\n\r\n <!-- Error -->\r\n <div id=\"alert-error\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-error-icon\"></i>\r\n <strong id=\"alert-error-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-error')\" class=\"btn-close btn-close-white\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-error-message\"></pre>\r\n </div>\r\n </div>\r\n\r\n\r\n <!-- Info -->\r\n <div id=\"alert-info\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-info-icon\"></i>\r\n <strong id=\"alert-info-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-info')\" class=\"btn-close btn-close-white\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-info-message\"></pre>\r\n </div>\r\n </div>\r\n\r\n\r\n <!-- Warning -->\r\n <div id=\"alert-warning\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-warning-icon\"></i>\r\n <strong id=\"alert-warning-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-warning')\" class=\"btn-close\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-warning-message\"></pre>\r\n </div>\r\n </div>\r\n</aside>", styles: [":root{--blue: #0d6efd;--gray: #6c757d;--green: #198754;--yellow: #ffc107;--red: #dc3545;--white: #f5f5f5;--black: #252525;--orange: #fd6031;--purple: #a615bc}.text-blue{color:var(--blue)!important}.text-blue-bold{color:var(--blue)!important;font-weight:700!important}.background-blue{background-color:var(--blue)!important}.background-border-blue{background-color:var(--blue)!important;border-color:var(--blue)!important}.border-blue{border-color:var(--blue)!important}.text-gray{color:var(--gray)!important}.text-gray-bold{color:var(--gray)!important;font-weight:700!important}.background-gray{background-color:var(--gray)!important}.background-border-gray{background-color:var(--gray)!important;border-color:var(--gray)!important}.border-gray{border-color:var(--gray)!important}.text-green{color:var(--green)!important}.text-green-bold{color:var(--green)!important;font-weight:700!important}.background-green{background-color:var(--green)!important}.background-border-green{background-color:var(--green)!important;border-color:var(--green)!important}.border-green{border-color:var(--green)!important}.text-yellow{color:var(--yellow)!important}.text-yellow-bold{color:var(--yellow)!important;font-weight:700!important}.background-yellow{background-color:var(--yellow)!important}.background-border-yellow{background-color:var(--yellow)!important;border-color:var(--yellow)!important}.border-yellow{border-color:var(--yellow)!important}.text-red{color:var(--red)!important}.text-red-bold{color:var(--red)!important;font-weight:700!important}.background-red{background-color:var(--red)!important}.background-border-red{background-color:var(--red)!important;border-color:var(--red)!important}.border-red{border-color:var(--red)!important}.text-white{color:var(--white)!important}.text-white-bold{color:var(--white)!important;font-weight:700!important}.background-white{background-color:var(--white)!important}.background-border-white{background-color:var(--white)!important;border-color:var(--white)!important}.border-white{border-color:var(--white)!important}.text-black{color:var(--black)!important}.text-black-bold{color:var(--black)!important;font-weight:700!important}.background-black{background-color:var(--black)!important}.background-border-black{background-color:var(--black)!important;border-color:var(--black)!important}.border-black{border-color:var(--black)!important}.text-orange{color:var(--orange)!important}.text-orange-bold{color:var(--orange)!important;font-weight:700!important}.background-orange{background-color:var(--orange)!important}.background-border-orange{background-color:var(--orange)!important;border-color:var(--orange)!important}.border-orange{border-color:var(--orange)!important}.text-transparent{color:transparent!important}.background-transparent{background-color:transparent!important}.border-transparent{border-color:transparent!important}aside.toast-container{position:fixed;bottom:0;right:0;padding:15px!important;z-index:2000!important}aside.toast-container i,aside.toast-container svg{display:flex;align-items:center}aside.toast-container strong{margin:0 auto 0 5px}aside.toast-container div.toast,aside.toast-container div.toast-header{border-top-left-radius:10px;border-top-right-radius:10px;color:var(--white)}aside.toast-container div.toast,aside.toast-container div.toast-body{border-bottom-left-radius:10px;border-bottom-right-radius:10px;width:auto!important;min-width:350px!important;max-width:470px!important;color:var(--white)}aside.toast-container div.toast-body{min-height:36px}aside.toast-container pre{font-family:Roboto,RobotoFallback,Noto Kufi Arabic,Helvetica,Arial,sans-serif;white-space:pre-wrap;font-size:medium}aside.toast-container button{margin:0 2px!important;width:10px!important;height:10px!important;box-shadow:none!important;outline:none!important;border:none!important}aside.toast-container div#alert-success div.toast-header,aside.toast-container div#alert-success div.toast-body{background-color:var(--green)}aside.toast-container div#alert-info div.toast-header,aside.toast-container div#alert-info div.toast-body{background-color:var(--blue)}aside.toast-container div#alert-error div.toast-header,aside.toast-container div#alert-error div.toast-body{background-color:var(--red)}aside.toast-container div#alert-warning div.toast-header,aside.toast-container div#alert-warning div.toast-body{background-color:var(--yellow);border-color:var(--black);color:var(--black)}aside.toast-container div#alert-success:hover,aside.toast-container div#alert-info:hover,aside.toast-container div#alert-error:hover,aside.toast-container div#alert-warning:hover{transform:scale(1.01);box-shadow:2px 2px 10px #789;cursor:default}button.sweet-alert-button{width:100px!important;height:40px!important;display:flex!important;align-items:center!important;justify-content:center!important;margin:0 5px!important;outline:none!important;border:none!important;box-shadow:none!important}aside.toast-container>*{border:none!important;z-index:2000!important;margin:15px 0 0!important}\n"] }); }
567
+ }
568
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: CoerAlert, decorators: [{
569
+ type: Component,
570
+ args: [{ selector: 'coer-alert', standalone: true, template: "<aside class=\"toast-container coer-alert\">\r\n <!-- Success -->\r\n <div id=\"alert-success\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-success-icon\"></i>\r\n <strong id=\"alert-success-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-success')\" class=\"btn-close btn-close-white\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-success-message\"></pre>\r\n </div>\r\n </div>\r\n\r\n\r\n <!-- Error -->\r\n <div id=\"alert-error\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-error-icon\"></i>\r\n <strong id=\"alert-error-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-error')\" class=\"btn-close btn-close-white\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-error-message\"></pre>\r\n </div>\r\n </div>\r\n\r\n\r\n <!-- Info -->\r\n <div id=\"alert-info\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-info-icon\"></i>\r\n <strong id=\"alert-info-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-info')\" class=\"btn-close btn-close-white\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-info-message\"></pre>\r\n </div>\r\n </div>\r\n\r\n\r\n <!-- Warning -->\r\n <div id=\"alert-warning\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-warning-icon\"></i>\r\n <strong id=\"alert-warning-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-warning')\" class=\"btn-close\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-warning-message\"></pre>\r\n </div>\r\n </div>\r\n</aside>", styles: [":root{--blue: #0d6efd;--gray: #6c757d;--green: #198754;--yellow: #ffc107;--red: #dc3545;--white: #f5f5f5;--black: #252525;--orange: #fd6031;--purple: #a615bc}.text-blue{color:var(--blue)!important}.text-blue-bold{color:var(--blue)!important;font-weight:700!important}.background-blue{background-color:var(--blue)!important}.background-border-blue{background-color:var(--blue)!important;border-color:var(--blue)!important}.border-blue{border-color:var(--blue)!important}.text-gray{color:var(--gray)!important}.text-gray-bold{color:var(--gray)!important;font-weight:700!important}.background-gray{background-color:var(--gray)!important}.background-border-gray{background-color:var(--gray)!important;border-color:var(--gray)!important}.border-gray{border-color:var(--gray)!important}.text-green{color:var(--green)!important}.text-green-bold{color:var(--green)!important;font-weight:700!important}.background-green{background-color:var(--green)!important}.background-border-green{background-color:var(--green)!important;border-color:var(--green)!important}.border-green{border-color:var(--green)!important}.text-yellow{color:var(--yellow)!important}.text-yellow-bold{color:var(--yellow)!important;font-weight:700!important}.background-yellow{background-color:var(--yellow)!important}.background-border-yellow{background-color:var(--yellow)!important;border-color:var(--yellow)!important}.border-yellow{border-color:var(--yellow)!important}.text-red{color:var(--red)!important}.text-red-bold{color:var(--red)!important;font-weight:700!important}.background-red{background-color:var(--red)!important}.background-border-red{background-color:var(--red)!important;border-color:var(--red)!important}.border-red{border-color:var(--red)!important}.text-white{color:var(--white)!important}.text-white-bold{color:var(--white)!important;font-weight:700!important}.background-white{background-color:var(--white)!important}.background-border-white{background-color:var(--white)!important;border-color:var(--white)!important}.border-white{border-color:var(--white)!important}.text-black{color:var(--black)!important}.text-black-bold{color:var(--black)!important;font-weight:700!important}.background-black{background-color:var(--black)!important}.background-border-black{background-color:var(--black)!important;border-color:var(--black)!important}.border-black{border-color:var(--black)!important}.text-orange{color:var(--orange)!important}.text-orange-bold{color:var(--orange)!important;font-weight:700!important}.background-orange{background-color:var(--orange)!important}.background-border-orange{background-color:var(--orange)!important;border-color:var(--orange)!important}.border-orange{border-color:var(--orange)!important}.text-transparent{color:transparent!important}.background-transparent{background-color:transparent!important}.border-transparent{border-color:transparent!important}aside.toast-container{position:fixed;bottom:0;right:0;padding:15px!important;z-index:2000!important}aside.toast-container i,aside.toast-container svg{display:flex;align-items:center}aside.toast-container strong{margin:0 auto 0 5px}aside.toast-container div.toast,aside.toast-container div.toast-header{border-top-left-radius:10px;border-top-right-radius:10px;color:var(--white)}aside.toast-container div.toast,aside.toast-container div.toast-body{border-bottom-left-radius:10px;border-bottom-right-radius:10px;width:auto!important;min-width:350px!important;max-width:470px!important;color:var(--white)}aside.toast-container div.toast-body{min-height:36px}aside.toast-container pre{font-family:Roboto,RobotoFallback,Noto Kufi Arabic,Helvetica,Arial,sans-serif;white-space:pre-wrap;font-size:medium}aside.toast-container button{margin:0 2px!important;width:10px!important;height:10px!important;box-shadow:none!important;outline:none!important;border:none!important}aside.toast-container div#alert-success div.toast-header,aside.toast-container div#alert-success div.toast-body{background-color:var(--green)}aside.toast-container div#alert-info div.toast-header,aside.toast-container div#alert-info div.toast-body{background-color:var(--blue)}aside.toast-container div#alert-error div.toast-header,aside.toast-container div#alert-error div.toast-body{background-color:var(--red)}aside.toast-container div#alert-warning div.toast-header,aside.toast-container div#alert-warning div.toast-body{background-color:var(--yellow);border-color:var(--black);color:var(--black)}aside.toast-container div#alert-success:hover,aside.toast-container div#alert-info:hover,aside.toast-container div#alert-error:hover,aside.toast-container div#alert-warning:hover{transform:scale(1.01);box-shadow:2px 2px 10px #789;cursor:default}button.sweet-alert-button{width:100px!important;height:40px!important;display:flex!important;align-items:center!important;justify-content:center!important;margin:0 5px!important;outline:none!important;border:none!important;box-shadow:none!important}aside.toast-container>*{border:none!important;z-index:2000!important;margin:15px 0 0!important}\n"] }]
571
+ }] });
572
+
573
+ class Breadcrumbs {
574
+ static { this.storage = 'COER-System'; }
575
+ /** */
576
+ static Add(page, path) {
577
+ const breadcrumbs = this.Get();
578
+ const paths = breadcrumbs.map(item => item.path);
579
+ if (!paths.includes(path)) {
580
+ breadcrumbs.push({ page, path });
581
+ this.Save(breadcrumbs);
582
+ }
583
+ }
584
+ /** */
585
+ static Get() {
586
+ let storage = sessionStorage.getItem(this.storage);
587
+ if (storage) {
588
+ storage = JSON.parse(storage);
589
+ if (storage.hasOwnProperty('breadcrumbs')) {
590
+ return Tools.BreakReference(storage.breadcrumbs);
591
+ }
592
+ }
593
+ return [];
594
+ }
595
+ /** */
596
+ static GetFirst() {
597
+ const breadcrumbs = this.Get();
598
+ return (breadcrumbs.length > 0) ? breadcrumbs.shift() : null;
599
+ }
600
+ /** */
601
+ static Save(breadcrumbs) {
602
+ let storage = sessionStorage.getItem(this.storage);
603
+ if (storage)
604
+ storage = JSON.parse(storage);
605
+ storage = Object.assign({}, storage, { breadcrumbs });
606
+ sessionStorage.setItem(this.storage, JSON.stringify(storage));
607
+ }
608
+ /** */
609
+ static Remove(path) {
610
+ let breadcrumbs = this.Get();
611
+ const index = breadcrumbs.findIndex(x => x.path.toLowerCase().trim() === path.toLowerCase().trim());
612
+ if (index >= 0) {
613
+ breadcrumbs = Tools.BreakReference(breadcrumbs).splice(0, index + 1);
614
+ this.Save(breadcrumbs);
615
+ }
616
+ }
617
+ /** */
618
+ static SetLast(page, path) {
619
+ const breadcrumbs = this.Get();
620
+ if (breadcrumbs.length > 0) {
621
+ breadcrumbs[breadcrumbs.length - 1] = { page, path };
622
+ this.Save(breadcrumbs);
623
+ }
624
+ }
625
+ /** */
626
+ static RemoveLast() {
627
+ const breadcrumbs = this.Get();
628
+ if (breadcrumbs.length > 0) {
629
+ breadcrumbs.pop();
630
+ this.Save(breadcrumbs);
631
+ }
632
+ }
633
+ }
634
+
635
+ const GridTemplates = {
636
+ /** Template for boolean property */
637
+ isActiveTemplate: (item) => {
638
+ if (item.value) {
639
+ return `
640
+ <span class='text-green-bold'>
641
+ <i class="fa-solid fa-circle-check"></i> Active
642
+ </span>
643
+ `;
644
+ }
645
+ else {
646
+ return `
647
+ <span class='text-gray-bold'>
648
+ <i class="fa-solid fa-circle-minus"></i> Disabled
649
+ </span>
650
+ `;
651
+ }
652
+ },
653
+ /** Template for boolean property */
654
+ coerSwitchTemplate: (item) => ({
655
+ isInput: true,
656
+ tooltip: `${item.value ? 'Active' : 'Disabled'}`
657
+ }),
658
+ /** Template for text property */
659
+ coerTextboxTemplate: (item) => ({
660
+ isInput: true,
661
+ isInvalid: item.value.length <= 0
662
+ }),
663
+ /** Template for text property */
664
+ coerIconTemplate: (icon, color = 'black') => {
665
+ return `<i class='${icon} d-block w-100 text-center' style='color: ${color};'></i>`;
666
+ }
667
+ };
668
+
669
+ const CONTROL_VALUE = (component) => {
670
+ return {
671
+ provide: NG_VALUE_ACCESSOR,
672
+ useExisting: forwardRef(() => component),
673
+ multi: true
674
+ };
675
+ };
676
+ class ControlValue {
677
+ constructor() {
678
+ this._isTouched = false;
679
+ }
680
+ get isTouched() {
681
+ return this._isTouched;
682
+ }
683
+ /** */
684
+ SetValue(value) {
685
+ if (typeof this._UpdateValue === 'function') {
686
+ this._UpdateValue(value);
687
+ }
688
+ this._value = value;
689
+ }
690
+ /** */
691
+ SetTouched(isTouched) {
692
+ if (typeof this._IsTouched === 'function') {
693
+ this._IsTouched(isTouched);
694
+ }
695
+ this._isTouched = isTouched;
696
+ }
697
+ /** */
698
+ writeValue(value) {
699
+ this._value = value;
700
+ }
701
+ /** */
702
+ registerOnChange(callback) {
703
+ this._UpdateValue = callback;
704
+ }
705
+ /** */
706
+ registerOnTouched(callback) {
707
+ this._IsTouched = callback;
708
+ }
709
+ /** */
710
+ setDisabledState(isDisabled) { }
711
+ }
712
+
713
+ class DateTime {
714
+ /** Get UTC Offset */
715
+ static GetOffset() {
716
+ return moment().utcOffset();
717
+ }
718
+ /** YYYY-MM-DD HH:mm:ss */
719
+ static GetFormatDB(date) {
720
+ date = new Date(date.toString());
721
+ return moment(date).format('YYYY-MM-DD HH:mm:ss');
722
+ }
723
+ /** Convert UTC Date to Local Zone */
724
+ static ToLocalZone(date) {
725
+ date = DateTime.GetFormatDB(date);
726
+ return moment(date).add(DateTime.GetOffset(), 'minutes').format('YYYY-MM-DD HH:mm:ss');
727
+ }
728
+ /** Convert Local Zone Date to UTC */
729
+ static ToUTC(date) {
730
+ date = DateTime.GetFormatDB(date);
731
+ return moment(date).subtract(DateTime.GetOffset(), 'minutes').format('YYYY-MM-DD HH:mm:ss');
732
+ }
733
+ /** MMM, DD YYYY */
734
+ static GetDateFormat(date) {
735
+ date = DateTime.GetFormatDB(date);
736
+ return moment(date).parseZone().local(true).format('MMM, DD YYYY');
737
+ }
738
+ /** MMM, DD YYYY at hh:mm a */
739
+ static GetDateTimeFormat(date) {
740
+ date = DateTime.GetFormatDB(date);
741
+ return moment(date).parseZone().local(true).format('MMM, DD YYYY - hh:mm a').replace('-', 'at');
742
+ }
743
+ /** */
744
+ static IsValidDate(date) {
745
+ if (Tools.IsOnlyWhiteSpace(date))
746
+ return false;
747
+ date = DateTime.GetFormatDB(date);
748
+ return moment(date).isValid();
749
+ }
750
+ /** */
751
+ static SetFirstHour(date = '', format = 'database') {
752
+ if (Tools.IsOnlyWhiteSpace(date))
753
+ date = moment();
754
+ else {
755
+ date = DateTime.GetFormatDB(date);
756
+ date = moment(date);
757
+ }
758
+ date = date.set('hour', 0).set('minute', 0).set('second', 0).set('millisecond', 0);
759
+ return (format === 'database')
760
+ ? DateTime.GetFormatDB(date)
761
+ : DateTime.GetDateFormat(date);
762
+ }
763
+ /** */
764
+ static SetLastHour(date = '', format = 'database') {
765
+ if (Tools.IsOnlyWhiteSpace(date))
766
+ date = moment();
767
+ else {
768
+ date = DateTime.GetFormatDB(date);
769
+ date = moment(date);
770
+ }
771
+ date = date.set('hour', 23).set('minute', 59).set('second', 59).set('millisecond', 59);
772
+ return (format === 'database')
773
+ ? DateTime.GetFormatDB(date)
774
+ : DateTime.GetDateFormat(date);
775
+ }
776
+ }
777
+
778
+ const ElementsHTML = {
779
+ /** Get width in px */
780
+ GetElementWidth: (element, ...args) => {
781
+ let width = 0;
782
+ if (Tools.IsNotNull(element) && Tools.IsNotOnlyWhiteSpace(element?.offsetWidth)) {
783
+ width += element.offsetWidth;
784
+ for (const arg of args) {
785
+ if (typeof arg == 'number')
786
+ width += arg;
787
+ else if (Tools.IsNotNull(arg) && Tools.IsNotOnlyWhiteSpace(arg?.offsetWidth)) {
788
+ width += arg.offsetWidth;
789
+ }
790
+ }
791
+ }
792
+ return `${width}px`;
793
+ },
794
+ /** Get height in px */
795
+ GetElementHeight: (element, ...args) => {
796
+ let height = 0;
797
+ if (Tools.IsNotNull(element) && Tools.IsNotOnlyWhiteSpace(element?.offsetHeight)) {
798
+ height += element.offsetHeight;
799
+ for (const arg of args) {
800
+ if (typeof arg == 'number')
801
+ height += arg;
802
+ else if (Tools.IsNotNull(arg) && Tools.IsNotOnlyWhiteSpace(arg?.offsetHeight)) {
803
+ height += arg.offsetHeight;
804
+ }
805
+ }
806
+ }
807
+ return `${height}px`;
808
+ },
809
+ /** */
810
+ IsInvalidElement: (element) => {
811
+ let isInvalid = true;
812
+ if (Tools.IsNotNull(element)) {
813
+ if (typeof element == 'object') {
814
+ const properties = Tools.GetPropertyList(element);
815
+ if (properties.includes('_isTouched') && properties.includes('_value')) {
816
+ isInvalid = element.isTouched && Tools.IsOnlyWhiteSpace(element.value);
817
+ }
818
+ }
819
+ }
820
+ return isInvalid;
821
+ },
822
+ };
823
+
824
+ class Files {
825
+ static { this.EXCEL_EXTENSIONS = ['xls', 'xlsx', 'csv']; }
826
+ /** Get Extension File */
827
+ static GetExtension(file) {
828
+ const fileName = file.name;
829
+ if (fileName.includes('.')) {
830
+ let worlds = fileName.split('.');
831
+ if (worlds.length > 0) {
832
+ let extension = worlds.pop();
833
+ extension = extension.trim().toLowerCase();
834
+ if (extension.length > 0)
835
+ return extension;
836
+ }
837
+ }
838
+ return null;
839
+ }
840
+ /** Is Excel File */
841
+ static IsExcel(file) {
842
+ const EXTENSION = Files.GetExtension(file);
843
+ return Tools.IsNotNull(EXTENSION)
844
+ ? this.EXCEL_EXTENSIONS.includes(EXTENSION)
845
+ : false;
846
+ }
847
+ /** Read excel file */
848
+ static ReadExcel(file) {
849
+ return new Promise(Resolve => {
850
+ let columns = [];
851
+ let rows = [];
852
+ const reader = new FileReader();
853
+ reader.readAsArrayBuffer(file);
854
+ reader.onload = () => {
855
+ const dataBytes = new Uint8Array(reader.result);
856
+ if (dataBytes) {
857
+ const workbook = XLSX.read(dataBytes, {});
858
+ const sheet = workbook.Sheets[workbook.SheetNames[0]];
859
+ let dataSheet = XLSX.utils.sheet_to_json(sheet, {
860
+ header: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
861
+ });
862
+ //Get Headers
863
+ for (const column in dataSheet[0]) {
864
+ columns.push(Tools.FirstCharToLower(String(dataSheet[0][column]).replaceAll(' ', '')));
865
+ }
866
+ //Get Rows
867
+ rows = XLSX.utils.sheet_to_json(sheet, { header: columns });
868
+ rows.shift();
869
+ rows = rows.map(row => {
870
+ const item = Tools.BreakReference(row);
871
+ delete item['__rowNum__'];
872
+ return item;
873
+ });
874
+ }
875
+ Resolve({ columns, rows });
876
+ };
877
+ reader.onerror = () => { Resolve({ columns, rows }); };
878
+ });
879
+ }
880
+ /** Export to excel file */
881
+ static ExportExcel(data, fileName = 'coer_report', sheetName = 'Sheet1') {
882
+ sheetName = Tools.CleanUpBlanks(sheetName);
883
+ fileName = Tools.CleanUpBlanks(fileName);
884
+ if (fileName.endsWith('.xls') || fileName.endsWith('.xlsx') || fileName.endsWith('.csv')) {
885
+ if (fileName.endsWith('.xls')) {
886
+ fileName = fileName.replaceAll('.xls', '.xlsx');
887
+ }
888
+ if (fileName.endsWith('.csv')) {
889
+ fileName = fileName.replaceAll('.csv', '.xlsx');
890
+ }
891
+ }
892
+ else {
893
+ fileName += '.xlsx';
894
+ }
895
+ const WORK_SHEET = XLSX.utils.json_to_sheet(data);
896
+ const WORK_BOOK = XLSX.utils.book_new();
897
+ XLSX.utils.book_append_sheet(WORK_BOOK, WORK_SHEET, sheetName);
898
+ XLSX.writeFile(WORK_BOOK, fileName);
899
+ }
900
+ /** Convert file to string base64 */
901
+ static ConvertToBase64(file) {
902
+ return new Promise(Resolve => {
903
+ const reader = new FileReader();
904
+ reader.readAsDataURL(file);
905
+ reader.onload = () => {
906
+ Resolve(reader.result?.toString() || '');
907
+ };
908
+ reader.onerror = () => Resolve('');
909
+ });
910
+ }
911
+ }
912
+
913
+ class User {
914
+ static { this.storage = 'COER-System'; }
915
+ /** */
916
+ static Set(user) {
917
+ let storage = localStorage.getItem(this.storage);
918
+ if (storage) {
919
+ storage = JSON.parse(storage);
920
+ storage = Object.assign({}, storage, { user });
921
+ }
922
+ else {
923
+ storage = Object.assign({}, storage, { user });
924
+ }
925
+ localStorage.setItem(this.storage, JSON.stringify(storage));
926
+ }
927
+ /** */
928
+ static Get() {
929
+ let storage = localStorage.getItem(this.storage);
930
+ if (storage) {
931
+ storage = JSON.parse(storage);
932
+ if (storage.hasOwnProperty('user')) {
933
+ return storage.user;
934
+ }
935
+ }
936
+ return null;
937
+ }
938
+ /** */
939
+ static LogIn() {
940
+ let storage = localStorage.getItem(this.storage);
941
+ storage = JSON.parse(storage);
942
+ return Tools.IsNotOnlyWhiteSpace(storage)
943
+ && Tools.IsNotNull(storage?.user)
944
+ && Tools.IsNotOnlyWhiteSpace(storage?.user?.jwt);
945
+ }
946
+ /** */
947
+ static LogOut() {
948
+ sessionStorage.removeItem(this.storage);
949
+ localStorage.removeItem(this.storage);
950
+ document.location.href = '/';
951
+ }
952
+ }
953
+
954
+ class Filters {
955
+ static { this.storage = 'COER-System'; }
956
+ /** */
957
+ static Add(filters, path) {
958
+ let storage = sessionStorage.getItem(this.storage);
959
+ storage = JSON.parse(storage);
960
+ let dictionary = [[path, filters]];
961
+ if (Tools.IsNotNull(storage?.filters)) {
962
+ const index = storage.filters.findIndex((x) => x.some(y => y === path));
963
+ if (index > -1) {
964
+ storage.filters[index][1] = filters;
965
+ dictionary = storage.filters;
966
+ }
967
+ else {
968
+ dictionary = storage.filters.concat(dictionary);
969
+ }
970
+ }
971
+ storage = Object.assign({}, storage, {
972
+ filters: dictionary
973
+ });
974
+ sessionStorage.setItem(this.storage, JSON.stringify(storage));
975
+ }
976
+ /** */
977
+ static Get(path) {
978
+ let storage = sessionStorage.getItem(this.storage);
979
+ storage = JSON.parse(storage);
980
+ if (Tools.IsNotNull(storage?.filters)) {
981
+ for (const filterList of storage.filters) {
982
+ if (filterList.some((x) => x === path)) {
983
+ return filterList[1];
984
+ }
985
+ }
986
+ }
987
+ return null;
988
+ }
989
+ /** */
990
+ static Remove(path) {
991
+ let storage = sessionStorage.getItem(this.storage);
992
+ storage = JSON.parse(storage);
993
+ if (Tools.IsNotNull(storage?.filters)) {
994
+ let index = 0;
995
+ for (index; index < storage.filters.length; index++) {
996
+ if (storage.filters[index].some((x) => x === path)) {
997
+ break;
998
+ }
999
+ }
1000
+ storage.filters.splice(index, 1);
1001
+ }
1002
+ sessionStorage.setItem(this.storage, JSON.stringify(storage));
1003
+ }
1004
+ /** */
1005
+ static RemoveAll() {
1006
+ let storage = sessionStorage.getItem(this.storage);
1007
+ storage = JSON.parse(storage);
1008
+ if (Tools.IsNotNull(storage?.filters)) {
1009
+ delete storage.filters;
1010
+ }
1011
+ sessionStorage.setItem(this.storage, JSON.stringify(storage));
1012
+ }
1013
+ }
1014
+
1015
+ class Menu {
1016
+ static { this.storage = 'COER-System'; }
1017
+ /** */
1018
+ static SetSelectedOption(menu) {
1019
+ let storage = sessionStorage.getItem(this.storage);
1020
+ if (storage)
1021
+ storage = JSON.parse(storage);
1022
+ storage = Object.assign({}, storage, { menu });
1023
+ sessionStorage.setItem(this.storage, JSON.stringify(storage));
1024
+ }
1025
+ /** */
1026
+ static GetSelectedOption() {
1027
+ let storage = sessionStorage.getItem(this.storage);
1028
+ if (storage) {
1029
+ storage = JSON.parse(storage);
1030
+ if (storage.hasOwnProperty('menu')) {
1031
+ return storage.menu;
1032
+ }
1033
+ }
1034
+ return null;
1035
+ }
1036
+ static { this.GetMenuAccess = () => {
1037
+ const menuAccess = [];
1038
+ //LV1
1039
+ for (const lv1 of navigationSIGNAL()) {
1040
+ //LV1 - Page
1041
+ if (Tools.IsNotOnlyWhiteSpace(lv1.path) && Tools.IsNull(lv1.items)) {
1042
+ menuAccess.push({
1043
+ module: null,
1044
+ submodule: null,
1045
+ page: lv1.label,
1046
+ path: lv1.path,
1047
+ readonly: Tools.IsNotNull(lv1?.readonly) ? lv1.readonly : true
1048
+ });
1049
+ }
1050
+ //LV1 - Module
1051
+ else if (Tools.IsOnlyWhiteSpace(lv1.path) && Tools.IsNotNull(lv1.items)) {
1052
+ //LV2
1053
+ for (const lv2 of lv1.items) {
1054
+ //LV2 - Page
1055
+ if (Tools.IsNotOnlyWhiteSpace(lv2.path) && Tools.IsNull(lv2.items)) {
1056
+ menuAccess.push({
1057
+ module: lv1.label,
1058
+ submodule: null,
1059
+ page: lv2.label,
1060
+ path: lv2.path,
1061
+ readonly: Tools.IsNotNull(lv2?.readonly) ? lv2.readonly : true
1062
+ });
1063
+ }
1064
+ //LV2 - Submodule
1065
+ else if (Tools.IsOnlyWhiteSpace(lv2.path) && Tools.IsNotNull(lv2.items)) {
1066
+ //LV3
1067
+ for (const lv3 of lv2.items) {
1068
+ //LV3 Page
1069
+ if (Tools.IsNotOnlyWhiteSpace(lv3.path) && Tools.IsNull(lv3.items)) {
1070
+ menuAccess.push({
1071
+ module: lv1.label,
1072
+ submodule: lv2.label,
1073
+ page: lv3.label,
1074
+ path: lv3.path,
1075
+ readonly: Tools.IsNotNull(lv3?.readonly) ? lv3.readonly : true
1076
+ });
1077
+ }
1078
+ }
1079
+ }
1080
+ }
1081
+ }
1082
+ }
1083
+ return menuAccess;
1084
+ }; }
1085
+ }
1086
+
1087
+ class Source {
1088
+ static { this.storage = 'COER-System'; }
1089
+ /** */
1090
+ static Set(page) {
1091
+ const ROUTER = inject(Router);
1092
+ let path = ROUTER.url;
1093
+ if (path.includes('?'))
1094
+ path = path.split('?')[0];
1095
+ Breadcrumbs.Add(page, path);
1096
+ const breadcrumbs = Breadcrumbs.Get();
1097
+ if (breadcrumbs.length >= 2) {
1098
+ breadcrumbs.pop();
1099
+ const breadcrumb = breadcrumbs.pop();
1100
+ this.Save({ page: breadcrumb.page, path: breadcrumb.path });
1101
+ }
1102
+ else
1103
+ this.Save(null);
1104
+ }
1105
+ /** */
1106
+ static Save(source) {
1107
+ let storage = sessionStorage.getItem(this.storage);
1108
+ if (storage)
1109
+ storage = JSON.parse(storage);
1110
+ storage = Object.assign({}, storage, { source });
1111
+ sessionStorage.setItem(this.storage, JSON.stringify(storage));
1112
+ }
1113
+ /** */
1114
+ static Get() {
1115
+ let storage = sessionStorage.getItem(this.storage);
1116
+ if (storage) {
1117
+ storage = JSON.parse(storage);
1118
+ if (storage.hasOwnProperty('source')) {
1119
+ return storage.source;
1120
+ }
1121
+ }
1122
+ return null;
1123
+ }
1124
+ /** */
1125
+ static GetRoot() {
1126
+ const breadcrumbs = Breadcrumbs.Get();
1127
+ return (breadcrumbs.length > 0) ? breadcrumbs.shift() : null;
1128
+ }
1129
+ /** */
1130
+ static SetPageResponse(pageResponse) {
1131
+ let storage = sessionStorage.getItem(this.storage);
1132
+ storage = JSON.parse(storage);
1133
+ storage = Object.assign({}, storage, { pageResponse });
1134
+ sessionStorage.setItem(this.storage, JSON.stringify(storage));
1135
+ }
1136
+ /** */
1137
+ static GetPageResponse() {
1138
+ let storage = sessionStorage.getItem(this.storage);
1139
+ if (storage) {
1140
+ storage = JSON.parse(storage);
1141
+ if (storage.hasOwnProperty('pageResponse')) {
1142
+ return Tools.BreakReference(storage.pageResponse);
1143
+ }
1144
+ }
1145
+ return null;
1146
+ }
1147
+ /** */
1148
+ static ClearPageResponse() {
1149
+ let storage = sessionStorage.getItem(this.storage);
1150
+ storage = JSON.parse(storage);
1151
+ if (Tools.IsNotNull(storage)) {
1152
+ if (storage.hasOwnProperty('pageResponse')) {
1153
+ delete storage.pageResponse;
1154
+ }
1155
+ storage = Object.assign({}, storage);
1156
+ sessionStorage.setItem(this.storage, JSON.stringify(storage));
1157
+ }
1158
+ }
1159
+ /** */
1160
+ static Reset() {
1161
+ let storage = localStorage.getItem(this.storage);
1162
+ storage = JSON.parse(storage);
1163
+ const user = storage?.user || null;
1164
+ localStorage.removeItem(this.storage);
1165
+ sessionStorage.removeItem(this.storage);
1166
+ if (Tools.IsNotNull(user)) {
1167
+ storage = Object.assign({ user });
1168
+ localStorage.setItem(this.storage, JSON.stringify(storage));
1169
+ }
1170
+ }
1171
+ }
1172
+
1173
+ class Page {
1174
+ constructor(page) {
1175
+ //Injection
1176
+ this.alert = inject(CoerAlert);
1177
+ this.router = inject(Router);
1178
+ this.activatedRoute = inject(ActivatedRoute);
1179
+ /** */
1180
+ this.isUpdate = false;
1181
+ /** */
1182
+ this.isLoading = false;
1183
+ /** */
1184
+ this.isReadonlyPage = true;
1185
+ /** */
1186
+ this.isReadyPage = false;
1187
+ /** */
1188
+ this.enableAnimations = false;
1189
+ /** */
1190
+ this.breadcrumbs = [];
1191
+ /** */
1192
+ this.pageResponse = null;
1193
+ /** */
1194
+ this.pageFilters = {};
1195
+ /** */
1196
+ this.goBack = { show: false };
1197
+ //Private Variables
1198
+ this._path = '';
1199
+ this._page = '';
1200
+ this._source = null;
1201
+ this._preventDestroy = false;
1202
+ /** */
1203
+ this.GoBack = (path) => (() => {
1204
+ if (path)
1205
+ Breadcrumbs.Remove(path);
1206
+ else
1207
+ Breadcrumbs.RemoveLast();
1208
+ });
1209
+ //Grid Templates
1210
+ this.isActiveTemplate = GridTemplates.isActiveTemplate;
1211
+ this.coerSwitchTemplate = GridTemplates.coerSwitchTemplate;
1212
+ this.coerTextboxTemplate = GridTemplates.coerTextboxTemplate;
1213
+ this.coerIconTemplate = GridTemplates.coerIconTemplate;
1214
+ //Tools
1215
+ this.IsNull = Tools.IsNull;
1216
+ this.IsNotNull = Tools.IsNotNull;
1217
+ this.IsOnlyWhiteSpace = Tools.IsOnlyWhiteSpace;
1218
+ this.IsNotOnlyWhiteSpace = Tools.IsNotOnlyWhiteSpace;
1219
+ this.Sleep = Tools.Sleep;
1220
+ //ElementsHTML
1221
+ this.IsInvalidElement = ElementsHTML.IsInvalidElement;
1222
+ if (page.toUpperCase().toUpperCase() === 'HOME')
1223
+ Source.Reset();
1224
+ this.SetPageName(page);
1225
+ this.__SetSource();
1226
+ this.__GetSource();
1227
+ this.__GetNavigation();
1228
+ this.__SetGoBack();
1229
+ this.__GetPageMode();
1230
+ this.__GetPageFilter();
1231
+ this.__GetPageResponse();
1232
+ }
1233
+ async ngAfterViewInit() {
1234
+ this.routeParams = this.activatedRoute.snapshot.params;
1235
+ this.queryParams = this.activatedRoute.snapshot.queryParams;
1236
+ await Tools.Sleep();
1237
+ this.isReadyPage = true;
1238
+ this.RunPage();
1239
+ await Tools.Sleep(1000);
1240
+ this.enableAnimations = true;
1241
+ }
1242
+ ngOnDestroy() {
1243
+ if (!this._preventDestroy)
1244
+ Source.ClearPageResponse();
1245
+ }
1246
+ /** Main method. Starts after ngAfterViewInit() */
1247
+ RunPage() { }
1248
+ ;
1249
+ /** Rename the last breadcrumb and update the url id */
1250
+ SetPageName(name, id = null) {
1251
+ this._page = name;
1252
+ this._path = this.router.url;
1253
+ if (this._path.includes('?'))
1254
+ this._path = this._path.split('?')[0];
1255
+ if (id) {
1256
+ const PATH_ARRAY = this._path.split('/');
1257
+ const PATH_ID = Tools.BreakReference(PATH_ARRAY).pop();
1258
+ if (PATH_ID) {
1259
+ PATH_ARRAY[PATH_ARRAY.length - 1] = String(id);
1260
+ this._path = PATH_ARRAY.join('/');
1261
+ }
1262
+ }
1263
+ if (this.breadcrumbs.length > 0) {
1264
+ this.breadcrumbs[this.breadcrumbs.length - 1].page = name;
1265
+ this.breadcrumbs[this.breadcrumbs.length - 1].path = this._path;
1266
+ Breadcrumbs.SetLast(name, this._path);
1267
+ }
1268
+ this.router.navigateByUrl(this._path);
1269
+ }
1270
+ /** */
1271
+ __SetSource() {
1272
+ Source.Set(this._page);
1273
+ }
1274
+ /** */
1275
+ __GetSource() {
1276
+ this._source = Source.Get();
1277
+ }
1278
+ /** */
1279
+ __GetPageResponse() {
1280
+ this.pageResponse = Source.GetPageResponse();
1281
+ }
1282
+ /** */
1283
+ __GetNavigation() {
1284
+ if (this._source) {
1285
+ this.breadcrumbs = Breadcrumbs.Get().map(item => Object.assign({
1286
+ page: item.page,
1287
+ path: item.path,
1288
+ click: this.GoBack(item.path)
1289
+ }));
1290
+ }
1291
+ else
1292
+ this.breadcrumbs = [{ page: this._page }];
1293
+ }
1294
+ /** */
1295
+ __SetGoBack() {
1296
+ if (this._source) {
1297
+ this.goBack = {
1298
+ show: true,
1299
+ path: this._source.path,
1300
+ click: this.GoBack()
1301
+ };
1302
+ }
1303
+ }
1304
+ /** */
1305
+ __GetPageMode() {
1306
+ const subscribe$ = this.activatedRoute.data.subscribe({
1307
+ next: ({ module, submodule, page }) => {
1308
+ const menuAccess = Menu.GetMenuAccess().find(x => x.module === module
1309
+ && x.submodule === submodule
1310
+ && x.page === page);
1311
+ this.isReadonlyPage = Tools.IsNotNull(menuAccess) ? menuAccess.readonly : true;
1312
+ },
1313
+ error: (message) => { console.error(message); },
1314
+ complete: () => { subscribe$.unsubscribe(); }
1315
+ });
1316
+ }
1317
+ /** Navigate to previous page */
1318
+ GoToSource(pageResponse = null) {
1319
+ if (this._source) {
1320
+ Breadcrumbs.RemoveLast();
1321
+ this.SetPageResponse(pageResponse);
1322
+ this.RemovePageFilter();
1323
+ Tools.Sleep().then(_ => this.router.navigateByUrl(this._source.path));
1324
+ }
1325
+ }
1326
+ ;
1327
+ /** */
1328
+ SetPageResponse(pageResponse = null) {
1329
+ if (Tools.IsNotNull(pageResponse)) {
1330
+ this._preventDestroy = true;
1331
+ Source.SetPageResponse(pageResponse);
1332
+ }
1333
+ }
1334
+ ;
1335
+ /** */
1336
+ ReloadPage() {
1337
+ Breadcrumbs.RemoveLast();
1338
+ setTimeout(() => window.location.reload());
1339
+ }
1340
+ /** */
1341
+ SetPageFilters(filters) {
1342
+ this.pageFilters = Tools.BreakReference(filters);
1343
+ Filters.Add(this.pageFilters, this._path);
1344
+ }
1345
+ /** */
1346
+ __GetPageFilter() {
1347
+ this.pageFilters = Filters.Get(this._path);
1348
+ }
1349
+ /** */
1350
+ RemovePageFilter() {
1351
+ this.pageFilters = {};
1352
+ Filters.Remove(this._path);
1353
+ }
1354
+ /** */
1355
+ Log(value, log = null) {
1356
+ if (Tools.IsNotNull(log))
1357
+ console.log({ log, value });
1358
+ else
1359
+ console.log(value);
1360
+ }
1361
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: Page, deps: [{ token: String }], target: i0.ɵɵFactoryTarget.Component }); }
1362
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.1", type: Page, isStandalone: true, selector: "ng-component", ngImport: i0, template: '', isInline: true }); }
1363
+ }
1364
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: Page, decorators: [{
1365
+ type: Component,
1366
+ args: [{ template: '' }]
1367
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1368
+ type: Inject,
1369
+ args: [String]
1370
+ }] }] });
1371
+
1372
+ class Screen {
1373
+ static get WINDOW_WIDTH() {
1374
+ return window.innerWidth;
1375
+ }
1376
+ static get WINDOW_HEIGHT() {
1377
+ return window.innerHeight;
1378
+ }
1379
+ static get DEVICE_WIDTH() {
1380
+ return window.screen.width;
1381
+ }
1382
+ static get DEVICE_HEIGHT() {
1383
+ return window.screen.height;
1384
+ }
1385
+ static get BREAKPOINT() {
1386
+ if (window.innerWidth < 576)
1387
+ return 'xs';
1388
+ else if (window.innerWidth >= 576 && window.innerWidth < 768)
1389
+ return 'sm';
1390
+ else if (window.innerWidth >= 768 && window.innerWidth < 992)
1391
+ return 'md';
1392
+ else if (window.innerWidth >= 992 && window.innerWidth < 1200)
1393
+ return 'lg';
1394
+ else if (window.innerWidth >= 1200 && window.innerWidth < 1400)
1395
+ return 'xl';
1396
+ else
1397
+ return 'xxl';
1398
+ }
1399
+ /** */
1400
+ static { this.Resize = new Observable(subscriber => {
1401
+ const handleResize = () => {
1402
+ subscriber.next({
1403
+ width: window.innerWidth,
1404
+ height: window.innerHeight,
1405
+ breakpoint: this.BREAKPOINT
1406
+ });
1407
+ };
1408
+ window.addEventListener("resize", handleResize);
1409
+ window.addEventListener("load", handleResize);
1410
+ return () => {
1411
+ window.removeEventListener("resize", handleResize);
1412
+ window.removeEventListener("load", handleResize);
1413
+ };
1414
+ }); }
1415
+ /** */
1416
+ static { this.BackButtonBrowser = new Observable(subscriber => {
1417
+ const handlePopState = (popStateEvent) => {
1418
+ if (popStateEvent.state && popStateEvent.target) {
1419
+ subscriber.next(popStateEvent.target.location.href);
1420
+ }
1421
+ };
1422
+ window.addEventListener('popstate', handlePopState);
1423
+ return () => {
1424
+ window.removeEventListener('popstate', handlePopState);
1425
+ };
1426
+ }); }
1427
+ }
1428
+
1429
+ class Section {
1430
+ constructor() {
1431
+ //Injection
1432
+ this.alert = inject(CoerAlert);
1433
+ this.router = inject(Router);
1434
+ //Inputs
1435
+ this.isLoading = input(false);
1436
+ this.isUpdate = input(false);
1437
+ //Outputs
1438
+ this.onReady = output();
1439
+ this.onDestroy = output();
1440
+ this.onIsLoading = output();
1441
+ this.onUpdated = output();
1442
+ //Variables
1443
+ this.enableAnimations = false;
1444
+ //Grid Templates
1445
+ this.isActiveTemplate = GridTemplates.isActiveTemplate;
1446
+ this.coerSwitchTemplate = GridTemplates.coerSwitchTemplate;
1447
+ this.coerTextboxTemplate = GridTemplates.coerTextboxTemplate;
1448
+ this.coerIconTemplate = GridTemplates.coerIconTemplate;
1449
+ //Tools
1450
+ this.IsNull = Tools.IsNull;
1451
+ this.IsNotNull = Tools.IsNotNull;
1452
+ this.IsOnlyWhiteSpace = Tools.IsOnlyWhiteSpace;
1453
+ this.IsNotOnlyWhiteSpace = Tools.IsNotOnlyWhiteSpace;
1454
+ this.Sleep = Tools.Sleep;
1455
+ //ElementsHTML
1456
+ this.IsInvalidElement = ElementsHTML.IsInvalidElement;
1457
+ }
1458
+ ngAfterViewInit() {
1459
+ Tools.Sleep().then(_ => {
1460
+ this.RunSection();
1461
+ this.onReady.emit();
1462
+ });
1463
+ Tools.Sleep(1000).then(_ => this.enableAnimations = true);
1464
+ }
1465
+ ngOnDestroy() {
1466
+ this.onDestroy.emit(null);
1467
+ }
1468
+ /** Main method. Starts after ngAfterViewInit() */
1469
+ RunSection() { }
1470
+ ;
1471
+ /** */
1472
+ Log(value, log = null) {
1473
+ if (Tools.IsNotNull(log))
1474
+ console.log({ log, value });
1475
+ else
1476
+ console.log(value);
1477
+ }
1478
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: Section, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1479
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.0.1", type: Section, isStandalone: true, selector: "ng-component", inputs: { isLoading: { classPropertyName: "isLoading", publicName: "isLoading", isSignal: true, isRequired: false, transformFunction: null }, isUpdate: { classPropertyName: "isUpdate", publicName: "isUpdate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onReady: "onReady", onDestroy: "onDestroy", onIsLoading: "onIsLoading", onUpdated: "onUpdated" }, ngImport: i0, template: '', isInline: true }); }
1480
+ }
1481
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: Section, decorators: [{
1482
+ type: Component,
1483
+ args: [{ template: '' }]
1484
+ }] });
1485
+
1486
+ class Service {
1487
+ constructor() {
1488
+ //Injections
1489
+ this.alert = inject(CoerAlert);
1490
+ this.http = inject(HttpClient);
1491
+ this.httpCode = {
1492
+ Ok: 200,
1493
+ Created: 201,
1494
+ NoContent: 204,
1495
+ BadRequest: 400,
1496
+ Unauthorize: 401,
1497
+ Forbidden: 403,
1498
+ NotFound: 404,
1499
+ NotAllowed: 405,
1500
+ NotAcceptable: 406,
1501
+ Conflict: 409,
1502
+ PayloadTooLarge: 413,
1503
+ InnerError: 500
1504
+ };
1505
+ }
1506
+ /** */
1507
+ ReleaseSubscription(subscription) {
1508
+ if (subscription && !subscription.closed)
1509
+ subscription.unsubscribe();
1510
+ }
1511
+ /** HTTP GET */
1512
+ HTTP_GET(request, cancelPrevious = true) {
1513
+ return new Promise(Resolve => {
1514
+ if (cancelPrevious) {
1515
+ this.ReleaseSubscription(this._GET$);
1516
+ this._GET$ = this.http.request(new HttpRequest("GET", request.url, {
1517
+ params: request.queryParams,
1518
+ headers: request.headers,
1519
+ responseType: request.responseType,
1520
+ withCredentials: request.withCredentials
1521
+ })).subscribe({
1522
+ next: (response) => {
1523
+ if (response.type > 0) {
1524
+ Resolve({
1525
+ body: Tools.BreakReference(response.body),
1526
+ status: response.status,
1527
+ message: response.statusText,
1528
+ ok: true
1529
+ });
1530
+ }
1531
+ },
1532
+ error: (httpError) => {
1533
+ this.ReleaseSubscription(this._GET$);
1534
+ this.AlertError(httpError, request.alertError);
1535
+ Resolve({
1536
+ body: {},
1537
+ status: httpError.status,
1538
+ message: httpError.error?.message || httpError.error,
1539
+ ok: false
1540
+ });
1541
+ },
1542
+ complete: () => {
1543
+ this.ReleaseSubscription(this._GET$);
1544
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1545
+ this.alert.Success(request.alertSuccess);
1546
+ }
1547
+ }
1548
+ });
1549
+ }
1550
+ else {
1551
+ const subscription = this.http.request(new HttpRequest("GET", request.url, {
1552
+ params: request.queryParams,
1553
+ headers: request.headers,
1554
+ responseType: request.responseType,
1555
+ withCredentials: request.withCredentials
1556
+ })).subscribe({
1557
+ next: (response) => {
1558
+ if (response.type > 0) {
1559
+ Resolve({
1560
+ body: Tools.BreakReference(response.body),
1561
+ status: response.status,
1562
+ message: response.statusText,
1563
+ ok: true
1564
+ });
1565
+ }
1566
+ },
1567
+ error: (httpError) => {
1568
+ this.ReleaseSubscription(subscription);
1569
+ this.AlertError(httpError, request.alertError);
1570
+ Resolve({
1571
+ body: {},
1572
+ status: httpError.status,
1573
+ message: httpError.error?.message || httpError.error,
1574
+ ok: false
1575
+ });
1576
+ },
1577
+ complete: () => {
1578
+ this.ReleaseSubscription(subscription);
1579
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1580
+ this.alert.Success(request.alertSuccess);
1581
+ }
1582
+ }
1583
+ });
1584
+ }
1585
+ });
1586
+ }
1587
+ /** HTTP POST */
1588
+ HTTP_POST(request, cancelPrevious = true) {
1589
+ return new Promise(Resolve => {
1590
+ if (cancelPrevious) {
1591
+ this.ReleaseSubscription(this._POST$);
1592
+ this._POST$ = this.http.request(new HttpRequest("POST", request.url, request.body, {
1593
+ params: request.queryParams,
1594
+ headers: request.headers,
1595
+ responseType: request.responseType,
1596
+ withCredentials: request.withCredentials
1597
+ })).subscribe({
1598
+ next: (response) => {
1599
+ if (response.type > 0) {
1600
+ Resolve({
1601
+ body: Tools.BreakReference(response.body),
1602
+ status: response.status,
1603
+ message: response.statusText,
1604
+ ok: true
1605
+ });
1606
+ }
1607
+ },
1608
+ error: (httpError) => {
1609
+ this.ReleaseSubscription(this._POST$);
1610
+ this.AlertError(httpError, request.alertError);
1611
+ Resolve({
1612
+ body: {},
1613
+ status: httpError.status,
1614
+ message: httpError.error?.message || httpError.error,
1615
+ ok: false
1616
+ });
1617
+ },
1618
+ complete: () => {
1619
+ this.ReleaseSubscription(this._POST$);
1620
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1621
+ this.alert.Success(request.alertSuccess);
1622
+ }
1623
+ }
1624
+ });
1625
+ }
1626
+ else {
1627
+ const subscription = this.http.request(new HttpRequest("POST", request.url, request.body, {
1628
+ params: request.queryParams,
1629
+ headers: request.headers,
1630
+ responseType: request.responseType,
1631
+ withCredentials: request.withCredentials
1632
+ })).subscribe({
1633
+ next: (response) => {
1634
+ if (response.type > 0) {
1635
+ Resolve({
1636
+ body: Tools.BreakReference(response.body),
1637
+ status: response.status,
1638
+ message: response.statusText,
1639
+ ok: true
1640
+ });
1641
+ }
1642
+ },
1643
+ error: (httpError) => {
1644
+ this.ReleaseSubscription(subscription);
1645
+ this.AlertError(httpError, request.alertError);
1646
+ Resolve({
1647
+ body: {},
1648
+ status: httpError.status,
1649
+ message: httpError.error?.message || httpError.error,
1650
+ ok: false
1651
+ });
1652
+ },
1653
+ complete: () => {
1654
+ this.ReleaseSubscription(subscription);
1655
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1656
+ this.alert.Success(request.alertSuccess);
1657
+ }
1658
+ }
1659
+ });
1660
+ }
1661
+ });
1662
+ }
1663
+ /** HTTP PUT */
1664
+ HTTP_PUT(request, cancelPrevious = true) {
1665
+ return new Promise(Resolve => {
1666
+ if (cancelPrevious) {
1667
+ this.ReleaseSubscription(this._PUT$);
1668
+ this._PUT$ = this.http.request(new HttpRequest("PUT", request.url, request.body, {
1669
+ params: request.queryParams,
1670
+ headers: request.headers,
1671
+ responseType: request.responseType,
1672
+ withCredentials: request.withCredentials
1673
+ })).subscribe({
1674
+ next: (response) => {
1675
+ if (response.type > 0) {
1676
+ Resolve({
1677
+ body: {},
1678
+ status: response.status,
1679
+ message: response.statusText,
1680
+ ok: true
1681
+ });
1682
+ }
1683
+ },
1684
+ error: (httpError) => {
1685
+ this.ReleaseSubscription(this._PUT$);
1686
+ this.AlertError(httpError, request.alertError);
1687
+ Resolve({
1688
+ body: {},
1689
+ status: httpError.status,
1690
+ message: httpError.error?.message || httpError.error,
1691
+ ok: false
1692
+ });
1693
+ },
1694
+ complete: () => {
1695
+ this.ReleaseSubscription(this._PUT$);
1696
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1697
+ this.alert.Success(request.alertSuccess, 'Updated', 'fa-solid fa-arrows-rotate fa-spin');
1698
+ }
1699
+ }
1700
+ });
1701
+ }
1702
+ else {
1703
+ const subscription = this.http.request(new HttpRequest("PUT", request.url, request.body, {
1704
+ params: request.queryParams,
1705
+ headers: request.headers,
1706
+ responseType: request.responseType,
1707
+ withCredentials: request.withCredentials
1708
+ })).subscribe({
1709
+ next: (response) => {
1710
+ if (response.type > 0) {
1711
+ Resolve({
1712
+ body: {},
1713
+ status: response.status,
1714
+ message: response.statusText,
1715
+ ok: true
1716
+ });
1717
+ }
1718
+ },
1719
+ error: (httpError) => {
1720
+ this.ReleaseSubscription(subscription);
1721
+ this.AlertError(httpError, request.alertError);
1722
+ Resolve({
1723
+ body: {},
1724
+ status: httpError.status,
1725
+ message: httpError.error?.message || httpError.error,
1726
+ ok: false
1727
+ });
1728
+ },
1729
+ complete: () => {
1730
+ this.ReleaseSubscription(subscription);
1731
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1732
+ this.alert.Success(request.alertSuccess, 'Updated', 'fa-solid fa-arrows-rotate fa-spin');
1733
+ }
1734
+ }
1735
+ });
1736
+ }
1737
+ });
1738
+ }
1739
+ /** HTTP PATCH */
1740
+ HTTP_PATCH(request, cancelPrevious = true) {
1741
+ return new Promise(Resolve => {
1742
+ if (cancelPrevious) {
1743
+ this.ReleaseSubscription(this._PATCH$);
1744
+ this._PATCH$ = this.http.request(new HttpRequest("PATCH", request.url, request.body, {
1745
+ params: request.queryParams,
1746
+ headers: request.headers,
1747
+ responseType: request.responseType,
1748
+ withCredentials: request.withCredentials
1749
+ })).subscribe({
1750
+ next: (response) => {
1751
+ if (response.type > 0) {
1752
+ Resolve({
1753
+ body: {},
1754
+ status: response.status,
1755
+ message: response.statusText,
1756
+ ok: true
1757
+ });
1758
+ }
1759
+ },
1760
+ error: (httpError) => {
1761
+ this.ReleaseSubscription(this._PATCH$);
1762
+ this.AlertError(httpError, request.alertError);
1763
+ Resolve({
1764
+ body: {},
1765
+ status: httpError.status,
1766
+ message: httpError.error?.message || httpError.error,
1767
+ ok: false
1768
+ });
1769
+ },
1770
+ complete: () => {
1771
+ this.ReleaseSubscription(this._PATCH$);
1772
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1773
+ this.alert.Success(request.alertSuccess, 'Updated', 'fa-solid fa-arrows-rotate fa-spin');
1774
+ }
1775
+ }
1776
+ });
1777
+ }
1778
+ else {
1779
+ const subscription = this.http.request(new HttpRequest("PATCH", request.url, request.body, {
1780
+ params: request.queryParams,
1781
+ headers: request.headers,
1782
+ responseType: request.responseType,
1783
+ withCredentials: request.withCredentials
1784
+ })).subscribe({
1785
+ next: (response) => {
1786
+ if (response.type > 0) {
1787
+ Resolve({
1788
+ body: {},
1789
+ status: response.status,
1790
+ message: response.statusText,
1791
+ ok: true
1792
+ });
1793
+ }
1794
+ },
1795
+ error: (httpError) => {
1796
+ this.ReleaseSubscription(subscription);
1797
+ this.AlertError(httpError, request.alertError);
1798
+ Resolve({
1799
+ body: {},
1800
+ status: httpError.status,
1801
+ message: httpError.error?.message || httpError.error,
1802
+ ok: false
1803
+ });
1804
+ },
1805
+ complete: () => {
1806
+ this.ReleaseSubscription(subscription);
1807
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1808
+ this.alert.Success(request.alertSuccess, 'Updated', 'fa-solid fa-arrows-rotate fa-spin');
1809
+ }
1810
+ }
1811
+ });
1812
+ }
1813
+ });
1814
+ }
1815
+ /** HTTP DELETE */
1816
+ HTTP_DELETE(request, cancelPrevious = true) {
1817
+ return new Promise(Resolve => {
1818
+ if (cancelPrevious) {
1819
+ this.ReleaseSubscription(this._DELETE$);
1820
+ this._DELETE$ = this.http.request(new HttpRequest("DELETE", request.url, {
1821
+ params: request.queryParams,
1822
+ headers: request.headers,
1823
+ responseType: request.responseType,
1824
+ withCredentials: request.withCredentials
1825
+ })).subscribe({
1826
+ next: (response) => {
1827
+ if (response.type > 0) {
1828
+ Resolve({
1829
+ body: {},
1830
+ status: response.status,
1831
+ message: response.statusText,
1832
+ ok: true
1833
+ });
1834
+ }
1835
+ },
1836
+ error: (httpError) => {
1837
+ this.ReleaseSubscription(this._DELETE$);
1838
+ this.AlertError(httpError, request.alertError);
1839
+ Resolve({
1840
+ body: {},
1841
+ status: httpError.status,
1842
+ message: httpError.error?.message || httpError.error,
1843
+ ok: false
1844
+ });
1845
+ },
1846
+ complete: () => {
1847
+ this.ReleaseSubscription(this._DELETE$);
1848
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1849
+ this.alert.Success(request.alertSuccess, 'Deleted', 'fa-regular fa-trash-can');
1850
+ }
1851
+ }
1852
+ });
1853
+ }
1854
+ else {
1855
+ const subscription = this.http.request(new HttpRequest("DELETE", request.url, {
1856
+ params: request.queryParams,
1857
+ headers: request.headers,
1858
+ responseType: request.responseType,
1859
+ withCredentials: request.withCredentials
1860
+ })).subscribe({
1861
+ next: (response) => {
1862
+ if (response.type > 0) {
1863
+ Resolve({
1864
+ body: {},
1865
+ status: response.status,
1866
+ message: response.statusText,
1867
+ ok: true
1868
+ });
1869
+ }
1870
+ },
1871
+ error: (httpError) => {
1872
+ this.ReleaseSubscription(subscription);
1873
+ this.AlertError(httpError, request.alertError);
1874
+ Resolve({
1875
+ body: {},
1876
+ status: httpError.status,
1877
+ message: httpError.error?.message || httpError.error,
1878
+ ok: false
1879
+ });
1880
+ },
1881
+ complete: () => {
1882
+ this.ReleaseSubscription(subscription);
1883
+ if (Tools.IsNotOnlyWhiteSpace(request.alertSuccess)) {
1884
+ this.alert.Success(request.alertSuccess, 'Deleted', 'fa-regular fa-trash-can');
1885
+ }
1886
+ }
1887
+ });
1888
+ }
1889
+ });
1890
+ }
1891
+ /** */
1892
+ DOWNLOAD_CSV(buffer, fileName = '') {
1893
+ if (Tools.IsOnlyWhiteSpace(fileName))
1894
+ fileName = 'COERSystem';
1895
+ if (!fileName.endsWith('.csv'))
1896
+ fileName += ".csv";
1897
+ const BLOB = new Blob([buffer], { type: 'application/csv' });
1898
+ saveAs(BLOB, fileName);
1899
+ return BLOB;
1900
+ }
1901
+ /** */
1902
+ AlertError(httpError, message) {
1903
+ if (httpError.status >= 500) {
1904
+ if (Tools.IsNotOnlyWhiteSpace(message)) {
1905
+ this.alert.Error(message, 'BUG', 'fa-solid fa-bug', null);
1906
+ }
1907
+ }
1908
+ else if (httpError.status < 500) {
1909
+ switch (httpError.status) {
1910
+ case 400: {
1911
+ this.alert.Warning(httpError.error?.message || httpError.error, 'Bad Request', 'fa-regular fa-face-grin-beam-sweat fa-lg');
1912
+ break;
1913
+ }
1914
+ case 401: {
1915
+ this.alert.Warning(httpError.error?.message || httpError.error, 'Unauthorize', 'fa-regular fa-face-rolling-eyes fa-lg');
1916
+ break;
1917
+ }
1918
+ case 403: {
1919
+ this.alert.Warning(httpError.error?.message || httpError.error, 'Forbidden', 'fa-regular fa-face-rolling-eyes fa-lg');
1920
+ break;
1921
+ }
1922
+ case 404: {
1923
+ this.alert.Warning(httpError.error?.message || httpError.error, 'Not Found', 'fa-regular fa-face-meh fa-lg');
1924
+ break;
1925
+ }
1926
+ case 405: {
1927
+ this.alert.Warning(httpError.error?.message || httpError.error, 'Not Allowed', 'fa-regular fa-face-grimace fa-lg');
1928
+ break;
1929
+ }
1930
+ case 406: {
1931
+ this.alert.Warning(httpError.error?.message || httpError.error, 'Not Acceptable', 'fa-regular fa-face-frown-open fa-lg');
1932
+ break;
1933
+ }
1934
+ case 409: {
1935
+ this.alert.Warning(httpError.error?.message || httpError.error, 'Conflict', 'fa-regular fa-face-dizzy fa-lg');
1936
+ break;
1937
+ }
1938
+ case 413: {
1939
+ this.alert.Warning(httpError.error?.message || httpError.error, 'Too Large', 'fa-regular fa-face-flushed fa-lg');
1940
+ break;
1941
+ }
1942
+ default: {
1943
+ if (httpError.status <= 0) {
1944
+ this.alert.Warning('Without Connection', 'WEB API DOWN', 'fa-solid fa-plug-circle-xmark fa-lg');
1945
+ }
1946
+ else
1947
+ this.alert.Warning(httpError.error?.message || httpError.error);
1948
+ break;
1949
+ }
1950
+ }
1951
+ }
1952
+ }
1953
+ }
1954
+
1955
+ /**
1956
+ * Generated bundle index. Do not edit.
1957
+ */
1958
+
1959
+ export { Breadcrumbs, CONTROL_VALUE, CoerAlert, Colors, ControlValue, DateTime, ElementsHTML, Files, Filters, GridTemplates, Menu, Page, Screen, Section, Service, Source, Tools, User };
1960
+ //# sourceMappingURL=coer-elements-tools.mjs.map