@sankhyalabs/sankhyablocks 2.5.2 → 2.6.1

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 (153) hide show
  1. package/dist/cjs/{SnkMessageBuilder-370e23ae.js → SnkMessageBuilder-09b25b0a.js} +20 -1
  2. package/dist/cjs/data-exporter-option-417da37a.js +19 -0
  3. package/dist/cjs/{index-20e8b68a.js → index-2cd6f753.js} +26 -0
  4. package/dist/cjs/index-696b5c3b.js +200 -0
  5. package/dist/cjs/loader.cjs.js +2 -2
  6. package/dist/cjs/sankhyablocks.cjs.js +2 -2
  7. package/dist/cjs/snk-application.cjs.entry.js +2 -2
  8. package/dist/cjs/snk-config-options.cjs.entry.js +1 -1
  9. package/dist/cjs/snk-configurator_3.cjs.entry.js +71 -13
  10. package/dist/cjs/snk-crud.cjs.entry.js +3 -2
  11. package/dist/cjs/{snk-exporter-email-sender_8.cjs.entry.js → snk-data-exporter_9.cjs.entry.js} +305 -8
  12. package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
  13. package/dist/cjs/snk-filter-binary-select.cjs.entry.js +1 -1
  14. package/dist/cjs/snk-filter-detail.cjs.entry.js +1 -1
  15. package/dist/cjs/snk-filter-multi-select.cjs.entry.js +1 -1
  16. package/dist/cjs/snk-filter-number.cjs.entry.js +1 -1
  17. package/dist/cjs/snk-filter-period.cjs.entry.js +1 -1
  18. package/dist/cjs/snk-filter-personalized.cjs.entry.js +1 -1
  19. package/dist/cjs/snk-filter-search.cjs.entry.js +1 -1
  20. package/dist/cjs/snk-filter-text.cjs.entry.js +1 -1
  21. package/dist/cjs/snk-form-config.cjs.entry.js +1 -1
  22. package/dist/cjs/snk-form.cjs.entry.js +1 -1
  23. package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
  24. package/dist/cjs/snk-tab-config.cjs.entry.js +1 -1
  25. package/dist/cjs/{taskbar-elements-3807c809.js → taskbar-elements-bbb89cdb.js} +8 -5
  26. package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
  27. package/dist/collection/collection-manifest.json +1 -0
  28. package/dist/collection/components/snk-crud/snk-crud.js +4 -2
  29. package/dist/collection/components/snk-data-exporter/enum/data-exporter-option.js +11 -0
  30. package/dist/collection/components/snk-data-exporter/exporter-email-sender/snk-exporter-email-sender.js +4 -4
  31. package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +1 -0
  32. package/dist/collection/components/snk-data-exporter/snk-data-exporter.css +19 -0
  33. package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +181 -0
  34. package/dist/collection/components/snk-data-exporter/structure/ItemBuilder.js +140 -0
  35. package/dist/collection/components/snk-form/snk-form.js +4 -2
  36. package/dist/collection/components/snk-form/subcomponents/snk-config-options/snk-config-options.js +3 -1
  37. package/dist/collection/components/snk-form/subcomponents/snk-field-config/snk-field-config.js +4 -2
  38. package/dist/collection/components/snk-form/subcomponents/snk-form-config/snk-form-config.js +3 -1
  39. package/dist/collection/components/snk-grid/snk-grid.js +69 -10
  40. package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +7 -4
  41. package/dist/collection/components/snk-taskbar/snk-taskbar.js +2 -2
  42. package/dist/collection/lib/http/data-fetcher/fetchers/fetchDataExporter/index.js +33 -0
  43. package/dist/collection/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IExporterColumnMetadata.js +1 -0
  44. package/dist/collection/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IFetchDataExporterParams.js +1 -0
  45. package/dist/collection/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IFetchDataExporterResponse.js +1 -0
  46. package/dist/collection/lib/message/SnkMessageBuilder.js +3 -1
  47. package/dist/collection/lib/message/resources/snk-data-exporter.msg.js +16 -0
  48. package/dist/collection/lib/message/resources/snk-taskbar.msg.js +1 -0
  49. package/dist/collection/lib/store/index.js +5 -0
  50. package/dist/collection/lib/utils/fileViewer/index.js +3 -0
  51. package/dist/collection/lib/utils/fileViewer/interfaces/IFileViewerParams.js +1 -0
  52. package/dist/components/ConfigStorage.js +3 -6694
  53. package/dist/components/DataFetcher.js +6695 -0
  54. package/dist/components/SnkMessageBuilder.js +20 -1
  55. package/dist/components/index.d.ts +1 -0
  56. package/dist/components/index.js +1 -0
  57. package/dist/components/snk-application2.js +2 -1
  58. package/dist/components/snk-config-options2.js +1 -1
  59. package/dist/components/snk-crud.js +11 -5
  60. package/dist/components/snk-data-exporter.d.ts +11 -0
  61. package/dist/components/snk-data-exporter.js +6 -0
  62. package/dist/components/snk-data-exporter2.js +330 -0
  63. package/dist/components/snk-field-config2.js +1 -1
  64. package/dist/components/snk-form-config2.js +2 -2
  65. package/dist/components/snk-form2.js +9 -3
  66. package/dist/components/snk-grid2.js +74 -10
  67. package/dist/components/snk-taskbar2.js +212 -9
  68. package/dist/esm/{SnkMessageBuilder-7d583c9a.js → SnkMessageBuilder-47db5d75.js} +20 -1
  69. package/dist/esm/data-exporter-option-006307dd.js +19 -0
  70. package/dist/esm/{index-e4121713.js → index-a77b6f35.js} +25 -1
  71. package/dist/esm/index-d89e384f.js +198 -0
  72. package/dist/esm/loader.js +2 -2
  73. package/dist/esm/sankhyablocks.js +2 -2
  74. package/dist/esm/snk-application.entry.js +2 -2
  75. package/dist/esm/snk-config-options.entry.js +1 -1
  76. package/dist/esm/snk-configurator_3.entry.js +68 -10
  77. package/dist/esm/snk-crud.entry.js +3 -2
  78. package/dist/esm/{snk-exporter-email-sender_8.entry.js → snk-data-exporter_9.entry.js} +304 -8
  79. package/dist/esm/snk-data-unit.entry.js +2 -2
  80. package/dist/esm/snk-filter-binary-select.entry.js +1 -1
  81. package/dist/esm/snk-filter-detail.entry.js +1 -1
  82. package/dist/esm/snk-filter-multi-select.entry.js +1 -1
  83. package/dist/esm/snk-filter-number.entry.js +1 -1
  84. package/dist/esm/snk-filter-period.entry.js +1 -1
  85. package/dist/esm/snk-filter-personalized.entry.js +1 -1
  86. package/dist/esm/snk-filter-search.entry.js +1 -1
  87. package/dist/esm/snk-filter-text.entry.js +1 -1
  88. package/dist/esm/snk-form-config.entry.js +1 -1
  89. package/dist/esm/snk-form.entry.js +1 -1
  90. package/dist/esm/snk-pesquisa.entry.js +1 -1
  91. package/dist/esm/snk-tab-config.entry.js +1 -1
  92. package/dist/esm/{taskbar-elements-b2bbe275.js → taskbar-elements-beec3b27.js} +8 -5
  93. package/dist/esm/teste-pesquisa.entry.js +1 -1
  94. package/dist/sankhyablocks/{p-a3871147.entry.js → p-02d430a7.entry.js} +3 -3
  95. package/dist/sankhyablocks/p-04581d0c.entry.js +1 -0
  96. package/dist/sankhyablocks/p-112bb324.js +1 -0
  97. package/dist/sankhyablocks/{p-c17be74f.entry.js → p-12ebe36a.entry.js} +1 -1
  98. package/dist/sankhyablocks/p-13116d05.entry.js +1 -0
  99. package/dist/sankhyablocks/{p-14af45cc.entry.js → p-187b0d06.entry.js} +1 -1
  100. package/dist/sankhyablocks/{p-570cc474.entry.js → p-1a2533d0.entry.js} +1 -1
  101. package/dist/sankhyablocks/{p-fd3b562d.entry.js → p-1ccaea51.entry.js} +1 -1
  102. package/dist/sankhyablocks/p-1d7a0daf.js +1 -0
  103. package/dist/sankhyablocks/p-50c8bcb7.entry.js +1 -0
  104. package/dist/sankhyablocks/{p-44ce5b90.entry.js → p-57895452.entry.js} +1 -1
  105. package/dist/sankhyablocks/{p-48bbbd2c.entry.js → p-68fcc226.entry.js} +1 -1
  106. package/dist/sankhyablocks/p-719e570a.js +1 -0
  107. package/dist/sankhyablocks/{p-00b3c5d8.entry.js → p-772f1c44.entry.js} +1 -1
  108. package/dist/sankhyablocks/{p-c30d0966.entry.js → p-82e20fc0.entry.js} +1 -1
  109. package/dist/sankhyablocks/{p-eff899b0.entry.js → p-91c23d20.entry.js} +1 -1
  110. package/dist/sankhyablocks/p-a77dd79a.js +2 -0
  111. package/dist/sankhyablocks/{p-f50c6ef6.entry.js → p-ab4ff312.entry.js} +1 -1
  112. package/dist/sankhyablocks/p-c8327a5c.js +1 -0
  113. package/dist/sankhyablocks/{p-2664ae24.entry.js → p-d3e402d3.entry.js} +1 -1
  114. package/dist/sankhyablocks/{p-9593c937.entry.js → p-d7ae56ce.entry.js} +1 -1
  115. package/dist/sankhyablocks/{p-70e52fee.entry.js → p-d96bf6a7.entry.js} +1 -1
  116. package/dist/sankhyablocks/{p-b0a0222f.entry.js → p-df5d94c6.entry.js} +1 -1
  117. package/dist/sankhyablocks/{p-db111acd.entry.js → p-e075dba7.entry.js} +1 -1
  118. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  119. package/dist/types/components/snk-data-exporter/data/attachment.d.ts +1 -1
  120. package/dist/types/components/snk-data-exporter/data/email.d.ts +3 -3
  121. package/dist/types/components/snk-data-exporter/data/export-config.d.ts +5 -5
  122. package/dist/types/components/snk-data-exporter/data/export-result.d.ts +5 -5
  123. package/dist/types/components/snk-data-exporter/data/report.d.ts +1 -1
  124. package/dist/types/components/snk-data-exporter/enum/data-exporter-option.d.ts +10 -0
  125. package/dist/types/components/snk-data-exporter/exporter-email-sender/email-info-step.d.ts +4 -4
  126. package/dist/types/components/snk-data-exporter/exporter-email-sender/options-step.d.ts +4 -4
  127. package/dist/types/components/snk-data-exporter/interfaces/IExporterProvider.d.ts +9 -0
  128. package/dist/types/components/snk-data-exporter/snk-data-exporter.d.ts +40 -0
  129. package/dist/types/components/snk-data-exporter/structure/ItemBuilder.d.ts +61 -0
  130. package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +2 -2
  131. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +1 -1
  132. package/dist/types/components.d.ts +33 -3
  133. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/index.d.ts +3 -0
  134. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IExporterColumnMetadata.d.ts +9 -0
  135. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IFetchDataExporterParams.d.ts +14 -0
  136. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IFetchDataExporterResponse.d.ts +7 -0
  137. package/dist/types/lib/message/resources/snk-data-exporter.msg.d.ts +1 -0
  138. package/dist/types/lib/store/index.d.ts +4 -0
  139. package/dist/types/lib/utils/fileViewer/index.d.ts +2 -0
  140. package/dist/types/lib/utils/fileViewer/interfaces/IFileViewerParams.d.ts +4 -0
  141. package/package.json +2 -1
  142. package/react/components.d.ts +1 -0
  143. package/react/components.js +1 -0
  144. package/react/components.js.map +1 -1
  145. package/dist/cjs/AuthorizationConfig-79ffae4b.js +0 -7
  146. package/dist/esm/AuthorizationConfig-dcbd207a.js +0 -7
  147. package/dist/sankhyablocks/p-8a872a35.entry.js +0 -1
  148. package/dist/sankhyablocks/p-9ba3df4c.js +0 -2
  149. package/dist/sankhyablocks/p-9e67cf79.entry.js +0 -1
  150. package/dist/sankhyablocks/p-c118ef2a.entry.js +0 -1
  151. package/dist/sankhyablocks/p-dbaad88c.js +0 -1
  152. package/dist/sankhyablocks/p-dc36cfbf.js +0 -1
  153. package/dist/sankhyablocks/p-e7f772ed.js +0 -1
@@ -1,14 +1,310 @@
1
- import { h, r as registerInstance, g as getElement, H as Host, c as createEvent } from './index-e4121713.js';
2
- import { ElementIDUtils, DataType, ObjectUtils, StringUtils, ErrorException, ApplicationContext, FloatingManager, ArrayUtils } from '@sankhyalabs/core';
1
+ import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-a77b6f35.js';
2
+ import { ObjectUtils, ApplicationContext, ElementIDUtils, DataType, StringUtils, ErrorException, FloatingManager, ArrayUtils } from '@sankhyalabs/core';
3
+ import { D as DataExporterOption, A as AuthorizationConfig } from './data-exporter-option-006307dd.js';
4
+ import { D as DataFetcher, C as ConfigStorage } from './ConfigStorage-b59461d8.js';
3
5
  import { F as FilterItemType } from './filter-item-type.enum-a79b2fa8.js';
4
6
  import { ModalAction, ModalButtonStatus } from '@sankhyalabs/ezui/dist/collection/components/ez-modal-container';
5
7
  import { toString } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
6
8
  import { CheckMode, ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
7
- import { C as ConfigStorage } from './ConfigStorage-b59461d8.js';
8
9
  import { O as ORDER_VALUES } from './constants-babe1a08.js';
9
- import { A as AuthorizationConfig } from './AuthorizationConfig-dcbd207a.js';
10
- import { T as TaskbarElement, V as VisibleWhenForbidden, A as AuthorizationElements, b as buildElem, a as buildCustomButton } from './taskbar-elements-b2bbe275.js';
10
+ import { T as TaskbarElement, V as VisibleWhenForbidden, A as AuthorizationElements, b as buildElem, a as buildCustomButton } from './taskbar-elements-beec3b27.js';
11
11
  import './_commonjsHelpers-9943807e.js';
12
+ import './index-d89e384f.js';
13
+
14
+ var __rest = (undefined && undefined.__rest) || function (s, e) {
15
+ var t = {};
16
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
17
+ t[p] = s[p];
18
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
19
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
20
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
21
+ t[p[i]] = s[p[i]];
22
+ }
23
+ return t;
24
+ };
25
+ function fetchDataExporter(_a) {
26
+ var { methodName } = _a, requestBody = __rest(_a, ["methodName"]);
27
+ const serviceName = `DataExporterSPBean.${methodName}`;
28
+ const payload = { serviceName, requestBody };
29
+ return new Promise((resolve, reject) => {
30
+ DataFetcher.get()
31
+ .callServiceBroker(serviceName, ObjectUtils.objectToString(payload))
32
+ .then(result => resolve(getFormatResponse(result)))
33
+ .catch(error => reject(error));
34
+ });
35
+ }
36
+ function getFormatResponse(result) {
37
+ var _a;
38
+ const response = (_a = result === null || result === void 0 ? void 0 : result.json) === null || _a === void 0 ? void 0 : _a.$;
39
+ if (response == undefined) {
40
+ return;
41
+ }
42
+ return ObjectUtils.stringToObject(response);
43
+ }
44
+
45
+ function fileViewer({ fileSessionKey }) {
46
+ window.open(`${window.location.protocol}//${window.location.hostname}:${window.location.port}/mge/visualizadorArquivos.mge?chaveArquivo=${fileSessionKey}&download=S`);
47
+ }
48
+
49
+ class ItemBuilder {
50
+ constructor(getMessage, selectedNumber) {
51
+ this._selectedNumber = 0;
52
+ this._getMessage = getMessage;
53
+ this._selectedNumber = selectedNumber;
54
+ }
55
+ /**
56
+ * Método responsável por inserir os items no array de opções.
57
+ * @param option - Nome da opção que será inserida no array.
58
+ * @param items - Array que será alimentado com as opções permitidas.
59
+ */
60
+ setExportOption(option, items) {
61
+ const groupName = this.getExportGroupName();
62
+ if (option === DataExporterOption.EXPORT_TO_PDF) {
63
+ items.push(this.getExportToPDF(groupName));
64
+ }
65
+ if (option === DataExporterOption.EXPORT_TO_XLS) {
66
+ items.push(this.getExportToXLS(groupName));
67
+ }
68
+ this.setExportCurrentPage(option, items);
69
+ this.setExportByEmail(option, items);
70
+ }
71
+ /**
72
+ * Método responsável por inserir os itens de exportação personalizada.
73
+ * @param option - Nome da opção que será inserida no array.
74
+ * @param items - Array que será alimentado com as opções permitidas.
75
+ */
76
+ setExportCurrentPage(option, items) {
77
+ var _a;
78
+ const pageOptions = [DataExporterOption.EXPORT_PAGE_TO_PDF, DataExporterOption.EXPORT_PAGE_TO_XLS];
79
+ if (option === DataExporterOption.EXPORT_CURRENT_PAGE) {
80
+ items.push(this.getCurrentPage());
81
+ }
82
+ if (pageOptions.includes(option)) {
83
+ let item = items.find((item) => item.id === DataExporterOption.EXPORT_CURRENT_PAGE);
84
+ if (item == undefined) {
85
+ items.push(this.getCurrentPage());
86
+ item = items.find((item) => item.id === DataExporterOption.EXPORT_CURRENT_PAGE);
87
+ }
88
+ if (!((_a = item === null || item === void 0 ? void 0 : item.children) === null || _a === void 0 ? void 0 : _a.length)) {
89
+ item.children = [];
90
+ }
91
+ if (option === DataExporterOption.EXPORT_PAGE_TO_PDF) {
92
+ item.children.push(this.getExportPageToPDF());
93
+ }
94
+ if (option === DataExporterOption.EXPORT_PAGE_TO_XLS) {
95
+ item.children.push(this.getExportPageToXLS());
96
+ }
97
+ }
98
+ }
99
+ /**
100
+ * Método responsável por inserir os itens de exportação por e-mail.
101
+ * @param option - Nome da opção que será inserida no array.
102
+ * @param items - Array que será alimentado com as opções permitidas.
103
+ */
104
+ setExportByEmail(option, items) {
105
+ if (option === DataExporterOption.EXPORT_BY_EMAIL) {
106
+ items.push(this.getExportByEmail());
107
+ }
108
+ }
109
+ /**
110
+ * Método responsável por capturar o objeto com os dados de exportação em PDF.
111
+ * @param groupName - Nome do grupo da opção que será inserida na lista.
112
+ * @returns Retorna o objeto com os dados de exportação em PDF.
113
+ */
114
+ getExportToPDF(groupName) {
115
+ return {
116
+ id: DataExporterOption.EXPORT_TO_PDF,
117
+ label: "PDF (.pdf)",
118
+ group: groupName
119
+ };
120
+ }
121
+ /**
122
+ * Método responsável por capturar o objeto com os dados de exportação em XLS.
123
+ * @param groupName - Nome do grupo da opção que será inserida na lista.
124
+ * @returns Retorna o objeto com os dados de exportação em XLS.
125
+ */
126
+ getExportToXLS(groupName) {
127
+ return {
128
+ id: DataExporterOption.EXPORT_TO_XLS,
129
+ label: `${this._getMessage("snkDataExporter.label.spreadsheet")} (.xlsx)`,
130
+ group: groupName
131
+ };
132
+ }
133
+ /**
134
+ * Método responsável por capturar o objeto com os dados de exportação personalizada.
135
+ * @returns Retorna o objeto com os dados de exportação personalizada.
136
+ */
137
+ getCurrentPage() {
138
+ return {
139
+ id: DataExporterOption.EXPORT_CURRENT_PAGE,
140
+ label: this._getMessage("snkDataExporter.label.currentPage"),
141
+ group: this._getMessage("snkDataExporter.group.custom")
142
+ };
143
+ }
144
+ /**
145
+ * Método responsável por capturar o objeto com os dados de exportação personalizada em PDF.
146
+ * @returns Retorna o objeto com os dados de exportação personalizada em PDF.
147
+ */
148
+ getExportPageToPDF() {
149
+ return {
150
+ id: DataExporterOption.EXPORT_PAGE_TO_PDF,
151
+ label: "PDF (.pdf)"
152
+ };
153
+ }
154
+ /**
155
+ * Método responsável por capturar o objeto com os dados de exportação personalizada em XLS.
156
+ * @returns Retorna o objeto com os dados de exportação personalizada em XLS.
157
+ */
158
+ getExportPageToXLS() {
159
+ return {
160
+ id: DataExporterOption.EXPORT_PAGE_TO_XLS,
161
+ label: `${this._getMessage("snkDataExporter.label.spreadsheet")} (.xlsx)`
162
+ };
163
+ }
164
+ /**
165
+ * Método responsável por capturar o objeto com os dados de exportação por e-mail.
166
+ * @returns Retorna o objeto com os dados de exportação por e-mail.
167
+ */
168
+ getExportByEmail() {
169
+ return {
170
+ id: DataExporterOption.EXPORT_BY_EMAIL,
171
+ label: `${this._getMessage("snkDataExporter.label.sendByEmail")}...`
172
+ };
173
+ }
174
+ /**
175
+ * Método responsável por capturar o nome do grupo da opção que será inserida na lista.
176
+ * @returns Retorna o nome do grupo da opção que será inserida na lista.
177
+ */
178
+ getExportGroupName() {
179
+ if (this._selectedNumber === 1) {
180
+ return this._getMessage("snkDataExporter.group.export.selectedLine");
181
+ }
182
+ if (this._selectedNumber > 1) {
183
+ return this._getMessage("snkDataExporter.group.export.multiSelected").replace('{0}', this._selectedNumber.toString());
184
+ }
185
+ return this._getMessage("snkDataExporter.group.export.default");
186
+ }
187
+ }
188
+
189
+ const snkDataExporterCss = ".sc-snk-data-exporter-h{--snk-data-exporter--z-index:var(--more-visible, 2);display:flex;width:fit-content;height:fit-content}.snk-data-exporter.sc-snk-data-exporter{display:flex;width:fit-content;height:fit-content;z-index:var(--snk-data-exporter--z-index)}";
190
+
191
+ const SnkDataExporter = class {
192
+ constructor(hostRef) {
193
+ registerInstance(this, hostRef);
194
+ this.ezClickDataExporter = createEvent(this, "ezClickDataExporter", 7);
195
+ this._items = [];
196
+ this._selectedNumber = 0;
197
+ this._showDropdown = false;
198
+ this._releasedToExport = [
199
+ DataExporterOption.EXPORT_TO_PDF,
200
+ DataExporterOption.EXPORT_BY_EMAIL,
201
+ DataExporterOption.EXPORT_PDF_TO_EMAIL,
202
+ DataExporterOption.EXPORT_XLS_TO_EMAIL
203
+ ];
204
+ /**
205
+ * Provedor das informações para exportação dos dados.
206
+ */
207
+ this.provider = null;
208
+ }
209
+ /**
210
+ * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
211
+ * através de um pequeno modulo na estrutura da aplicação:
212
+ * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
213
+ * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-data-exporter.msg.ts"
214
+ */
215
+ getMessage(key, params) {
216
+ return this._application.messagesBuilder.getMessage(key, params);
217
+ }
218
+ positionDropdown() {
219
+ var _a;
220
+ const bounding = (_a = this._ezButton) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
221
+ if (bounding == undefined || this._ezDropdown == undefined) {
222
+ return;
223
+ }
224
+ this._ezDropdown.style.top = (bounding.y + bounding.height + 5) + "px";
225
+ this._ezDropdown.style.left = bounding.x + "px";
226
+ }
227
+ closeDropdown(evt) {
228
+ const target = evt === null || evt === void 0 ? void 0 : evt.target;
229
+ if (target == undefined) {
230
+ return;
231
+ }
232
+ if (!target.closest(".snk-data-exporter")) {
233
+ this._showDropdown = false;
234
+ }
235
+ }
236
+ setEvents() {
237
+ document.removeEventListener("click", this.closeDropdown.bind(this));
238
+ document.addEventListener("click", this.closeDropdown.bind(this));
239
+ document.removeEventListener("scroll", this.positionDropdown.bind(this));
240
+ document.addEventListener("scroll", this.positionDropdown.bind(this));
241
+ }
242
+ controlDropdown() {
243
+ this._showDropdown = !this._showDropdown;
244
+ }
245
+ async processExporter(evt) {
246
+ const item = evt === null || evt === void 0 ? void 0 : evt.detail;
247
+ if (!this._releasedToExport.includes(item === null || item === void 0 ? void 0 : item.id)) {
248
+ return;
249
+ }
250
+ if (item.id !== DataExporterOption.EXPORT_BY_EMAIL) {
251
+ if (this.provider == undefined) {
252
+ return;
253
+ }
254
+ const filters = this.provider.getFilters();
255
+ const columns = this.provider.getColumnsMetadata();
256
+ const sort = this.provider.getOrders();
257
+ const resourceURI = this.provider.getResourceURI();
258
+ fetchDataExporter({ filters, columns, sort, resourceURI, methodName: item.id })
259
+ .then((response) => fileViewer(Object.assign(Object.assign({}, response), { fileType: "PDF" })))
260
+ .catch(err => console.log(err));
261
+ }
262
+ this.ezClickDataExporter.emit(item);
263
+ this._showDropdown = false;
264
+ }
265
+ getItems() {
266
+ const items = [];
267
+ this._releasedToExport
268
+ .forEach((option) => {
269
+ this._itemBuilder.setExportOption(option, items);
270
+ });
271
+ return items;
272
+ }
273
+ loadDropdown() {
274
+ var _a;
275
+ this._selectedNumber = ((_a = this.provider) === null || _a === void 0 ? void 0 : _a.getSelectedNumber()) || 0;
276
+ this._itemBuilder = new ItemBuilder(this.getMessage.bind(this), this._selectedNumber);
277
+ this._items = this.getItems();
278
+ }
279
+ componentWillLoad() {
280
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
281
+ this.loadDropdown();
282
+ this.setEvents();
283
+ }
284
+ componentDidLoad() {
285
+ if (this._element == undefined) {
286
+ return;
287
+ }
288
+ ElementIDUtils.addIDInfo(this._element);
289
+ }
290
+ componentWillUpdate() {
291
+ if (this._showDropdown) {
292
+ this.loadDropdown();
293
+ }
294
+ }
295
+ componentDidUpdate() {
296
+ if (this._showDropdown) {
297
+ this.positionDropdown();
298
+ }
299
+ }
300
+ render() {
301
+ return (h(Host, null, h("div", { class: "snk-data-exporter" }, h("ez-button", Object.assign({ ref: (ref) => this._ezButton = ref, iconName: "file-download", size: "small", mode: "icon", onClick: () => this.controlDropdown() }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${ElementIDUtils.getInternalIDInfo("button")}` })), this._showDropdown &&
302
+ h("ez-dropdown", Object.assign({ ref: (ref) => this._ezDropdown = ref, items: this._items, onEzClick: (evt) => this.processExporter(evt) }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${ElementIDUtils.getInternalIDInfo("dropdown")}` }))), this._showDropdown &&
303
+ h("div", Object.assign({ class: "ez-scrim ez-scrim-light" }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: `${ElementIDUtils.getInternalIDInfo("ezScrim")}` }))));
304
+ }
305
+ get _element() { return getElement(this); }
306
+ };
307
+ SnkDataExporter.style = snkDataExporterCss;
12
308
 
13
309
  const EmailInfoStep = ({ getMessage, changeInfo, data }) => {
14
310
  return h("div", null,
@@ -1512,7 +1808,7 @@ const SnkTaskbar = class {
1512
1808
  [TaskbarElement.GRID_MODE]: "snkTaskbar.titleGridMode",
1513
1809
  [TaskbarElement.FORM_MODE]: "snkTaskbar.titleFormMode",
1514
1810
  [TaskbarElement.CONFIGURATOR]: "snkTaskbar.titleConfigurator",
1515
- [TaskbarElement.EXPORT]: "snkTaskbar.titleExportar"
1811
+ [TaskbarElement.DATA_EXPORTER]: "snkTaskbar.titleDataExporter"
1516
1812
  };
1517
1813
  }
1518
1814
  observeButtons() {
@@ -1603,7 +1899,7 @@ const SnkTaskbar = class {
1603
1899
  className += "ez-padding-left--medium";
1604
1900
  }
1605
1901
  if (TaskbarElement[def.toString()]) {
1606
- return buildElem(def, className, this.getIdElemBtnNative(def), elem => this.getTitle(elem), elem => this.elementClick(elem), elem => this.isEnabled(elem), this.actionsList);
1902
+ return buildElem(def, className, this.getIdElemBtnNative(def), elem => this.getTitle(elem), elem => this.elementClick(elem), elem => this.isEnabled(elem), this.actionsList, this.configName);
1607
1903
  }
1608
1904
  else {
1609
1905
  return buildCustomButton(def, className, this.getIdElemBtnCustom(def), elem => this.elementClick(elem), elem => this.isEnabled(elem));
@@ -1681,4 +1977,4 @@ const SnkTaskbar = class {
1681
1977
  };
1682
1978
  SnkTaskbar.style = snkTaskbarCss;
1683
1979
 
1684
- export { SnkExporterEmailSender as snk_exporter_email_sender, SnkFilterBar as snk_filter_bar, SnkFilterItem as snk_filter_item, SnkFilterList as snk_filter_list, SnkFilterModal as snk_filter_modal, EzGridConfig as snk_grid_config, SelectBox as snk_select_box, SnkTaskbar as snk_taskbar };
1980
+ export { SnkDataExporter as snk_data_exporter, SnkExporterEmailSender as snk_exporter_email_sender, SnkFilterBar as snk_filter_bar, SnkFilterItem as snk_filter_item, SnkFilterList as snk_filter_list, SnkFilterModal as snk_filter_modal, EzGridConfig as snk_grid_config, SelectBox as snk_select_box, SnkTaskbar as snk_taskbar };
@@ -1,7 +1,7 @@
1
- import { r as registerInstance, c as createEvent, h, g as getElement, H as Host } from './index-e4121713.js';
1
+ import { r as registerInstance, c as createEvent, h, g as getElement, H as Host } from './index-a77b6f35.js';
2
2
  import { Action, ApplicationContext } from '@sankhyalabs/core';
3
3
  import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
4
- import { O as OperationMap } from './SnkMessageBuilder-7d583c9a.js';
4
+ import { O as OperationMap } from './SnkMessageBuilder-47db5d75.js';
5
5
 
6
6
  const snkDataUnitCss = ".sc-snk-data-unit-h{display:flex;flex-direction:column;height:100%}";
7
7
 
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h, H as Host, g as getElement } from './index-e4121713.js';
1
+ import { r as registerInstance, h, H as Host, g as getElement } from './index-a77b6f35.js';
2
2
  import { ElementIDUtils } from '@sankhyalabs/core';
3
3
  import { F as FilterItemType } from './filter-item-type.enum-a79b2fa8.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-e4121713.js';
1
+ import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-a77b6f35.js';
2
2
  import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
3
3
  import { F as FilterItemType } from './filter-item-type.enum-a79b2fa8.js';
4
4
  import { ElementIDUtils, DataType } from '@sankhyalabs/core';
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h, g as getElement } from './index-e4121713.js';
1
+ import { r as registerInstance, h, g as getElement } from './index-a77b6f35.js';
2
2
  import { ElementIDUtils } from '@sankhyalabs/core';
3
3
  import { F as FilterItemType } from './filter-item-type.enum-a79b2fa8.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h, g as getElement } from './index-e4121713.js';
1
+ import { r as registerInstance, h, g as getElement } from './index-a77b6f35.js';
2
2
  import { ElementIDUtils } from '@sankhyalabs/core';
3
3
  import { F as FilterItemType } from './filter-item-type.enum-a79b2fa8.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h, g as getElement } from './index-e4121713.js';
1
+ import { r as registerInstance, h, g as getElement } from './index-a77b6f35.js';
2
2
  import { ElementIDUtils } from '@sankhyalabs/core';
3
3
  import { F as FilterItemType } from './filter-item-type.enum-a79b2fa8.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h, H as Host, g as getElement } from './index-e4121713.js';
1
+ import { r as registerInstance, h, H as Host, g as getElement } from './index-a77b6f35.js';
2
2
  import { ElementIDUtils, UserInterface, ApplicationContext } from '@sankhyalabs/core';
3
3
  import { convertType } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
4
4
  import { CheckMode } from '@sankhyalabs/ezui/dist/collection/utils';
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h, g as getElement } from './index-e4121713.js';
1
+ import { r as registerInstance, h, g as getElement } from './index-a77b6f35.js';
2
2
  import { ElementIDUtils, ApplicationContext } from '@sankhyalabs/core';
3
3
  import { F as FilterItemType } from './filter-item-type.enum-a79b2fa8.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h, g as getElement } from './index-e4121713.js';
1
+ import { r as registerInstance, h, g as getElement } from './index-a77b6f35.js';
2
2
  import { ElementIDUtils } from '@sankhyalabs/core';
3
3
 
4
4
  const SnkFilterText = class {
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-e4121713.js';
1
+ import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-a77b6f35.js';
2
2
  import { d as draggable_bundle } from './draggable.bundle-41d56f06.js';
3
3
  import { ObjectUtils, ElementIDUtils, ArrayUtils, ApplicationContext } from '@sankhyalabs/core';
4
4
  import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, c as createEvent, h, g as getElement } from './index-e4121713.js';
1
+ import { r as registerInstance, c as createEvent, h, g as getElement } from './index-a77b6f35.js';
2
2
  import { DateUtils, ObjectUtils, ElementIDUtils, ApplicationContext } from '@sankhyalabs/core';
3
3
  import { T as TaskbarProcessor } from './taskbar-processor-c2a99aba.js';
4
4
  import { C as ConfigStorage } from './ConfigStorage-b59461d8.js';
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h, H as Host, g as getElement } from './index-e4121713.js';
1
+ import { r as registerInstance, h, H as Host, g as getElement } from './index-a77b6f35.js';
2
2
  import { ObjectUtils, StringUtils, ElementIDUtils } from '@sankhyalabs/core';
3
3
 
4
4
  const snkPesquisaCss = ".sc-snk-pesquisa-h{--snk-pesquisa--font-size:var(--text--medium, 14px);--snk-pesquisa--font-family:var(--font-pattern, Arial);--snk-pesquisa--font-weight:var(--text-weight--medium, 400);--snk-pesquisa__records--color:var(--text--primary, #626e82);--snk-pesquisa__records--padding-vertical:var(--space--medium, 12px);--snk-pesquisa__content--padding-right:var(--space--small, 6px);--snk-pesquisa__btn--color:var(--title--primary, #2B3A54);--snk-pesquisa__btn-disabled--color:var(--text--disable, #AFB6C0);--snk-pesquisa__btn-hover--color:var(--color--primary, #4e4e4e);--snk-pesquisa__scrollbar--color-default:var(--scrollbar--default, #626e82);--snk-pesquisa__scrollbar--color-background:var(--scrollbar--background, #E5EAF0);--snk-pesquisa__scrollbar--color-hover:var(--scrollbar--hover, #2B3A54);--snk-pesquisa__scrollbar--color-clicked:var(--scrollbar--clicked, #a2abb9);--snk-pesquisa__scrollbar--border-radius:var(--border--radius-small, 6px);--snk-pesquisa__scrollbar--width:var(--space--medium, 12px);max-height:100%;height:100%;display:flex;flex-direction:column;overflow-y:auto}.snk-pesquisa.sc-snk-pesquisa{display:flex;flex-direction:column;height:100%}.snk-pesquisa__input.sc-snk-pesquisa{display:flex;width:100%;box-sizing:border-box;padding-top:4px;padding-right:4px}.snk-pesquisa__input.sc-snk-pesquisa ez-icon.sc-snk-pesquisa{--ez-icon--color:inherit;font-weight:var(--text-weight--large, 600)}.snk-pesquisa__content.sc-snk-pesquisa{display:flex;flex-direction:column;height:100%;overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--snk-pesquisa__scrollbar--color-clicked) var(--snk-pesquisa__scrollbar--color-background);padding-right:var(--snk-pesquisa__content--padding-right)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar{background-color:var(--snk-pesquisa__scrollbar--color-background);width:var(--snk-pesquisa__scrollbar--width);max-width:var(--snk-pesquisa__scrollbar--width);min-width:var(--snk-pesquisa__scrollbar--width)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-track{background-color:var(--snk-pesquisa__scrollbar--color-background);border-radius:var(--snk-pesquisa__scrollbar--border-radius)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-thumb{background-color:var(--snk-pesquisa__scrollbar--color-default);border-radius:var(--snk-pesquisa__scrollbar--border-radius)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-thumb:vertical:hover,.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-thumb:horizontal:hover{background-color:var(--snk-pesquisa__scrollbar--color-hover)}.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-thumb:vertical:active,.snk-pesquisa__content.sc-snk-pesquisa::-webkit-scrollbar-thumb:horizontal:active{background-color:var(--snk-pesquisa__scrollbar--color-clicked)}.snk-pesquisa__records.sc-snk-pesquisa{font-family:var(--snk-pesquisa--font-family);font-weight:var(--snk-pesquisa--font-weight);font-size:var(--snk-pesquisa--font-size);color:var(--snk-pesquisa__records--color);padding-bottom:var(--snk-pesquisa__records--padding-vertical);padding-top:var(--snk-pesquisa__records--padding-vertical)}.snk-pesquisa__btn.sc-snk-pesquisa{outline:none;border:none;background:none;cursor:pointer;color:var(--snk-pesquisa__btn--color)}.snk-pesquisa__btn.sc-snk-pesquisa:disabled{cursor:unset;color:var(--snk-pesquisa__btn-disabled--color)}.snk-pesquisa__btn.sc-snk-pesquisa:disabled:hover{cursor:unset;color:var(--snk-pesquisa__btn-disabled--color)}.snk-pesquisa__btn.sc-snk-pesquisa:hover{color:var(--snk-pesquisa__btn-hover--color)}";
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, c as createEvent, h, F as Fragment, H as Host, g as getElement } from './index-e4121713.js';
1
+ import { r as registerInstance, c as createEvent, h, F as Fragment, H as Host, g as getElement } from './index-a77b6f35.js';
2
2
  import { d as draggable_bundle } from './draggable.bundle-41d56f06.js';
3
3
  import { ApplicationContext, ElementIDUtils } from '@sankhyalabs/core';
4
4
  import { C as CONFIG_EVENTS, K as KEY_EVENTS, b as TYPE_ACTIONS, T as TAB_NAMES } from './constants-babe1a08.js';
@@ -1,4 +1,5 @@
1
- import { h } from './index-e4121713.js';
1
+ import { h } from './index-a77b6f35.js';
2
+ import { s as store } from './index-d89e384f.js';
2
3
 
3
4
  var TaskbarElement;
4
5
  (function (TaskbarElement) {
@@ -16,7 +17,7 @@ var TaskbarElement;
16
17
  TaskbarElement["MORE_OPTIONS"] = "MORE_OPTIONS";
17
18
  TaskbarElement["DIVIDER"] = "DIVIDER";
18
19
  TaskbarElement["CONFIGURATOR"] = "CONFIGURATOR";
19
- TaskbarElement["EXPORT"] = "EXPORT";
20
+ TaskbarElement["DATA_EXPORTER"] = "DATA_EXPORTER";
20
21
  })(TaskbarElement || (TaskbarElement = {}));
21
22
  var AuthorizationElements;
22
23
  (function (AuthorizationElements) {
@@ -44,7 +45,8 @@ const buildCustomButton = (def, className, dataElementId, action, isEnabled) =>
44
45
  return textButton(def.name, className, dataElementId, text, hint, action, isEnabled);
45
46
  }
46
47
  };
47
- const buildElem = (element, className, dataElementId, getTitle, action, isEnabled, actions) => {
48
+ const buildElem = (element, className, dataElementId, getTitle, action, isEnabled, actions, configName) => {
49
+ var _a;
48
50
  const title = getTitle(element);
49
51
  switch (element) {
50
52
  case TaskbarElement.PREVIOUS:
@@ -71,12 +73,13 @@ const buildElem = (element, className, dataElementId, getTitle, action, isEnable
71
73
  return iconButton("list", element, className, dataElementId, title, action, isEnabled);
72
74
  case TaskbarElement.CONFIGURATOR:
73
75
  return iconButton("settings-inverted", element, className, dataElementId, title, action, isEnabled);
74
- case TaskbarElement.EXPORT:
75
- return iconButton("file-download", element, className, dataElementId, title, action, isEnabled);
76
76
  case TaskbarElement.MORE_OPTIONS:
77
77
  return actionButton(element, className, dataElementId, title, action, isEnabled, actions);
78
78
  case TaskbarElement.DIVIDER:
79
79
  return h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-horizontal--medium", "data-taskbar-divider": true });
80
+ case TaskbarElement.DATA_EXPORTER:
81
+ const provider = (_a = store.get("exporterProviders")) === null || _a === void 0 ? void 0 : _a[configName];
82
+ return h("snk-data-exporter", { class: className, title: title, provider: provider, "data-element-id": dataElementId });
80
83
  }
81
84
  };
82
85
  function textButton(name, className, dataElementId, text, title, action, isEnabled) {
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h } from './index-e4121713.js';
1
+ import { r as registerInstance, h } from './index-a77b6f35.js';
2
2
  import { DataUnit, DataType, UserInterface } from '@sankhyalabs/core';
3
3
 
4
4
  const testePesquisaCss = ":host{display:block}";
@@ -1,9 +1,9 @@
1
- import{r as t,c as e,h as s,g as i}from"./p-9ba3df4c.js";import{WaitingChangeException as r,WarningException as n,ErrorException as a,ObjectUtils as o,DataType as c,DataUnit as h,StringUtils as u,ChangeOperation as l,DateUtils as d,DependencyType as p,ElementIDUtils as m,ApplicationContext as f,ErrorTracking as y}from"@sankhyalabs/core";import{d as g,D as v,R as w,U as I,F as _,G as P,C as $}from"./p-395b45a7.js";import{ApplicationUtils as D}from"@sankhyalabs/ezui/dist/collection/utils";import{S}from"./p-e7f772ed.js";import"./p-112455b1.js";class C{constructor(t){this._app=t,window.addEventListener("error",(t=>this.errorHandler(t))),window.addEventListener("unhandledrejection",(t=>this.rejectionHandler(t)))}rejectionHandler(t){const e=t.reason;e instanceof r||(e?this.processException(e):this._app.isDebugMode().then((t=>{t&&this._app.error("Promise rejeitada","Erro interno: Uma promise foi rejeitada sem razão determinada.")})))}errorHandler(t){this.processException(t.error)}buildErrorCodeHTML(t){return'<br><a href="#" onclick="try{window.workspace.openHelp(\'_tbcode:'+t.errorCode+"')} catch(e){alert('Não é possível abrir a ajuda fora do workspace Sankhya');}\">Código: "+t.errorCode+"</a>"}processException(t){t.errorCode&&(t.message+=this.buildErrorCodeHTML(t)),t instanceof r||t instanceof n?this._app.alert(t.title,t.message):t instanceof a?this._app.error(t.title,t.message):this._app.isDebugMode().then((e=>{if(e)if(t instanceof Error)this._app.error(t.name,t.message);else{const e=(null==t?void 0:t.title)||"Erro detectado",s="string"==typeof t?t:t.message||`Erro interno "${o.objectToString(t)}"`;this._app.error(e,s)}}))}}class A{constructor(){this._defaultPageSize=100,this._templateByQuery=new Map,this.buldTemplates()}buldTemplates(){this._templateByQuery.set("search",g.gql`query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
1
+ import{r as t,c as e,h as s,g as i}from"./p-a77dd79a.js";import{WaitingChangeException as r,WarningException as n,ErrorException as a,ObjectUtils as o,DataType as c,DataUnit as h,StringUtils as u,ChangeOperation as l,DateUtils as d,DependencyType as p,ElementIDUtils as m,ApplicationContext as f,ErrorTracking as y}from"@sankhyalabs/core";import{d as g,D as v,R as w,U as I,F as _,G as P,C as $}from"./p-395b45a7.js";import{ApplicationUtils as D}from"@sankhyalabs/ezui/dist/collection/utils";import{S}from"./p-1d7a0daf.js";import"./p-112455b1.js";class C{constructor(t){this._app=t,window.addEventListener("error",(t=>this.errorHandler(t))),window.addEventListener("unhandledrejection",(t=>this.rejectionHandler(t)))}rejectionHandler(t){const e=t.reason;e instanceof r||(e?this.processException(e):this._app.isDebugMode().then((t=>{t&&this._app.error("Promise rejeitada","Erro interno: Uma promise foi rejeitada sem razão determinada.")})))}errorHandler(t){this.processException(t.error)}buildErrorCodeHTML(t){return'<br><a href="#" onclick="try{window.workspace.openHelp(\'_tbcode:'+t.errorCode+"')} catch(e){alert('Não é possível abrir a ajuda fora do workspace Sankhya');}\">Código: "+t.errorCode+"</a>"}processException(t){t.errorCode&&(t.message+=this.buildErrorCodeHTML(t)),t instanceof r||t instanceof n?this._app.alert(t.title,t.message):t instanceof a?this._app.error(t.title,t.message):this._app.isDebugMode().then((e=>{if(e)if(t instanceof Error)this._app.error(t.name,t.message);else{const e=(null==t?void 0:t.title)||"Erro detectado",s="string"==typeof t?t:t.message||`Erro interno "${o.objectToString(t)}"`;this._app.error(e,s)}}))}}class A{constructor(){this._defaultPageSize=100,this._templateByQuery=new Map,this.buldTemplates()}buldTemplates(){this._templateByQuery.set("search",g.gql`query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
2
2
  $queryAlias$: search(entityName: $entityName argument: $argument criteria: $criteria options: $options){
3
3
  value
4
4
  label
5
5
  }
6
- }`)}loadSearchOptions(t,e,s,i){const r=(null==e?void 0:e.trim())||void 0;return e=isNaN(Number(r))&&r?`%${r}`:r,new Promise(((r,n)=>{v.get().callGraphQL({values:{argument:e,entityName:t,criteria:s,options:i},query:this._templateByQuery.get("search")}).then((t=>{r(t)})).catch((t=>{n(t)}))}))}loadAdvancedSearch(t,e,s,i){const r={query:{$:null==s?void 0:s.expression}};(null==s?void 0:s.params.length)>0&&(r.params={param:s.params.map((t=>{let e=t.value,s=t.dataType;return s===c.OBJECT?(e=e.value,s="S"):s=function(t){switch(t){case c.NUMBER:return"I";case c.DATE:return"D";default:return"S"}}(t.dataType),{$:e,type:s}}))});const n={serviceName:"PesquisaSP.getSuggestion",requestBody:{criteria:{entityName:t,compacted:!1,ignoreEntityCriteria:!1,limit:this._defaultPageSize,query:{$:e},orderByDesc:!1,externalCriteria:r,localEntityName:null==i?void 0:i.rootEntity},clientEventList:{clientEvent:[]}}};return new Promise(((t,e)=>{v.get().callServiceBroker("PesquisaSP.getSuggestion",JSON.stringify(n)).then((e=>t(e))).catch((t=>e(t)))}))}}function T(){const t=["2909523kXwted","CompanyName=Sankhya Jiva Tecnologia e Inovao Ltda,LicensedApplication=Sankhya Gestao,LicenseType=SingleApplication,LicensedConcurrentDeveloperCount=2,LicensedProductionInstancesCount=0,AssetReference=AG-019460,ExpiryDate=9_November_2022_[v2]_MTY2Nzk1MjAwMDAwMA==10487151e296ee4360f80961ca960869","1131048CARoeW","502909mLEPmu","447255iQEXuN","428UHbJwW","270AFTxAV","194369jhGqTI","1540nWuTrj","2044062GicUQI","30CkXPWg"];return(T=function(){return t})()}const N=E;function E(t,e){const s=T();return(E=function(t){return s[t-=392]})(t,e)}!function(){const t=E,e=T();for(;;)try{if(951926==-parseInt(t(398))/1+-parseInt(t(393))/2+parseInt(t(395))/3+-parseInt(t(400))/4*(parseInt(t(392))/5)+-parseInt(t(401))/6*(-parseInt(t(402))/7)+parseInt(t(397))/8+-parseInt(t(399))/9*(-parseInt(t(394))/10))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const b=N(396);class q{constructor(){this.templateByQuery=new Map,this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchTotals",g.gql`query($filters: [InputFilter!] $name: String!) {
6
+ }`)}loadSearchOptions(t,e,s,i){const r=(null==e?void 0:e.trim())||void 0;return e=isNaN(Number(r))&&r?`%${r}`:r,new Promise(((r,n)=>{v.get().callGraphQL({values:{argument:e,entityName:t,criteria:s,options:i},query:this._templateByQuery.get("search")}).then((t=>{r(t)})).catch((t=>{n(t)}))}))}loadAdvancedSearch(t,e,s,i){const r={query:{$:null==s?void 0:s.expression}};(null==s?void 0:s.params.length)>0&&(r.params={param:s.params.map((t=>{let e=t.value,s=t.dataType;return s===c.OBJECT?(e=e.value,s="S"):s=function(t){switch(t){case c.NUMBER:return"I";case c.DATE:return"D";default:return"S"}}(t.dataType),{$:e,type:s}}))});const n={serviceName:"PesquisaSP.getSuggestion",requestBody:{criteria:{entityName:t,compacted:!1,ignoreEntityCriteria:!1,limit:this._defaultPageSize,query:{$:e},orderByDesc:!1,externalCriteria:r,localEntityName:null==i?void 0:i.rootEntity},clientEventList:{clientEvent:[]}}};return new Promise(((t,e)=>{v.get().callServiceBroker("PesquisaSP.getSuggestion",JSON.stringify(n)).then((e=>t(e))).catch((t=>e(t)))}))}}function T(){const t=["2909523kXwted","CompanyName=Sankhya Jiva Tecnologia e Inovao Ltda,LicensedApplication=Sankhya Gestao,LicenseType=SingleApplication,LicensedConcurrentDeveloperCount=2,LicensedProductionInstancesCount=0,AssetReference=AG-019460,ExpiryDate=9_November_2022_[v2]_MTY2Nzk1MjAwMDAwMA==10487151e296ee4360f80961ca960869","1131048CARoeW","502909mLEPmu","447255iQEXuN","428UHbJwW","270AFTxAV","194369jhGqTI","1540nWuTrj","2044062GicUQI","30CkXPWg"];return(T=function(){return t})()}const N=E;function E(t,e){const s=T();return(E=function(t){return s[t-=392]})(t,e)}!function(){const t=E,e=T();for(;;)try{if(951926==-parseInt(t(398))/1+-parseInt(t(393))/2+parseInt(t(395))/3+-parseInt(t(400))/4*(parseInt(t(392))/5)+-parseInt(t(401))/6*(-parseInt(t(402))/7)+parseInt(t(397))/8+-parseInt(t(399))/9*(-parseInt(t(394))/10))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const q=N(396);class b{constructor(){this.templateByQuery=new Map,this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchTotals",g.gql`query($filters: [InputFilter!] $name: String!) {
7
7
  $queryAlias$: fetchTotals(name: $name, filters: $filters ){
8
8
  name
9
9
  value
@@ -73,4 +73,4 @@ import{r as t,c as e,h as s,g as i}from"./p-9ba3df4c.js";import{WaitingChangeExc
73
73
  name
74
74
  resource
75
75
  }
76
- }`)}async getParam(t){const e=`param://application?params=${t}`;return v.get().callGraphQL({values:{name:e},query:this.templateByQuery.get("fetchParam")})}async asString(t){const e=await this.getParam(t);return this.getValue(e)}async asInteger(t){const e=await this.getParam(t);return parseInt(this.getValue(e))}async asFloat(t){const e=await this.getParam(t);return parseFloat(this.getValue(e))}async asBoolean(t){const e=await this.getParam(t);return this.getValue(e).includes('"S"')}async asDate(t){const e=await this.getParam(t);return d.strToDate(this.getValue(e))}async getBatchParams(t){const e=await this.getParam(t.join(",")),s={};return e.forEach((t=>s[t.name]=t.resource)),s}getValue(t={}){return Array.isArray(t)&&t.length>0&&(t=t[0]),u.isEmpty(t.resource)?"":t.resource}}const L=j;function j(t,e){const s=k();return(j=function(t){return s[t-=378]})(t,e)}function k(){const t=["true","863GKWjmo","parse","56355fjjjAm","isSup","putAccess","4324480sjuCdS","hasOwnProperty","239748okvJLB","name","6055770tXeRaU","actions","forEach","7RPRvzn","1042CHxkUw","2988126NIwRMm","20MTNzmH","authorizationSf","item","string","hasAccess","isArray","Objeto não pode ser indefinido.","3071943fWslZp","parseFromJSON"];return(k=function(){return t})()}!function(){const t=j,e=k();for(;;)try{if(281287==parseInt(t(399))/1*(-parseInt(t(387))/2)+-parseInt(t(401))/3+parseInt(t(381))/4*(-parseInt(t(389))/5)+parseInt(t(388))/6*(-parseInt(t(386))/7)+parseInt(t(379))/8+parseInt(t(396))/9+parseInt(t(383))/10)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class M{[L(397)](t){const e=L;if(typeof(t=utxt(t[e(390)]))==e(392)&&(t=JSON[e(400)](t)),null==t)throw Error(e(395));const s=new x("S"===t[e(402)]||!0===t[e(402)]);return Array[e(394)](t[e(391)])&&t[e(391)][e(385)]((t=>s.putAccess(t[e(382)],String(t.status)==e(398)))),s}}class x{constructor(t){const e=L;this.isSup=t,this[e(384)]={}}[L(378)](t,e){this[L(384)][t]=e}[L(393)](t){const e=L;if(this[e(402)])return!0;let s=!0;return this[e(384)][e(380)](t)&&(s=this.actions[t]),s}isUserSup(){return this.isSup}}class B extends w{getData(t){const e=`cfg://auth/${t}`;return new Promise(((t,s)=>{this.loadResource(e).then((e=>{let s=o.stringToObject(e);s&&"object"==typeof s&&t(s)})).catch((t=>{s(t)}))}))}}var z;function G(t){if(null==t)return t;if(t instanceof Date)return t.toISOString();if("object"==typeof t){if(t instanceof Array)return t.map((t=>G(t)));{const e=Object.assign({},t);return Object.keys(t).forEach((s=>{t[s]?e[s]=G(t[s]):delete e[s]})),e}}return t}!function(t){t.INSERT="I",t.UPDATE="A",t.REMOVE="E",t.SHOW="C",t.CONFIG="F",t.CONFIG_NUMBER="N",t.CLONE="D",t.CONFIG_GRID="G"}(z||(z={}));class J extends w{saveConfig(t,e,s){const i=t.map((t=>{const{id:e,value:s,fixed:i,visible:r}=t,n={id:e};return s&&(n.value=G(s)),i&&(n.fixed=i),r&&(n.visible=!0),n}));return this.saveResource(i,`cfg://filter/FilterBarState:${e}/${s}`)}getConfig(t,e){return new Promise(((s,i)=>{this.loadResource(`cfg://filter/FilterBarState:${t}/${e}`).then((t=>{let e;t&&(e=JSON.parse(t).items),s(e||[])})).catch((t=>{i(t)}))}))}}class H extends w{getDefaultValues(t){return new Promise(((e,s)=>{this.loadResource(`cfg://defaultValues/${t}`).then((t=>{let s;t&&(s=JSON.parse(t)),e(s)})).catch((t=>{s(t)}))}))}}const V=class{constructor(s){t(this,s),this.applicationLoaded=e(this,"applicationLoaded",7),this.applicationLoading=e(this,"applicationLoading",7),this._authPromises=[],this._duCache=new Map,this._duPromises=new Map,this._requestListener=new W}get parameters(){return this._parameters||(this._parameters=new R),this._parameters}get resourceID(){return this._resourceID||(this._resourceID=this.urlParams.get("workspaceResourceID")||this.urlParams.get("resourceID")||F.resourceID||"unknown.resource.id"),this._resourceID}get auth(){return this._auth?Promise.resolve(this._auth):new Promise(((t,e)=>{const s=this._authPromises.length>0;this._authPromises.push(new Z(t,e)),s||this.authFetcher.getData(this.resourceID).then((t=>{for(this._auth=t;this._authPromises.length>0;)this._authPromises.pop().resolve(this._auth)})).catch((t=>{for(;this._authPromises.length>0;)this._authPromises.pop().reject(t)}))}))}async isUserSup(){return new Promise(((t,e)=>{this.auth.then((s=>{this.getAuthList(s).then((e=>{t(e.isSup)})).catch((t=>e(t)))}))}))}async hasAccess(t){return new Promise(((e,s)=>{this.auth.then((i=>{this.getAuthList(i).then((s=>{e(s.isSup||s.actions[t])})).catch((t=>s(t)))}))}))}async getAllAccess(){return new Promise(((t,e)=>{this.auth.then((s=>{this.getAuthList(s).then((e=>{const s={};s.isSup=e.isSup,Object.entries(z).forEach((t=>{s[t[0]]=e.actions[t[1]]||!1})),t(s)})).catch((t=>e(t)))}))}))}async getStringParam(t){return this.parameters.asString(t)}async getIntParam(t){return this.parameters.asInteger(t)}async getFloatParam(t){return this.parameters.asFloat(t)}async getBooleanParam(t){return this.parameters.asBoolean(t)}async getDateParam(t){return this.parameters.asDate(t)}async showPopUp(t,e="full",s=!0){this.clearContent(this._popUp),this._popUp.appendChild(t),this._popUp.opened=!0,this._popUp.heightMode=e,this._popUp.useHeader=s,"EZ-MODAL-CONTAINER"===t.tagName&&(this._popUp.useHeader=!1)}async showModal(t){this.clearContent(this._rightModal),this._rightModal.appendChild(t),this._rightModal.opened=!0}async closeModal(){this.clearContent(this._rightModal),this._rightModal.opened=!1}async closePopUp(){this.clearContent(this._popUp),this._popUp.opened=!1,this._popUp.useHeader=!0,this._popUp.heightMode="full"}async temOpcional(t){const e=t.split(",");return new Promise(((t,s)=>{this.getAttributeFromHTMLWrapper("opc0009").then((i=>{"1"===i?t(!0):Promise.all(e.map((t=>this.getAttributeFromHTMLWrapper("opc"+t)))).then((e=>{t(e.includes("1"))})).catch((t=>{s(t)}))})).catch((t=>{s(t)}))}))}async getConfig(t){let e={serviceName:"SystemUtilsSP.getConf",requestBody:{config:{chave:t,tipo:"T"}}};return new Promise(((t,s)=>{v.get().callServiceBroker("SystemUtilsSP.getConf",JSON.stringify(e)).then((e=>{var s;return t(null===(s=e.config)||void 0===s?void 0:s.data)})).catch((t=>s(t)))}))}async saveConfig(t,e){let s={serviceName:"SystemUtilsSP.saveConf",requestBody:{config:{chave:t,tipo:"T",data:e}}};return new Promise(((t,e)=>{v.get().callServiceBroker("SystemUtilsSP.saveConf",JSON.stringify(s)).then((e=>t(e))).catch((t=>e(t)))}))}async getAttributeFromHTMLWrapper(t){return Promise.resolve(window[t])}async openApp(t,e){F.openAppActivity(t,e)}getDuPromissesStack(t){let e;return t&&(e=this._duPromises.get(t),e||(e=[],this._duPromises.set(t,e))),e||[]}async createDataunit(t,e){return new Promise(((s,i)=>{const r=this.getDuPromissesStack(e),n=r.length>0;if(r.push(new Z(s,i)),!n){const s=this.dataUnitFetcher.getDataUnit(t,this.resourceID);s.loadMetadata().then((()=>{for(e&&this._duCache.set(e,s);r.length>0;)r.pop().resolve(s)})).catch((t=>{for(;r.length>0;)r.pop().reject(t)}))}}))}async getDataUnit(t,e){return new Promise(((s,i)=>{const r=this._duCache.get(e);r?s(r):this.createDataunit(t,e).then((t=>{s(t)})).catch((t=>i(t)))}))}async getResourceID(){return Promise.resolve(this.resourceID)}async getUserID(){return Promise.resolve(window.UID)}async alert(t,e,s,i){return D.alert(t,e,s,i)}async error(t,e,s,i){return D.error(t,e,s,i)}async success(t,e,s,i){return D.success(t,e,s,i)}async message(t,e,s,i){return D.message(t,e,s,i)}async confirm(t,e,s,i,r){return D.confirm(t,e,s,i,r)}async info(t,e){return D.info(t,e)}async loadFormConfig(t){return this.formConfigFetcher.loadFormConfig(t,this.resourceID)}async loadGridConfig(t){return this.gridConfigFetcher.getConfig(t,this.resourceID)}async fetchUserAvailableConfigs(t){return this.formConfigFetcher.fetchUserAvailableConfigs(t,this.resourceID)}async fetchLegacyConfig(t){return this.formConfigFetcher.fetchLegacyConfig(t,this.resourceID)}async fetchDefaultConfig(t){return this.formConfigFetcher.fetchDefaultConfig(t,this.resourceID)}async loadTotals(t,e,s){return this.totalsFetcher.fetchTotals(t,e,s)}async saveGridConfig(t){return this.gridConfigFetcher.saveConfig(t,this.resourceID)}async getFilterBarConfig(t){return new Promise(((e,s)=>{this.configName===t&&this._filterBarConfig?e(this._filterBarConfig):this.configName===t&&null!=this._filterConfigPromise?Promise.all([this._filterConfigPromise]).then((t=>e(t[0]))).catch((t=>s(t[0]))):this.filterBarConfigFetcher.getConfig(this.resourceID,t).then((t=>e(t))).catch((t=>s(t)))}))}async saveFilterBarConfig(t,e){return this.filterBarConfigFetcher.saveConfig(t,this.resourceID,e)}async saveFormConfig(t,e){return this.formConfigFetcher.saveConfig(t,e,this.resourceID)}async getDefaultValues(){return this.defaultValuesFetcher.getDefaultValues(this.resourceID)}async getDefaultValue(t){return this._defaultValues&&this._defaultValues[t]}async getAuthList(t){return await(new M).parseFromJSON(t)}get urlParams(){return this._urlParams||(this._urlParams=I.getQueryParams(location.search)),this._urlParams}get dataUnitFetcher(){return this._dataUnitFetcher||(this._dataUnitFetcher=new U),this._dataUnitFetcher}get formConfigFetcher(){return this._formConfigFetcher||(this._formConfigFetcher=new _),this._formConfigFetcher}get gridConfigFetcher(){return this._gridConfigFetcher||(this._gridConfigFetcher=new P),this._gridConfigFetcher}get totalsFetcher(){return this._totalsFetcher||(this._totalsFetcher=new q),this._totalsFetcher}get pesquisaFetcher(){return this._pesquisaFetcher||(this._pesquisaFetcher=new A),this._pesquisaFetcher}get authFetcher(){return this._authFetcher||(this._authFetcher=new B),this._authFetcher}get filterBarConfigFetcher(){return this._filterBarConfigFetcher||(this._filterBarConfigFetcher=new J),this._filterBarConfigFetcher}get defaultValuesFetcher(){return this._defaultValuesFetcher||(this._defaultValuesFetcher=new H),this._defaultValuesFetcher}async executeSearch(t,e,s){const i=null==s?void 0:s.getField(e);if(i){const{mode:e,argument:r}=t,{ENTITYNAME:n,CODEFIELD:a,DESCRIPTIONFIELD:o,ROOTENTITY:h,DESCRIPTIONENTITY:u}=i.properties,l=i.dependencies;let d;const m={rootEntity:h,descriptionFieldName:o,codeFieldName:a,showInactives:!1};return null==l||l.filter((t=>{var e;return null===(e=t.masterFields)||void 0===e?void 0:e.every((t=>{var e;return null===(e=s.getField(t))||void 0===e?void 0:e.visible}))})).forEach((t=>{var e;t.type===p.SEARCHING&&(null===(e=t.masterFields)||void 0===e?void 0:e.length)>0&&(d={expression:t.expression,params:t.masterFields.map((t=>{const e=s.getField(t),i=(null==e?void 0:e.dataType)||c.TEXT,r=s.getFieldValue(t);if(null==r)throw this.alert("Erro ao pesquisar",`É necessario informar o campo ${e.label} para executar a pesquisa.`),new Error(`É necessario informar o campo ${e.label} para executar a pesquisa.`);return{name:t,value:r,dataType:i}}))})})),this.executePreparedSearch(e,r,{entity:n,entityDescription:u,criteria:d,searchOptions:m})}}async executePreparedSearch(t,e,s){const{entity:i,entityDescription:r,criteria:n,searchOptions:a}=s;return"ADVANCED"===t?new Promise((t=>{const s=document.createElement("snk-pesquisa");s[m.DATA_ELEMENT_ID_ATTRIBUTE_NAME]=`entity_${i}`,s.argument=e,s.searchLoader=t=>this.pesquisaFetcher.loadAdvancedSearch(i,t,n,a),s.selectItem=e=>{t(e),this.clearPopUpTitle(),this.closePopUp()},this.setPopUpTitle(r),this.showPopUp(s)})):this.pesquisaFetcher.loadSearchOptions(i,e,n,a)}async isDebugMode(){return new Promise((t=>{t(window.isDebugMode)}))}clearContent(t){t&&Array.from(t.children).forEach((e=>{t.removeChild(e)}))}clearPopUpTitle(){this._popUp.ezTitle=""}setPopUpTitle(t){this._popUp.ezTitle=t}componentWillLoad(){this._errorHandler=new C(this),this.messagesBuilder=new S,f.setContextValue("__EZUI__UPLOAD__ADD__URL__",`${I.getUrlBase()}/mge/upload/file`),f.setContextValue("__EZUI__SEARCH__OPTION__LOADER__",((t,e,s)=>this.executeSearch(t,e,s))),f.setContextValue("__EZUI__GRID_LICENSE__",b),this.configName&&(this._filterConfigPromise=new Promise(((t,e)=>{this.filterBarConfigFetcher.getConfig(this.resourceID,this.configName).then((e=>{this._filterBarConfig=e,t(e)})).catch((t=>e(t)))}))),y.init(),$.get(),this.getDefaultValues().then((t=>{this._defaultValues=t}))}connectedCallback(){f.setContextValue("__SNK__APPLICATION__",this),v.addRequestListener(this._requestListener)}disconnectedCallback(){v.removeRequestListener(this._requestListener)}componentDidLoad(){this.applicationLoading.emit(!0),window.requestAnimationFrame((()=>{this.applicationLoaded.emit(!0)})),m.addIDInfo(this._element,`resource_${this._resourceID}`)}render(){return s("div",null,s("ez-loading-bar",{ref:t=>this._requestListener.loadingBar=t}),s("ez-popup",{opened:!1,ref:t=>this._popUp=t,onEzClosePopup:()=>this.closePopUp()}),s("ez-modal",{opened:!1,ref:t=>this._rightModal=t,"modal-size":"small",closeOutsideClick:!0,closeEsc:!0}))}get _element(){return i(this)}};class W{constructor(){this._debounceTime=1e3,this._ignoredNameTypes=["totals"],this._countRequest=0}onRequestStart(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest++,this.loadingBar.show(),this._timerLoading&&clearTimeout(this._timerLoading))}onRequestEnd(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest--,this._timerLoading=setTimeout((()=>{this._countRequest<=0&&this.loadingBar.hide()}),this._debounceTime))}isIgnoreLoadingOnRequest(t){var e;if(1==(null===(e=null==t?void 0:t.requestBody)||void 0===e?void 0:e.length)){const{name:e}=t.requestBody[0].variables;if(e){const t=e.split(":");return this._ignoredNameTypes.indexOf(t[0])>=0}}return!1}}class Z{constructor(t,e){this.resolve=t,this.reject=e}}V.style=".sc-snk-application-h{display:flex;flex-direction:column;height:100%}";export{V as snk_application}
76
+ }`)}async getParam(t){const e=`param://application?params=${t}`;return v.get().callGraphQL({values:{name:e},query:this.templateByQuery.get("fetchParam")})}async asString(t){const e=await this.getParam(t);return this.getValue(e)}async asInteger(t){const e=await this.getParam(t);return parseInt(this.getValue(e))}async asFloat(t){const e=await this.getParam(t);return parseFloat(this.getValue(e))}async asBoolean(t){const e=await this.getParam(t);return this.getValue(e).includes('"S"')}async asDate(t){const e=await this.getParam(t);return d.strToDate(this.getValue(e))}async getBatchParams(t){const e=await this.getParam(t.join(",")),s={};return e.forEach((t=>s[t.name]=t.resource)),s}getValue(t={}){return Array.isArray(t)&&t.length>0&&(t=t[0]),u.isEmpty(t.resource)?"":t.resource}}const L=j;function j(t,e){const s=k();return(j=function(t){return s[t-=378]})(t,e)}function k(){const t=["true","863GKWjmo","parse","56355fjjjAm","isSup","putAccess","4324480sjuCdS","hasOwnProperty","239748okvJLB","name","6055770tXeRaU","actions","forEach","7RPRvzn","1042CHxkUw","2988126NIwRMm","20MTNzmH","authorizationSf","item","string","hasAccess","isArray","Objeto não pode ser indefinido.","3071943fWslZp","parseFromJSON"];return(k=function(){return t})()}!function(){const t=j,e=k();for(;;)try{if(281287==parseInt(t(399))/1*(-parseInt(t(387))/2)+-parseInt(t(401))/3+parseInt(t(381))/4*(-parseInt(t(389))/5)+parseInt(t(388))/6*(-parseInt(t(386))/7)+parseInt(t(379))/8+parseInt(t(396))/9+parseInt(t(383))/10)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class M{[L(397)](t){const e=L;if(typeof(t=utxt(t[e(390)]))==e(392)&&(t=JSON[e(400)](t)),null==t)throw Error(e(395));const s=new x("S"===t[e(402)]||!0===t[e(402)]);return Array[e(394)](t[e(391)])&&t[e(391)][e(385)]((t=>s.putAccess(t[e(382)],String(t.status)==e(398)))),s}}class x{constructor(t){const e=L;this.isSup=t,this[e(384)]={}}[L(378)](t,e){this[L(384)][t]=e}[L(393)](t){const e=L;if(this[e(402)])return!0;let s=!0;return this[e(384)][e(380)](t)&&(s=this.actions[t]),s}isUserSup(){return this.isSup}}class B extends w{getData(t){const e=`cfg://auth/${t}`;return new Promise(((t,s)=>{this.loadResource(e).then((e=>{let s=o.stringToObject(e);s&&"object"==typeof s&&t(s)})).catch((t=>{s(t)}))}))}}var z;function G(t){if(null==t)return t;if(t instanceof Date)return t.toISOString();if("object"==typeof t){if(t instanceof Array)return t.map((t=>G(t)));{const e=Object.assign({},t);return Object.keys(t).forEach((s=>{t[s]?e[s]=G(t[s]):delete e[s]})),e}}return t}!function(t){t.INSERT="I",t.UPDATE="A",t.REMOVE="E",t.SHOW="C",t.CONFIG="F",t.CONFIG_NUMBER="N",t.CLONE="D",t.CONFIG_GRID="G"}(z||(z={}));class J extends w{saveConfig(t,e,s){const i=t.map((t=>{const{id:e,value:s,fixed:i,visible:r}=t,n={id:e};return s&&(n.value=G(s)),i&&(n.fixed=i),r&&(n.visible=!0),n}));return this.saveResource(i,`cfg://filter/FilterBarState:${e}/${s}`)}getConfig(t,e){return new Promise(((s,i)=>{this.loadResource(`cfg://filter/FilterBarState:${t}/${e}`).then((t=>{let e;t&&(e=JSON.parse(t).items),s(e||[])})).catch((t=>{i(t)}))}))}}class H extends w{getDefaultValues(t){return new Promise(((e,s)=>{this.loadResource(`cfg://defaultValues/${t}`).then((t=>{let s;t&&(s=JSON.parse(t)),e(s)})).catch((t=>{s(t)}))}))}}const V=class{constructor(s){t(this,s),this.applicationLoaded=e(this,"applicationLoaded",7),this.applicationLoading=e(this,"applicationLoading",7),this._authPromises=[],this._duCache=new Map,this._duPromises=new Map,this._requestListener=new W}get parameters(){return this._parameters||(this._parameters=new R),this._parameters}get resourceID(){return this._resourceID||(this._resourceID=this.urlParams.get("workspaceResourceID")||this.urlParams.get("resourceID")||F.resourceID||"unknown.resource.id"),this._resourceID}get auth(){return this._auth?Promise.resolve(this._auth):new Promise(((t,e)=>{const s=this._authPromises.length>0;this._authPromises.push(new Z(t,e)),s||this.authFetcher.getData(this.resourceID).then((t=>{for(this._auth=t;this._authPromises.length>0;)this._authPromises.pop().resolve(this._auth)})).catch((t=>{for(;this._authPromises.length>0;)this._authPromises.pop().reject(t)}))}))}async isUserSup(){return new Promise(((t,e)=>{this.auth.then((s=>{this.getAuthList(s).then((e=>{t(e.isSup)})).catch((t=>e(t)))}))}))}async hasAccess(t){return new Promise(((e,s)=>{this.auth.then((i=>{this.getAuthList(i).then((s=>{e(s.isSup||s.actions[t])})).catch((t=>s(t)))}))}))}async getAllAccess(){return new Promise(((t,e)=>{this.auth.then((s=>{this.getAuthList(s).then((e=>{const s={};s.isSup=e.isSup,Object.entries(z).forEach((t=>{s[t[0]]=e.actions[t[1]]||!1})),t(s)})).catch((t=>e(t)))}))}))}async getStringParam(t){return this.parameters.asString(t)}async getIntParam(t){return this.parameters.asInteger(t)}async getFloatParam(t){return this.parameters.asFloat(t)}async getBooleanParam(t){return this.parameters.asBoolean(t)}async getDateParam(t){return this.parameters.asDate(t)}async showPopUp(t,e="full",s=!0){this.clearContent(this._popUp),this._popUp.appendChild(t),this._popUp.opened=!0,this._popUp.heightMode=e,this._popUp.useHeader=s,"EZ-MODAL-CONTAINER"===t.tagName&&(this._popUp.useHeader=!1)}async showModal(t){this.clearContent(this._rightModal),this._rightModal.appendChild(t),this._rightModal.opened=!0}async closeModal(){this.clearContent(this._rightModal),this._rightModal.opened=!1}async closePopUp(){this.clearContent(this._popUp),this._popUp.opened=!1,this._popUp.useHeader=!0,this._popUp.heightMode="full"}async temOpcional(t){const e=t.split(",");return new Promise(((t,s)=>{this.getAttributeFromHTMLWrapper("opc0009").then((i=>{"1"===i?t(!0):Promise.all(e.map((t=>this.getAttributeFromHTMLWrapper("opc"+t)))).then((e=>{t(e.includes("1"))})).catch((t=>{s(t)}))})).catch((t=>{s(t)}))}))}async getConfig(t){let e={serviceName:"SystemUtilsSP.getConf",requestBody:{config:{chave:t,tipo:"T"}}};return new Promise(((t,s)=>{v.get().callServiceBroker("SystemUtilsSP.getConf",JSON.stringify(e)).then((e=>{var s;return t(null===(s=e.config)||void 0===s?void 0:s.data)})).catch((t=>s(t)))}))}async saveConfig(t,e){let s={serviceName:"SystemUtilsSP.saveConf",requestBody:{config:{chave:t,tipo:"T",data:e}}};return new Promise(((t,e)=>{v.get().callServiceBroker("SystemUtilsSP.saveConf",JSON.stringify(s)).then((e=>t(e))).catch((t=>e(t)))}))}async getAttributeFromHTMLWrapper(t){return Promise.resolve(window[t])}async openApp(t,e){F.openAppActivity(t,e)}getDuPromissesStack(t){let e;return t&&(e=this._duPromises.get(t),e||(e=[],this._duPromises.set(t,e))),e||[]}async createDataunit(t,e){return new Promise(((s,i)=>{const r=this.getDuPromissesStack(e),n=r.length>0;if(r.push(new Z(s,i)),!n){const s=this.dataUnitFetcher.getDataUnit(t,this.resourceID);s.loadMetadata().then((()=>{for(e&&this._duCache.set(e,s);r.length>0;)r.pop().resolve(s)})).catch((t=>{for(;r.length>0;)r.pop().reject(t)}))}}))}async getDataUnit(t,e){return new Promise(((s,i)=>{const r=this._duCache.get(e);r?s(r):this.createDataunit(t,e).then((t=>{s(t)})).catch((t=>i(t)))}))}async getResourceID(){return Promise.resolve(this.resourceID)}async getUserID(){return Promise.resolve(window.UID)}async alert(t,e,s,i){return D.alert(t,e,s,i)}async error(t,e,s,i){return D.error(t,e,s,i)}async success(t,e,s,i){return D.success(t,e,s,i)}async message(t,e,s,i){return D.message(t,e,s,i)}async confirm(t,e,s,i,r){return D.confirm(t,e,s,i,r)}async info(t,e){return D.info(t,e)}async loadFormConfig(t){return this.formConfigFetcher.loadFormConfig(t,this.resourceID)}async loadGridConfig(t){return this.gridConfigFetcher.getConfig(t,this.resourceID)}async fetchUserAvailableConfigs(t){return this.formConfigFetcher.fetchUserAvailableConfigs(t,this.resourceID)}async fetchLegacyConfig(t){return this.formConfigFetcher.fetchLegacyConfig(t,this.resourceID)}async fetchDefaultConfig(t){return this.formConfigFetcher.fetchDefaultConfig(t,this.resourceID)}async loadTotals(t,e,s){return this.totalsFetcher.fetchTotals(t,e,s)}async saveGridConfig(t){return this.gridConfigFetcher.saveConfig(t,this.resourceID)}async getFilterBarConfig(t){return new Promise(((e,s)=>{this.configName===t&&this._filterBarConfig?e(this._filterBarConfig):this.configName===t&&null!=this._filterConfigPromise?Promise.all([this._filterConfigPromise]).then((t=>e(t[0]))).catch((t=>s(t[0]))):this.filterBarConfigFetcher.getConfig(this.resourceID,t).then((t=>e(t))).catch((t=>s(t)))}))}async saveFilterBarConfig(t,e){return this.filterBarConfigFetcher.saveConfig(t,this.resourceID,e)}async saveFormConfig(t,e){return this.formConfigFetcher.saveConfig(t,e,this.resourceID)}async getDefaultValues(){return this.defaultValuesFetcher.getDefaultValues(this.resourceID)}async getDefaultValue(t){return this._defaultValues&&this._defaultValues[t]}async getAuthList(t){return await(new M).parseFromJSON(t)}get urlParams(){return this._urlParams||(this._urlParams=I.getQueryParams(location.search)),this._urlParams}get dataUnitFetcher(){return this._dataUnitFetcher||(this._dataUnitFetcher=new U),this._dataUnitFetcher}get formConfigFetcher(){return this._formConfigFetcher||(this._formConfigFetcher=new _),this._formConfigFetcher}get gridConfigFetcher(){return this._gridConfigFetcher||(this._gridConfigFetcher=new P),this._gridConfigFetcher}get totalsFetcher(){return this._totalsFetcher||(this._totalsFetcher=new b),this._totalsFetcher}get pesquisaFetcher(){return this._pesquisaFetcher||(this._pesquisaFetcher=new A),this._pesquisaFetcher}get authFetcher(){return this._authFetcher||(this._authFetcher=new B),this._authFetcher}get filterBarConfigFetcher(){return this._filterBarConfigFetcher||(this._filterBarConfigFetcher=new J),this._filterBarConfigFetcher}get defaultValuesFetcher(){return this._defaultValuesFetcher||(this._defaultValuesFetcher=new H),this._defaultValuesFetcher}async executeSearch(t,e,s){const i=null==s?void 0:s.getField(e);if(i){const{mode:e,argument:r}=t,{ENTITYNAME:n,CODEFIELD:a,DESCRIPTIONFIELD:o,ROOTENTITY:h,DESCRIPTIONENTITY:u}=i.properties,l=i.dependencies;let d;const m={rootEntity:h,descriptionFieldName:o,codeFieldName:a,showInactives:!1};return null==l||l.filter((t=>{var e;return null===(e=t.masterFields)||void 0===e?void 0:e.every((t=>{var e;return null===(e=s.getField(t))||void 0===e?void 0:e.visible}))})).forEach((t=>{var e;t.type===p.SEARCHING&&(null===(e=t.masterFields)||void 0===e?void 0:e.length)>0&&(d={expression:t.expression,params:t.masterFields.map((t=>{const e=s.getField(t),i=(null==e?void 0:e.dataType)||c.TEXT,r=s.getFieldValue(t);if(null==r)throw this.alert("Erro ao pesquisar",`É necessario informar o campo ${e.label} para executar a pesquisa.`),new Error(`É necessario informar o campo ${e.label} para executar a pesquisa.`);return{name:t,value:r,dataType:i}}))})})),this.executePreparedSearch(e,r,{entity:n,entityDescription:u,criteria:d,searchOptions:m})}}async executePreparedSearch(t,e,s){const{entity:i,entityDescription:r,criteria:n,searchOptions:a}=s;return"ADVANCED"===t?new Promise((t=>{const s=document.createElement("snk-pesquisa");s[m.DATA_ELEMENT_ID_ATTRIBUTE_NAME]=`entity_${i}`,s.argument=e,s.searchLoader=t=>this.pesquisaFetcher.loadAdvancedSearch(i,t,n,a),s.selectItem=e=>{t(e),this.clearPopUpTitle(),this.closePopUp()},this.setPopUpTitle(r),this.showPopUp(s)})):this.pesquisaFetcher.loadSearchOptions(i,e,n,a)}async isDebugMode(){return new Promise((t=>{t(window.isDebugMode)}))}clearContent(t){t&&Array.from(t.children).forEach((e=>{t.removeChild(e)}))}clearPopUpTitle(){this._popUp.ezTitle=""}setPopUpTitle(t){this._popUp.ezTitle=t}componentWillLoad(){this._errorHandler=new C(this),this.messagesBuilder=new S,f.setContextValue("__EZUI__UPLOAD__ADD__URL__",`${I.getUrlBase()}/mge/upload/file`),f.setContextValue("__EZUI__SEARCH__OPTION__LOADER__",((t,e,s)=>this.executeSearch(t,e,s))),f.setContextValue("__EZUI__GRID_LICENSE__",q),this.configName&&(this._filterConfigPromise=new Promise(((t,e)=>{this.filterBarConfigFetcher.getConfig(this.resourceID,this.configName).then((e=>{this._filterBarConfig=e,t(e)})).catch((t=>e(t)))}))),y.init(),$.get(),this.getDefaultValues().then((t=>{this._defaultValues=t}))}connectedCallback(){f.setContextValue("__SNK__APPLICATION__",this),v.addRequestListener(this._requestListener)}disconnectedCallback(){v.removeRequestListener(this._requestListener)}componentDidLoad(){this.applicationLoading.emit(!0),window.requestAnimationFrame((()=>{this.applicationLoaded.emit(!0)})),m.addIDInfo(this._element,`resource_${this._resourceID}`)}render(){return s("div",null,s("ez-loading-bar",{ref:t=>this._requestListener.loadingBar=t}),s("ez-popup",{opened:!1,ref:t=>this._popUp=t,onEzClosePopup:()=>this.closePopUp()}),s("ez-modal",{opened:!1,ref:t=>this._rightModal=t,"modal-size":"small",closeOutsideClick:!0,closeEsc:!0}))}get _element(){return i(this)}};class W{constructor(){this._debounceTime=1e3,this._ignoredNameTypes=["totals"],this._countRequest=0}onRequestStart(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest++,this.loadingBar.show(),this._timerLoading&&clearTimeout(this._timerLoading))}onRequestEnd(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest--,this._timerLoading=setTimeout((()=>{this._countRequest<=0&&this.loadingBar.hide()}),this._debounceTime))}isIgnoreLoadingOnRequest(t){var e;if(1==(null===(e=null==t?void 0:t.requestBody)||void 0===e?void 0:e.length)){const{name:e}=t.requestBody[0].variables;if(e){const t=e.split(":");return this._ignoredNameTypes.indexOf(t[0])>=0}}return!1}}class Z{constructor(t,e){this.resolve=t,this.reject=e}}V.style=".sc-snk-application-h{display:flex;flex-direction:column;height:100%}";export{V as snk_application}