teraprox-ui-kit 0.1.8 → 0.2.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.
package/dist/index.js ADDED
@@ -0,0 +1,4052 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ ActionButtons: () => ActionButtons,
34
+ AddButton: () => AddButton_default,
35
+ AdvancedFilterBar: () => AdvancedFilterBar,
36
+ AnexoManager: () => import_ui_kit_core.AnexoManager,
37
+ ApproveAndReproveButtons: () => ApproveAndReproveButtons,
38
+ AsyncButton: () => AsyncButton,
39
+ AutoComplete: () => AutoComplete,
40
+ BonusButton: () => BonusButton,
41
+ BranchDropDisplay: () => import_ui_kit_sgm.BranchDropDisplay,
42
+ ButtonWithDropdown: () => ButtonWithDropdown,
43
+ CalculadoraCorrecaoModal: () => import_ui_kit_sgp.CalculadoraCorrecaoModal,
44
+ CalculoCorrecao: () => import_ui_kit_sgp.CalculoCorrecao,
45
+ CampoDeVerificacaoV2: () => import_ui_kit_sgp.CampoDeVerificacaoV2,
46
+ CheckBox: () => CheckBox,
47
+ ClickToWriteField: () => ClickToWriteField,
48
+ ColorPicker: () => ColorPicker,
49
+ ConfigObject: () => ConfigObject,
50
+ DeleteButton: () => DeleteButton_default,
51
+ DeleteConfirm: () => DeleteConfirm,
52
+ ExpandableCard: () => ExpandableCard,
53
+ FindRecursoByTagField: () => import_ui_kit_sgm3.FindRecursoByTagField,
54
+ FormField: () => FormField,
55
+ FrequenciaFormV2: () => import_ui_kit_sgp.FrequenciaFormV2,
56
+ Generic3DotMenu: () => Generic3DotMenu,
57
+ GenericChart: () => GenericChart,
58
+ GenericDisplay: () => GenericDisplay_default,
59
+ GenericForm: () => GenericForm_default,
60
+ GenericREchart: () => GenericREchart,
61
+ GenericSelect: () => GenericSelect_default,
62
+ GenericSelectOps: () => GenericSelectOps,
63
+ IconLabelItem: () => IconLabelItem,
64
+ IconLabelList: () => IconLabelList,
65
+ ImageViewModal: () => ImageViewModal,
66
+ JustificativaModal: () => JustificativaModal,
67
+ LoadingButton: () => LoadingButton,
68
+ LoadingProgress: () => LoadingProgress,
69
+ MailSender: () => MailSender,
70
+ MenuEvent: () => MenuEvent,
71
+ ModalBasicTemplate: () => ModalBasicTemplate,
72
+ NavigateButton: () => NavigateButton,
73
+ NotificationBell: () => NotificationBell,
74
+ NotificationItem: () => NotificationItem,
75
+ PeriodSelector: () => PeriodSelector,
76
+ QrCodeScanButton: () => QrCodeScanButton,
77
+ QrReader: () => QrReader,
78
+ RateLimitBar: () => RateLimitBar,
79
+ RecursoDisplayer: () => import_ui_kit_sgm2.RecursoDisplayer,
80
+ ResponsiveContainer: () => ResponsiveContainer_default,
81
+ ReusableTableWithModal: () => ReusableTableWithModal,
82
+ SectorSelector: () => SectorSelector,
83
+ SelectDateModal: () => SelectDateModal,
84
+ StatusBadge: () => StatusBadge,
85
+ StatusIndicator: () => StatusIndicator,
86
+ StatusLight: () => StatusLight,
87
+ StatusPills: () => StatusPills,
88
+ Switch: () => Switch,
89
+ SwitchOnClick: () => SwitchOnClick,
90
+ TarefaUnidadeForm: () => import_ui_kit_sgp.TarefaUnidadeForm,
91
+ TextWithMore: () => TextWithMore,
92
+ TimerDisplay: () => TimerDisplay,
93
+ UnidadeMaterialCard: () => import_ui_kit_sgp.UnidadeMaterialCard,
94
+ UnidadeMaterialForm: () => UnidadeMaterialForm,
95
+ UnifiedPeriodSelector: () => UnifiedPeriodSelector,
96
+ UploadArea: () => UploadArea,
97
+ UuidPill: () => UuidPill_default,
98
+ VerticalItemsDisplay: () => VerticalItemsDisplay
99
+ });
100
+ module.exports = __toCommonJS(index_exports);
101
+
102
+ // src/buttons/AddButton.tsx
103
+ var import_react_bootstrap = require("react-bootstrap");
104
+ var import_gr = require("react-icons/gr");
105
+ var import_jsx_runtime = require("react/jsx-runtime");
106
+ var AddButton = ({ callback, hiddenBool, size }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
107
+ import_react_bootstrap.Button,
108
+ {
109
+ hidden: hiddenBool || false,
110
+ variant: "outline-primary",
111
+ onClick: () => callback(),
112
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_gr.GrAdd, { size: size || 25 })
113
+ }
114
+ );
115
+ var AddButton_default = AddButton;
116
+
117
+ // src/buttons/DeleteButton.tsx
118
+ var import_jsx_runtime2 = require("react/jsx-runtime");
119
+ var DeleteButton = ({ title, onDeleteClick }) => {
120
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "btn btn-danger", onClick: () => onDeleteClick(), children: title });
121
+ };
122
+ var DeleteButton_default = DeleteButton;
123
+
124
+ // src/buttons/ActionButtons.tsx
125
+ var import_react2 = require("react");
126
+ var import_react_bootstrap3 = require("react-bootstrap");
127
+ var import_fi = require("react-icons/fi");
128
+
129
+ // src/forms/DeleteConfirm.tsx
130
+ var import_react = require("react");
131
+ var import_react_bootstrap2 = require("react-bootstrap");
132
+ var import_jsx_runtime3 = require("react/jsx-runtime");
133
+ var DeleteConfirm = ({
134
+ show,
135
+ onHide,
136
+ onConfirm,
137
+ title = "Confirma\xE7\xE3o de Exclus\xE3o",
138
+ dialogText,
139
+ payload,
140
+ needExclusionDetails = false
141
+ }) => {
142
+ const [exclusionDetails, setExclusionDetails] = (0, import_react.useState)("");
143
+ const getDialogContent = () => {
144
+ if (typeof dialogText === "function" && payload) {
145
+ return dialogText(payload);
146
+ }
147
+ return dialogText || "Voc\xEA tem certeza que deseja excluir este item?";
148
+ };
149
+ const isConfirmEnabled = () => {
150
+ if (!needExclusionDetails) return true;
151
+ return exclusionDetails.length >= 8;
152
+ };
153
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_bootstrap2.Modal, { show, onHide: () => onHide(false), centered: true, children: [
154
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_bootstrap2.Modal.Header, { closeButton: true, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_bootstrap2.Modal.Title, { children: title }) }),
155
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_bootstrap2.Modal.Body, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "d-flex flex-column gap-3", children: [
156
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: getDialogContent() }) }),
157
+ needExclusionDetails && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_bootstrap2.Form.Group, { children: [
158
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_bootstrap2.Form.Label, { children: "Motivo da Exclus\xE3o (m\xEDn. 8 caracteres)" }),
159
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
160
+ import_react_bootstrap2.Form.Control,
161
+ {
162
+ as: "textarea",
163
+ rows: 3,
164
+ value: exclusionDetails,
165
+ onChange: (e) => setExclusionDetails(e.target.value),
166
+ placeholder: "Descreva o motivo...",
167
+ autoFocus: true
168
+ }
169
+ )
170
+ ] })
171
+ ] }) }),
172
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_bootstrap2.Modal.Footer, { children: [
173
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_bootstrap2.Button, { variant: "secondary", onClick: () => onHide(false), children: "Cancelar" }),
174
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
175
+ import_react_bootstrap2.Button,
176
+ {
177
+ variant: "danger",
178
+ disabled: !isConfirmEnabled(),
179
+ onClick: () => {
180
+ onConfirm(exclusionDetails);
181
+ onHide(false);
182
+ },
183
+ children: "Confirmar Exclus\xE3o"
184
+ }
185
+ )
186
+ ] })
187
+ ] });
188
+ };
189
+
190
+ // src/buttons/ActionButtons.tsx
191
+ var import_jsx_runtime4 = require("react/jsx-runtime");
192
+ var ActionButtons = ({
193
+ onSave,
194
+ saveLabel = "Salvar",
195
+ saveVariant = "primary",
196
+ disabled = false,
197
+ onDelete,
198
+ deleteLabel = "Excluir",
199
+ deleteConfirmMsg,
200
+ needExclusionDetails = false,
201
+ onBack,
202
+ backLabel = "Voltar",
203
+ onCancelEdit,
204
+ cancelEditLabel = "Cancelar",
205
+ onCopy,
206
+ copyLabel = "Copiar Formul\xE1rio",
207
+ isEditing = false,
208
+ useDelayedDelete = false,
209
+ delayedDeleteTimeout = 3e3,
210
+ PermissionWrapper = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children })
211
+ }) => {
212
+ const [showConfirm, setShowConfirm] = (0, import_react2.useState)(false);
213
+ const [isHolding, setIsHolding] = (0, import_react2.useState)(false);
214
+ const [progress, setProgress] = (0, import_react2.useState)(0);
215
+ const timeoutRef = (0, import_react2.useRef)(null);
216
+ const intervalRef = (0, import_react2.useRef)(null);
217
+ const startHold = () => {
218
+ if (disabled || !onDelete) return;
219
+ setIsHolding(true);
220
+ setProgress(0);
221
+ const step = 2;
222
+ const tickTime = delayedDeleteTimeout / (100 / step);
223
+ intervalRef.current = setInterval(() => {
224
+ setProgress((prev) => prev >= 100 ? 100 : prev + step);
225
+ }, tickTime);
226
+ timeoutRef.current = setTimeout(() => {
227
+ stopHold();
228
+ onDelete();
229
+ }, delayedDeleteTimeout);
230
+ };
231
+ const stopHold = () => {
232
+ setIsHolding(false);
233
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
234
+ if (intervalRef.current) clearInterval(intervalRef.current);
235
+ setProgress(0);
236
+ };
237
+ const renderDeleteButton = () => {
238
+ if (!onDelete || !isEditing) return null;
239
+ if (useDelayedDelete) {
240
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { position: "relative", display: "inline-block", margin: 2 }, children: [
241
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
242
+ import_react_bootstrap3.Button,
243
+ {
244
+ variant: "outline-danger",
245
+ onMouseDown: startHold,
246
+ onMouseUp: stopHold,
247
+ onMouseLeave: stopHold,
248
+ onTouchStart: startHold,
249
+ onTouchEnd: stopHold,
250
+ disabled,
251
+ style: { minWidth: "120px" },
252
+ children: [
253
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_fi.FiTrash2, { className: "me-2" }),
254
+ isHolding ? "Segure..." : deleteLabel
255
+ ]
256
+ }
257
+ ),
258
+ isHolding && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
259
+ import_react_bootstrap3.ProgressBar,
260
+ {
261
+ now: progress,
262
+ style: {
263
+ position: "absolute",
264
+ bottom: 0,
265
+ left: 0,
266
+ right: 0,
267
+ height: "4px",
268
+ borderRadius: "0 0 4px 4px"
269
+ },
270
+ variant: "danger"
271
+ }
272
+ )
273
+ ] });
274
+ }
275
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
276
+ import_react_bootstrap3.Button,
277
+ {
278
+ variant: "danger",
279
+ onClick: () => setShowConfirm(true),
280
+ disabled,
281
+ style: { margin: 2 },
282
+ children: [
283
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_fi.FiTrash2, { className: "me-2" }),
284
+ deleteLabel
285
+ ]
286
+ }
287
+ );
288
+ };
289
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
290
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
291
+ DeleteConfirm,
292
+ {
293
+ show: showConfirm,
294
+ onHide: setShowConfirm,
295
+ onConfirm: (details) => onDelete && onDelete(details),
296
+ dialogText: deleteConfirmMsg,
297
+ needExclusionDetails
298
+ }
299
+ ),
300
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_bootstrap3.Form.Group, { className: "d-flex flex-wrap align-items-center mt-3 gap-1", children: [
301
+ onBack && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_bootstrap3.Button, { variant: "outline-secondary", onClick: onBack, disabled, style: { margin: 2 }, children: [
302
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_fi.FiChevronLeft, { className: "me-2" }),
303
+ backLabel
304
+ ] }),
305
+ isEditing && onCancelEdit && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_bootstrap3.Button, { variant: "warning", onClick: onCancelEdit, disabled, style: { margin: 2 }, children: [
306
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_fi.FiRotateCcw, { className: "me-2" }),
307
+ cancelEditLabel
308
+ ] }),
309
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PermissionWrapper, { children: renderDeleteButton() }),
310
+ onSave && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_bootstrap3.Button, { variant: saveVariant, onClick: onSave, disabled, style: { margin: 2 }, children: [
311
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_fi.FiSave, { className: "me-2" }),
312
+ saveLabel
313
+ ] }),
314
+ isEditing && onCopy && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_bootstrap3.Button, { variant: "outline-primary", onClick: onCopy, disabled, style: { margin: 2 }, children: [
315
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_fi.FiCopy, { className: "me-2" }),
316
+ copyLabel
317
+ ] })
318
+ ] })
319
+ ] });
320
+ };
321
+
322
+ // src/buttons/ApproveAndReproveButtons.tsx
323
+ var import_react3 = require("react");
324
+ var import_react_bootstrap4 = require("react-bootstrap");
325
+ var import_gr2 = require("react-icons/gr");
326
+ var import_jsx_runtime5 = require("react/jsx-runtime");
327
+ var ApproveAndReproveButtons = ({
328
+ buttonSize = 25,
329
+ approveCallback,
330
+ reproveCallback,
331
+ cancelCallback,
332
+ headerText = "Aprovar?",
333
+ approveText,
334
+ repproveText
335
+ }) => {
336
+ (0, import_react3.useEffect)(() => {
337
+ const keyboardHandler = (e) => {
338
+ if (e.key === "Escape") {
339
+ cancelCallback();
340
+ }
341
+ };
342
+ window.document.addEventListener("keydown", keyboardHandler);
343
+ return () => window.document.removeEventListener("keydown", keyboardHandler);
344
+ }, [cancelCallback]);
345
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
346
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("strong", { children: headerText }),
347
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("br", {}),
348
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_bootstrap4.Button, { onClick: approveCallback, variant: "success", className: "me-1", children: approveText ? approveText : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_gr2.GrCheckmark, { size: buttonSize }) }),
349
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_bootstrap4.Button, { onClick: reproveCallback, variant: "danger", children: repproveText ? repproveText : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_gr2.GrClose, { size: buttonSize }) })
350
+ ] });
351
+ };
352
+
353
+ // src/buttons/AsyncButton.tsx
354
+ var import_react4 = require("react");
355
+ var import_react_bootstrap6 = require("react-bootstrap");
356
+
357
+ // src/progress/LoadingProgress.tsx
358
+ var import_react_bootstrap5 = require("react-bootstrap");
359
+ var import_jsx_runtime6 = require("react/jsx-runtime");
360
+ var LoadingProgress = ({ hidden }) => {
361
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_bootstrap5.Spinner, { hidden, animation: "border", role: "status", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "visually-hidden", children: "Carregando..." }) });
362
+ };
363
+
364
+ // src/buttons/AsyncButton.tsx
365
+ var import_jsx_runtime7 = require("react/jsx-runtime");
366
+ var useAsyncAction = () => {
367
+ const [loading, setLoading] = (0, import_react4.useState)(false);
368
+ const isMounted = (0, import_react4.useRef)(true);
369
+ const isProcessing = (0, import_react4.useRef)(false);
370
+ const execute = async (action) => {
371
+ if (typeof action !== "function") {
372
+ throw new Error("A\xE7\xE3o inv\xE1lida: n\xE3o \xE9 uma fun\xE7\xE3o");
373
+ }
374
+ if (!action || isProcessing.current) return;
375
+ isProcessing.current = true;
376
+ setLoading(true);
377
+ try {
378
+ await action();
379
+ } catch (error) {
380
+ console.error("Async operation failed:", error);
381
+ } finally {
382
+ if (isMounted.current) {
383
+ setLoading(false);
384
+ isProcessing.current = false;
385
+ }
386
+ }
387
+ };
388
+ return { loading, execute };
389
+ };
390
+ var AsyncButton = ({
391
+ onClick,
392
+ children,
393
+ loadingComponent = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(LoadingProgress, {}),
394
+ buttonProps
395
+ }) => {
396
+ const { loading, execute } = useAsyncAction();
397
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
398
+ import_react_bootstrap6.Button,
399
+ {
400
+ ...buttonProps,
401
+ onClick: () => execute(onClick),
402
+ disabled: loading || buttonProps && buttonProps.disabled,
403
+ children: loading ? loadingComponent : children
404
+ }
405
+ );
406
+ };
407
+
408
+ // src/buttons/BonusButton.tsx
409
+ var import_jsx_runtime8 = require("react/jsx-runtime");
410
+ var BonusButton = ({
411
+ renderCondition = true,
412
+ onClickCallback,
413
+ label,
414
+ className = "",
415
+ ...props
416
+ }) => {
417
+ if (!renderCondition) return null;
418
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
419
+ "button",
420
+ {
421
+ className: `bonus-button ${className}`,
422
+ onClick: onClickCallback,
423
+ ...props,
424
+ children: label
425
+ }
426
+ );
427
+ };
428
+
429
+ // src/buttons/ButtonWithDropdown.tsx
430
+ var import_react_bootstrap7 = require("react-bootstrap");
431
+ var import_jsx_runtime9 = require("react/jsx-runtime");
432
+ var ButtonWithDropdown = ({
433
+ title,
434
+ onClickButton,
435
+ options,
436
+ menuVariant = "light",
437
+ variant = "primary",
438
+ toggleVariant
439
+ }) => {
440
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
441
+ import_react_bootstrap7.Dropdown,
442
+ {
443
+ as: import_react_bootstrap7.ButtonGroup,
444
+ className: "d-flex w-100",
445
+ style: { flex: 1, minWidth: 0 },
446
+ children: [
447
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
448
+ import_react_bootstrap7.Button,
449
+ {
450
+ variant,
451
+ onClick: onClickButton,
452
+ className: "flex-grow-1 text-truncate",
453
+ style: { minWidth: 0 },
454
+ children: title
455
+ }
456
+ ),
457
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
458
+ import_react_bootstrap7.Dropdown.Toggle,
459
+ {
460
+ split: true,
461
+ variant: toggleVariant || variant,
462
+ id: "dropdown-split-basic",
463
+ style: {
464
+ flex: "0 0 2.5rem",
465
+ width: "2.5rem",
466
+ padding: "0",
467
+ display: "flex",
468
+ justifyContent: "center",
469
+ alignItems: "center"
470
+ }
471
+ }
472
+ ),
473
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_bootstrap7.Dropdown.Menu, { variant: menuVariant, children: options.map((opt, idx) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_bootstrap7.Dropdown.Item, { onClick: opt.callback, children: opt.label }, `${opt.label}-${idx}`)) })
474
+ ]
475
+ }
476
+ );
477
+ };
478
+
479
+ // src/buttons/CheckBox.tsx
480
+ var import_react_bootstrap8 = require("react-bootstrap");
481
+ var import_ti = require("react-icons/ti");
482
+ var import_jsx_runtime10 = require("react/jsx-runtime");
483
+ var CheckBox = ({
484
+ opcoes,
485
+ isHover = false,
486
+ isCreator = false,
487
+ updateEvent,
488
+ deleteEvent,
489
+ enterEvent,
490
+ disabled = false,
491
+ className = ""
492
+ }) => {
493
+ if (isHover) {
494
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className, children: opcoes.map((opcao, index) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_bootstrap8.InputGroup, { style: { padding: 12, justifyItems: "center", opacity: disabled ? 0.5 : 1, pointerEvents: disabled ? "none" : "auto" }, children: [
495
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_bootstrap8.InputGroup.Checkbox, {}),
496
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
497
+ import_react_bootstrap8.Form.Control,
498
+ {
499
+ autoFocus: true,
500
+ onKeyDown: (event) => enterEvent && enterEvent(event, index, opcao),
501
+ style: { border: "none", borderBottom: "solid", borderRadius: 0, borderColor: "gray", borderWidth: "1px" },
502
+ value: isCreator ? "Nova opcao" : String(opcao.valor),
503
+ onChange: (event) => updateEvent && updateEvent(event, index)
504
+ }
505
+ ),
506
+ deleteEvent && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { style: { cursor: "pointer" }, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ti.TiDelete, { size: "18", className: "delete text-danger", onClick: () => deleteEvent() }) })
507
+ ] }, index)) });
508
+ }
509
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className, style: { textAlign: "start" }, children: opcoes.map((opcao, index) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
510
+ import_react_bootstrap8.Form.Check,
511
+ {
512
+ disabled,
513
+ type: "checkbox",
514
+ label: `${opcao.valor}`
515
+ },
516
+ index
517
+ )) });
518
+ };
519
+
520
+ // src/buttons/Generic3DotMenu.tsx
521
+ var import_react5 = require("react");
522
+ var import_react_bootstrap9 = require("react-bootstrap");
523
+ var import_ci = require("react-icons/ci");
524
+ var import_jsx_runtime11 = require("react/jsx-runtime");
525
+ var MenuEvent = class {
526
+ /**
527
+ * @param label - O texto que aparecerá no botão.
528
+ * @param callback - A função a ser chamada quando o botão for clicado.
529
+ * @param variant - A variante do botão (padrão: 'primary').
530
+ * @param renderCondition - Condição para renderizar o botão.
531
+ * @param section - A seção para organizar os botões (padrão: 'default').
532
+ */
533
+ constructor(label, callback, variant = "primary", renderCondition = true, section = "default") {
534
+ this.label = label;
535
+ this.callback = callback;
536
+ this.variant = variant;
537
+ this.renderCondition = renderCondition;
538
+ this.section = section;
539
+ }
540
+ };
541
+ var Generic3DotMenu = ({
542
+ events,
543
+ tittle = "Op\xE7\xF5es de Controle"
544
+ }) => {
545
+ const [show, setShow] = (0, import_react5.useState)(false);
546
+ const handleClose = () => setShow(false);
547
+ const handleShow = () => setShow(true);
548
+ const shouldRender = (event) => {
549
+ return typeof event.renderCondition === "function" ? event.renderCondition() : event.renderCondition;
550
+ };
551
+ const groupedEvents = events.reduce((sections, event) => {
552
+ const section = event.section || "default";
553
+ if (!sections[section]) {
554
+ sections[section] = [];
555
+ }
556
+ if (shouldRender(event)) {
557
+ sections[section].push(event);
558
+ }
559
+ return sections;
560
+ }, {});
561
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
562
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ci.CiMenuKebab, { onClick: handleShow, style: { cursor: "pointer" }, size: 25, title: tittle }),
563
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react_bootstrap9.Modal, { show, onHide: handleClose, centered: true, children: [
564
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_bootstrap9.Modal.Header, { closeButton: true, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_bootstrap9.Modal.Title, { children: tittle }) }),
565
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react_bootstrap9.Modal.Body, { children: [
566
+ Object.keys(groupedEvents).length === 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "text-center text-muted", children: "Nenhuma op\xE7\xE3o dispon\xEDvel." }),
567
+ Object.keys(groupedEvents).map((section, sectionIndex) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "mb-4", children: [
568
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h6", { className: "border-bottom pb-2 mb-3", children: section !== "default" ? section : "Op\xE7\xF5es Principais" }),
569
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "d-grid gap-2", children: groupedEvents[section].map((event, index) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
570
+ import_react_bootstrap9.Button,
571
+ {
572
+ variant: event.variant || "primary",
573
+ onClick: () => {
574
+ event.callback();
575
+ handleClose();
576
+ },
577
+ children: event.label
578
+ },
579
+ index
580
+ )) })
581
+ ] }, sectionIndex))
582
+ ] }),
583
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_bootstrap9.Modal.Footer, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_bootstrap9.Button, { variant: "secondary", onClick: handleClose, children: "Fechar" }) })
584
+ ] })
585
+ ] });
586
+ };
587
+
588
+ // src/buttons/LoadingButton.tsx
589
+ var import_react_bootstrap10 = require("react-bootstrap");
590
+ var import_jsx_runtime12 = require("react/jsx-runtime");
591
+ var LoadingButton = ({
592
+ onClick,
593
+ loading = false,
594
+ label = "Enviar",
595
+ variant = "primary",
596
+ size,
597
+ disabled = false,
598
+ icon = null,
599
+ className = "",
600
+ loadingLabel = "Carregando...",
601
+ ...props
602
+ }) => {
603
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
604
+ import_react_bootstrap10.Button,
605
+ {
606
+ variant,
607
+ size,
608
+ disabled: disabled || loading,
609
+ onClick,
610
+ className: `loading-button ${className}`,
611
+ style: { cursor: loading ? "not-allowed" : "pointer" },
612
+ ...props,
613
+ children: loading ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "align-items-center", children: [
614
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
615
+ import_react_bootstrap10.Spinner,
616
+ {
617
+ as: "span",
618
+ animation: "border",
619
+ size: "sm",
620
+ role: "status",
621
+ "aria-hidden": "true",
622
+ className: "me-2"
623
+ }
624
+ ),
625
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: loadingLabel })
626
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "align-items-center", children: [
627
+ icon && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "me-2 d-flex", children: icon }),
628
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: label })
629
+ ] })
630
+ }
631
+ );
632
+ };
633
+
634
+ // src/buttons/NavigateButton.tsx
635
+ var import_react_bootstrap11 = require("react-bootstrap");
636
+ var import_jsx_runtime13 = require("react/jsx-runtime");
637
+ var NavigateButton = ({
638
+ displayName,
639
+ path,
640
+ config,
641
+ pageName,
642
+ navigator: navigator2,
643
+ onBeforeNavigate,
644
+ variant = "outline-primary",
645
+ style,
646
+ ...props
647
+ }) => {
648
+ const handleClick = () => {
649
+ if (onBeforeNavigate) {
650
+ onBeforeNavigate();
651
+ }
652
+ navigator2(path, config, pageName);
653
+ };
654
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
655
+ import_react_bootstrap11.Button,
656
+ {
657
+ style,
658
+ variant,
659
+ onClick: handleClick,
660
+ ...props,
661
+ children: displayName
662
+ }
663
+ );
664
+ };
665
+
666
+ // src/buttons/StatusBadge.tsx
667
+ var import_react_bootstrap12 = require("react-bootstrap");
668
+ var import_jsx_runtime14 = require("react/jsx-runtime");
669
+ var StatusBadge = ({
670
+ status,
671
+ showCheckbox = false,
672
+ checked = false,
673
+ onToggle = () => {
674
+ },
675
+ loading = false,
676
+ customStatusClasses
677
+ }) => {
678
+ const statusClasses = customStatusClasses || {
679
+ PENDENTE: "bg-warning text-dark",
680
+ EXECUTANDO: "bg-success text-white",
681
+ CONCLUIDO: "bg-secondary text-white",
682
+ CANCELED: "bg-danger text-white"
683
+ };
684
+ const badgeClass = statusClasses[status] || "bg-secondary text-white";
685
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "d-flex align-items-center gap-2", children: loading ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_bootstrap12.Spinner, { animation: "border", size: "sm" }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
686
+ showCheckbox && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
687
+ import_react_bootstrap12.Form.Check,
688
+ {
689
+ type: "checkbox",
690
+ checked,
691
+ onChange: onToggle,
692
+ className: "me-1"
693
+ }
694
+ ),
695
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: `badge ${badgeClass}`, children: status })
696
+ ] }) });
697
+ };
698
+
699
+ // src/buttons/SwitchOnClick.tsx
700
+ var import_react6 = require("react");
701
+ var import_fa = require("react-icons/fa");
702
+ var import_gr3 = require("react-icons/gr");
703
+ var import_jsx_runtime15 = require("react/jsx-runtime");
704
+ var SwitchOnClick = ({
705
+ children,
706
+ placeHolder = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
707
+ "div",
708
+ {
709
+ className: "text-center zoom-container",
710
+ style: {
711
+ fontSize: "1.2rem",
712
+ color: "#666"
713
+ },
714
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
715
+ import_gr3.GrAddCircle,
716
+ {
717
+ size: 25,
718
+ className: "mb-2",
719
+ style: { cursor: "pointer" }
720
+ }
721
+ )
722
+ }
723
+ ),
724
+ onSwitchClick,
725
+ onCancel,
726
+ containerClassName = ""
727
+ }) => {
728
+ const [clicked, setClicked] = (0, import_react6.useState)(false);
729
+ const handleClick = () => {
730
+ onSwitchClick && onSwitchClick();
731
+ setClicked(!clicked);
732
+ };
733
+ const handleClose = () => {
734
+ setClicked(false);
735
+ onCancel && onCancel();
736
+ };
737
+ (0, import_react6.useEffect)(() => {
738
+ const handleEscape = (event) => {
739
+ if (event.key === "Escape") {
740
+ handleClose();
741
+ }
742
+ };
743
+ window.addEventListener("keydown", handleEscape);
744
+ return () => window.removeEventListener("keydown", handleEscape);
745
+ }, []);
746
+ if (!clicked) {
747
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { onClick: handleClick, style: { cursor: "pointer" }, children: placeHolder });
748
+ }
749
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: `switch-on-click-container ${containerClassName}`, children: [
750
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "close-icon", onClick: handleClose, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_fa.FaTimes, { title: "Fechar" }) }),
751
+ children({ handleClose })
752
+ ] });
753
+ };
754
+
755
+ // src/charts/GenericChart.tsx
756
+ var import_react_google_charts = require("react-google-charts");
757
+ var import_jsx_runtime16 = require("react/jsx-runtime");
758
+ var GenericChart = ({
759
+ chartType,
760
+ graphID,
761
+ width = "100%",
762
+ height = "400px",
763
+ columns,
764
+ rows,
765
+ chartEvents,
766
+ options,
767
+ tooltipFormatter
768
+ }) => {
769
+ let datachart = [columns, ...rows];
770
+ if (tooltipFormatter) {
771
+ datachart = datachart.map((row, index) => {
772
+ if (index === 0) return row;
773
+ const formattedTooltip = tooltipFormatter(row);
774
+ return [...row, formattedTooltip];
775
+ });
776
+ datachart[0] = [...columns, { type: "string", role: "tooltip", p: { html: true } }];
777
+ }
778
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
779
+ import_react_google_charts.Chart,
780
+ {
781
+ chartType,
782
+ options: { ...options, tooltip: { isHtml: true } },
783
+ data: datachart,
784
+ graphID,
785
+ width,
786
+ height,
787
+ chartEvents
788
+ }
789
+ );
790
+ };
791
+
792
+ // src/charts/GenericREchart.tsx
793
+ var import_recharts = require("recharts");
794
+ var import_dayjs = __toESM(require("dayjs"));
795
+ var import_jsx_runtime17 = require("react/jsx-runtime");
796
+ var GenericREchart = ({
797
+ data = [],
798
+ lines = [],
799
+ xAxisKey = "data",
800
+ showGrid = true,
801
+ showLegend = true,
802
+ showTooltip = true,
803
+ width = "100%",
804
+ height = 400,
805
+ hideYAxis,
806
+ unit,
807
+ margin = { top: 20, right: 30, left: 20, bottom: 5 },
808
+ YAxisRange = [0, "auto"]
809
+ }) => {
810
+ const sortedData = [...data].sort(
811
+ (a, b) => new Date(a[xAxisKey]).getTime() - new Date(b[xAxisKey]).getTime()
812
+ );
813
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: { width, height }, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_recharts.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_recharts.LineChart, { data: sortedData, margin, children: [
814
+ showGrid && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_recharts.CartesianGrid, { strokeDasharray: "3 3" }),
815
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
816
+ import_recharts.XAxis,
817
+ {
818
+ dataKey: xAxisKey,
819
+ reversed: false,
820
+ tickFormatter: (tick) => (0, import_dayjs.default)(tick).format("DD/MM/YY HH:mm")
821
+ }
822
+ ),
823
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_recharts.YAxis, { domain: YAxisRange, unit, hide: hideYAxis, type: "number" }),
824
+ showTooltip && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
825
+ import_recharts.Tooltip,
826
+ {
827
+ labelFormatter: (label) => (0, import_dayjs.default)(label).format("DD/MM/YY HH:mm")
828
+ }
829
+ ),
830
+ showLegend && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_recharts.Legend, {}),
831
+ lines.map((lineCfg, idx) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_recharts.Line, { ...lineCfg }, idx))
832
+ ] }) }) });
833
+ };
834
+
835
+ // src/containers/ResponsiveContainer.tsx
836
+ var import_react_bootstrap13 = require("react-bootstrap");
837
+ var import_jsx_runtime18 = require("react/jsx-runtime");
838
+ var ResponsiveContainer2 = ({
839
+ title,
840
+ show,
841
+ setShow,
842
+ children,
843
+ onClose,
844
+ scrollable = false
845
+ }) => {
846
+ const handleClose = () => {
847
+ setShow(false);
848
+ if (onClose) onClose();
849
+ };
850
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_react_bootstrap13.Modal, { size: "lg", show, onHide: handleClose, scrollable, children: [
851
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_bootstrap13.Modal.Header, { closeButton: true, onClick: handleClose, children: title && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_bootstrap13.Modal.Title, { children: title }) }),
852
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_bootstrap13.ModalBody, { children })
853
+ ] });
854
+ };
855
+ var ResponsiveContainer_default = ResponsiveContainer2;
856
+
857
+ // src/containers/ExpandableCard.tsx
858
+ var import_react7 = require("react");
859
+ var import_react_bootstrap14 = require("react-bootstrap");
860
+ var import_fa2 = require("react-icons/fa");
861
+ var import_jsx_runtime19 = require("react/jsx-runtime");
862
+ var ExpandableCard = ({
863
+ items = [],
864
+ initialVisibleCount = 3,
865
+ expandable = true,
866
+ leftSideContent,
867
+ rightSideContent,
868
+ cardClassName = "",
869
+ cardBodyClassName = "",
870
+ cardBodyStyle,
871
+ isMobile = false
872
+ }) => {
873
+ const [expandedCard, setExpandedCard] = (0, import_react7.useState)(false);
874
+ const handleToggleExpandCard = () => {
875
+ setExpandedCard(!expandedCard);
876
+ };
877
+ const visibleItems = expandedCard ? items : items.slice(0, initialVisibleCount);
878
+ const shouldShowExpandButton = expandable && items.length > initialVisibleCount;
879
+ const renderContentWithToggle = (content) => {
880
+ return content;
881
+ };
882
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_react_bootstrap14.Card, { className: `expandable-card ${cardClassName}`, children: [
883
+ leftSideContent && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "expandable-card-left-side", children: leftSideContent }),
884
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_bootstrap14.Card.Body, { className: `expandable-card-body ${cardBodyClassName}`, style: cardBodyStyle, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_react_bootstrap14.ListGroup, { variant: "flush", children: [
885
+ visibleItems.map((item, index) => {
886
+ const isObject = typeof item === "object" && item !== null && "content" in item;
887
+ const itemObj = isObject ? item : { content: item };
888
+ const clickableClass = itemObj.clickable ? "expandable-card-list-item-clickable" : "";
889
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
890
+ import_react_bootstrap14.ListGroup.Item,
891
+ {
892
+ className: `expandable-card-list-item ${clickableClass}`,
893
+ children: isMobile ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "expandable-card-item", children: [
894
+ itemObj.label && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "expandable-card-item-header", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("strong", { children: itemObj.label }) }),
895
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "expandable-card-item-content", children: renderContentWithToggle(itemObj.content) })
896
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "expandable-card-item-row", children: [
897
+ itemObj.label && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("strong", { className: "expandable-card-item-label", children: [
898
+ itemObj.label,
899
+ ":"
900
+ ] }),
901
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "expandable-card-item-content", children: renderContentWithToggle(itemObj.content) })
902
+ ] })
903
+ },
904
+ index
905
+ );
906
+ }),
907
+ shouldShowExpandButton && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
908
+ import_react_bootstrap14.ListGroup.Item,
909
+ {
910
+ className: `expandable-card-toggle ${expandedCard ? "expanded" : ""}`,
911
+ onClick: handleToggleExpandCard,
912
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_fa2.FaChevronDown, { className: "expandable-card-toggle-icon" })
913
+ }
914
+ )
915
+ ] }) }),
916
+ rightSideContent && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "expandable-card-right-side", children: rightSideContent })
917
+ ] });
918
+ };
919
+
920
+ // src/displays/UuidPill.tsx
921
+ var import_react8 = require("react");
922
+ var import_react_bootstrap15 = require("react-bootstrap");
923
+ var import_jsx_runtime20 = require("react/jsx-runtime");
924
+ var UuidPill = ({ uuid, bg = "light", textColor = "dark", short = 8 }) => {
925
+ const [copied, setCopied] = (0, import_react8.useState)(false);
926
+ const ref = (0, import_react8.useRef)(null);
927
+ const [showTooltip, setShowTooltip] = (0, import_react8.useState)(false);
928
+ if (!uuid) return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-muted", children: "\u2014" });
929
+ const shortId = String(uuid).substring(0, short);
930
+ const handleCopy = async (e) => {
931
+ e.stopPropagation();
932
+ try {
933
+ await navigator.clipboard.writeText(uuid);
934
+ } catch (e2) {
935
+ const ta = document.createElement("textarea");
936
+ ta.value = uuid;
937
+ document.body.appendChild(ta);
938
+ ta.select();
939
+ document.execCommand("copy");
940
+ document.body.removeChild(ta);
941
+ }
942
+ setCopied(true);
943
+ setTimeout(() => setCopied(false), 1500);
944
+ };
945
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
946
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
947
+ import_react_bootstrap15.Badge,
948
+ {
949
+ ref,
950
+ bg,
951
+ text: textColor,
952
+ pill: true,
953
+ className: "border px-2 py-1",
954
+ style: { cursor: "pointer", fontFamily: "monospace", fontSize: "0.8rem", userSelect: "none" },
955
+ onClick: handleCopy,
956
+ onMouseEnter: () => setShowTooltip(true),
957
+ onMouseLeave: () => {
958
+ setShowTooltip(false);
959
+ setCopied(false);
960
+ },
961
+ children: [
962
+ shortId,
963
+ "\u2026"
964
+ ]
965
+ }
966
+ ),
967
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_react_bootstrap15.Overlay, { target: ref.current, show: showTooltip, placement: "top", children: (props) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_react_bootstrap15.Tooltip, { ...props, children: copied ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { style: { color: "#6f6" }, children: "Copiado!" }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { style: { fontFamily: "monospace", fontSize: "0.75rem" }, children: [
968
+ uuid,
969
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("br", {}),
970
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("small", { className: "text-muted", children: "Clique para copiar" })
971
+ ] }) }) })
972
+ ] });
973
+ };
974
+ var UuidPill_default = UuidPill;
975
+
976
+ // src/displays/GenericDisplay.tsx
977
+ var import_react9 = __toESM(require("react"));
978
+ var import_react_bootstrap16 = require("react-bootstrap");
979
+ var import_jsx_runtime21 = require("react/jsx-runtime");
980
+ var ConfigObject = class {
981
+ constructor(dotNotation, style, onClick, onBlur, onHideClick, hidden, mapData, additionalComponents) {
982
+ this.dotNotation = dotNotation;
983
+ this.style = style;
984
+ this.onClick = onClick;
985
+ this.onBlur = onBlur;
986
+ this.onHideClick = onHideClick;
987
+ this.hidden = hidden;
988
+ this.mapData = mapData;
989
+ this.additionalComponents = additionalComponents || [];
990
+ }
991
+ };
992
+ var getRightConfigObjects = (currentPropertieMap, configObjects) => {
993
+ const curreDotNotation = currentPropertieMap.join(".");
994
+ if (!configObjects) return [];
995
+ return configObjects.filter((configObject) => configObject.dotNotation === curreDotNotation);
996
+ };
997
+ var getStyle = (configObjects) => {
998
+ let styleObject = {};
999
+ configObjects.forEach((configObject) => {
1000
+ styleObject = { ...styleObject, ...configObject.style };
1001
+ });
1002
+ return styleObject;
1003
+ };
1004
+ var getAdditionalComponentes = (configObjects) => {
1005
+ const components = [];
1006
+ configObjects.forEach((configObject) => {
1007
+ if (configObject.additionalComponents) {
1008
+ components.push(...configObject.additionalComponents);
1009
+ }
1010
+ });
1011
+ return components;
1012
+ };
1013
+ var getOnClick = (configObjects) => {
1014
+ return () => {
1015
+ configObjects.forEach((configObject) => {
1016
+ configObject.onClick && configObject.onClick();
1017
+ });
1018
+ };
1019
+ };
1020
+ var buildData = (obj, propertiesMap, configObjects, opn, innerArray, dispatch, isRoot, editButtonRenderer) => {
1021
+ const newPropertiesMap = [];
1022
+ if (opn) newPropertiesMap.push(...propertiesMap, opn);
1023
+ else newPropertiesMap.push(...propertiesMap);
1024
+ const innerConfigs = getRightConfigObjects(newPropertiesMap, configObjects);
1025
+ const styles = getStyle(innerConfigs);
1026
+ const onClick = getOnClick(innerConfigs);
1027
+ const extraComponents = getAdditionalComponentes(innerConfigs);
1028
+ if (Array.isArray(obj)) {
1029
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_react_bootstrap16.Container, { onClick, style: { ...styles }, children: [
1030
+ opn && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { style: { textAlign: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("strong", { children: opn }) }),
1031
+ obj.map((o, index) => {
1032
+ const mapCopy = [...newPropertiesMap, `[${index}]`];
1033
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react_bootstrap16.Row, { style: { padding: 4, ...styles }, children: buildData(o, mapCopy, configObjects, null, true, null, false, editButtonRenderer) }, index);
1034
+ })
1035
+ ] });
1036
+ }
1037
+ if (typeof obj === "object" && obj != null) {
1038
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
1039
+ import_react_bootstrap16.Container,
1040
+ {
1041
+ onClick,
1042
+ style: {
1043
+ border: innerArray ? "solid" : void 0,
1044
+ borderColor: "lightgray",
1045
+ borderRadius: innerArray ? 4 : 2,
1046
+ borderWidth: 1,
1047
+ padding: 4,
1048
+ ...styles
1049
+ },
1050
+ children: [
1051
+ opn && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("strong", { children: opn }),
1052
+ Object.entries(obj).map(
1053
+ ([key, value]) => buildData(value, newPropertiesMap, configObjects, key, false, null, false, editButtonRenderer)
1054
+ ),
1055
+ extraComponents.length > 0 ? extraComponents.map((comp, i) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react9.default.Fragment, { children: comp() }, i)) : isRoot && editButtonRenderer ? editButtonRenderer(obj, opn) : null
1056
+ ]
1057
+ }
1058
+ );
1059
+ }
1060
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_react_bootstrap16.Col, { children: [
1061
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("strong", { children: [
1062
+ opn,
1063
+ ": "
1064
+ ] }),
1065
+ String(obj)
1066
+ ] });
1067
+ };
1068
+ var GenericDisplay = ({
1069
+ ops = [],
1070
+ loadFunc,
1071
+ configObjects,
1072
+ rootName,
1073
+ context,
1074
+ onRefresh,
1075
+ editButtonRenderer
1076
+ }) => {
1077
+ const [innerOptions, setInnerOptions] = (0, import_react9.useState)();
1078
+ const refreshFunc = () => {
1079
+ if (loadFunc) {
1080
+ loadFunc().then((res) => {
1081
+ if (Array.isArray(res)) {
1082
+ setInnerOptions(res);
1083
+ } else {
1084
+ setInnerOptions([res]);
1085
+ }
1086
+ });
1087
+ } else {
1088
+ setInnerOptions(ops);
1089
+ }
1090
+ };
1091
+ (0, import_react9.useEffect)(() => {
1092
+ if (onRefresh) {
1093
+ onRefresh(refreshFunc);
1094
+ } else {
1095
+ refreshFunc();
1096
+ }
1097
+ }, [context]);
1098
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: innerOptions && innerOptions.map((cObj, index) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react_bootstrap16.Container, { style: { padding: 4, border: "solid" }, children: buildData(cObj, [], configObjects, rootName || null, false, null, true, editButtonRenderer) }, index)) });
1099
+ };
1100
+ var GenericDisplay_default = GenericDisplay;
1101
+
1102
+ // src/displays/BranchDropDisplay.tsx
1103
+ var import_ui_kit_sgm = require("@teraprox/ui-kit-sgm");
1104
+
1105
+ // src/displays/RateLimitBar.tsx
1106
+ var import_react10 = require("react");
1107
+ var import_jsx_runtime22 = require("react/jsx-runtime");
1108
+ function formatResetIn(windowReset) {
1109
+ const resetAt = new Date(windowReset).getTime();
1110
+ const remaining = Math.max(0, Math.round((resetAt - Date.now()) / 1e3));
1111
+ if (remaining <= 0) return "agora";
1112
+ if (remaining < 60) return `${remaining}s`;
1113
+ return `${Math.round(remaining / 60)}min`;
1114
+ }
1115
+ var RateLimitBar = ({ entry, label, className }) => {
1116
+ const pct = (0, import_react10.useMemo)(() => {
1117
+ if (!entry || entry.limit <= 0) return 0;
1118
+ return Math.min(100, Math.round(entry.used / entry.limit * 100));
1119
+ }, [entry]);
1120
+ if (!entry) return null;
1121
+ const color = entry.exceeded || pct >= 90 ? "#dc3545" : pct >= 70 ? "#ffc107" : "#28a745";
1122
+ const containerStyle = {
1123
+ width: "100%",
1124
+ marginBottom: "4px"
1125
+ };
1126
+ const barTrackStyle = {
1127
+ height: "6px",
1128
+ width: "100%",
1129
+ backgroundColor: "#e9ecef",
1130
+ borderRadius: "3px",
1131
+ overflow: "hidden"
1132
+ };
1133
+ const barFillStyle = {
1134
+ height: "100%",
1135
+ width: `${pct}%`,
1136
+ backgroundColor: color,
1137
+ borderRadius: "3px",
1138
+ transition: "width 0.3s ease, background-color 0.3s ease"
1139
+ };
1140
+ const textStyle = {
1141
+ fontSize: "11px",
1142
+ color: "#6c757d",
1143
+ display: "flex",
1144
+ justifyContent: "space-between",
1145
+ marginBottom: "2px"
1146
+ };
1147
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: containerStyle, className, children: [
1148
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: textStyle, children: [
1149
+ label && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { children: label }),
1150
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { children: [
1151
+ entry.used,
1152
+ "/",
1153
+ entry.limit,
1154
+ " req",
1155
+ entry.exceeded ? " \u2014 limite atingido" : ` (reset em ${formatResetIn(entry.windowReset)})`
1156
+ ] })
1157
+ ] }),
1158
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { style: barTrackStyle, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { style: barFillStyle }) })
1159
+ ] });
1160
+ };
1161
+
1162
+ // src/displays/StatusIndicator.tsx
1163
+ var import_jsx_runtime23 = require("react/jsx-runtime");
1164
+ var StatusIndicator = ({
1165
+ status,
1166
+ count,
1167
+ containerClassName = "",
1168
+ customLabels
1169
+ }) => {
1170
+ const statusLabels = customLabels || {
1171
+ pendente: "PENDENTE",
1172
+ executando: "EXECUTANDO",
1173
+ concluido: "CONCLU\xCDDA",
1174
+ canceled: "CANCELADA",
1175
+ naoAtribuida: "N\xC3O ATRIBUIDA"
1176
+ };
1177
+ const label = statusLabels[status] || status.toUpperCase();
1178
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: `status-flag ${status} ${containerClassName}`, children: [
1179
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "status-label", children: label }),
1180
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "status-count", children: count })
1181
+ ] });
1182
+ };
1183
+
1184
+ // src/displays/VerticalItemsDisplay.tsx
1185
+ var import_jsx_runtime24 = require("react/jsx-runtime");
1186
+ var VerticalItemsDisplay = ({
1187
+ item1 = "",
1188
+ item2 = "",
1189
+ item3 = "",
1190
+ className = "",
1191
+ style
1192
+ }) => {
1193
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className, style, children: [
1194
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { children: item1 }),
1195
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { children: item2 }),
1196
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { children: item3 })
1197
+ ] });
1198
+ };
1199
+
1200
+ // src/displays/StatusLight.tsx
1201
+ var import_jsx_runtime25 = require("react/jsx-runtime");
1202
+ var StatusLight = ({
1203
+ active = false,
1204
+ activeLightColor = "green",
1205
+ inactiveLightColor = "gray",
1206
+ size = "20px",
1207
+ className = "",
1208
+ style
1209
+ }) => {
1210
+ const color = active ? activeLightColor : inactiveLightColor;
1211
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
1212
+ "div",
1213
+ {
1214
+ className,
1215
+ style: {
1216
+ backgroundColor: color,
1217
+ borderRadius: "50%",
1218
+ width: size,
1219
+ height: size,
1220
+ display: "inline-block",
1221
+ transition: "background-color 0.3s ease",
1222
+ ...style
1223
+ }
1224
+ }
1225
+ );
1226
+ };
1227
+
1228
+ // src/displays/TimerDisplay.tsx
1229
+ var import_dayjs2 = __toESM(require("dayjs"));
1230
+ var import_duration = __toESM(require("dayjs/plugin/duration"));
1231
+ var import_bi = require("react-icons/bi");
1232
+ var import_bs = require("react-icons/bs");
1233
+ var import_jsx_runtime26 = require("react/jsx-runtime");
1234
+ import_dayjs2.default.extend(import_duration.default);
1235
+ var TimerDisplay = ({
1236
+ id,
1237
+ tempo = 0,
1238
+ isStopped = false,
1239
+ pausable = false,
1240
+ playable = false,
1241
+ enableView = true,
1242
+ onPause,
1243
+ onPlay,
1244
+ emptyMessage = "Timer ainda n\xE3o iniciado."
1245
+ }) => {
1246
+ const handlePause = (e) => {
1247
+ e.stopPropagation();
1248
+ if (id && onPause) onPause(id);
1249
+ };
1250
+ const handlePlay = (e) => {
1251
+ e.stopPropagation();
1252
+ if (id && onPlay) onPlay(id);
1253
+ };
1254
+ const formatDuration = (seconds) => {
1255
+ if (!enableView) return "- : - : -";
1256
+ const time = import_dayjs2.default.duration(seconds, "seconds");
1257
+ const days = Math.floor(time.asDays());
1258
+ const hours = time.hours().toString().padStart(2, "0");
1259
+ const minutes = time.minutes().toString().padStart(2, "0");
1260
+ const secondsRemaining = time.seconds().toString().padStart(2, "0");
1261
+ return days > 0 ? `${days}d ${hours}:${minutes}:${secondsRemaining}` : `${hours}:${minutes}:${secondsRemaining}`;
1262
+ };
1263
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "timer-display-container", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "timer-display-content", children: id ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
1264
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
1265
+ import_bi.BiTimer,
1266
+ {
1267
+ size: 24,
1268
+ className: "timer-icon",
1269
+ title: "Timer"
1270
+ }
1271
+ ),
1272
+ pausable && !isStopped && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
1273
+ import_bs.BsPause,
1274
+ {
1275
+ size: 20,
1276
+ className: "timer-icon-action",
1277
+ onClick: handlePause,
1278
+ title: "Pausar"
1279
+ }
1280
+ ),
1281
+ playable && !isStopped && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
1282
+ import_bs.BsPlay,
1283
+ {
1284
+ size: 20,
1285
+ className: "timer-icon-action",
1286
+ onClick: handlePlay,
1287
+ title: "Iniciar"
1288
+ }
1289
+ ),
1290
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "timer-display-time", children: formatDuration(tempo) })
1291
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "timer-display-message", children: emptyMessage }) }) });
1292
+ };
1293
+
1294
+ // src/displays/RecursoDisplayer.tsx
1295
+ var import_ui_kit_sgm2 = require("@teraprox/ui-kit-sgm");
1296
+
1297
+ // src/filters/StatusPills.tsx
1298
+ var import_jsx_runtime27 = require("react/jsx-runtime");
1299
+ var StatusPills = ({
1300
+ statuses,
1301
+ activeKeys,
1302
+ onSelectionChange,
1303
+ multiSelect = true,
1304
+ className = ""
1305
+ }) => {
1306
+ const toggleKey = (key) => {
1307
+ const isActive = activeKeys.includes(key);
1308
+ if (multiSelect) {
1309
+ if (isActive) {
1310
+ onSelectionChange(activeKeys.filter((k) => k !== key));
1311
+ } else {
1312
+ onSelectionChange([...activeKeys, key]);
1313
+ }
1314
+ } else {
1315
+ onSelectionChange(isActive ? [] : [key]);
1316
+ }
1317
+ };
1318
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: `status-pills-container ${className}`, children: Object.entries(statuses).map(([key, meta]) => {
1319
+ const isActive = activeKeys.includes(key);
1320
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
1321
+ "button",
1322
+ {
1323
+ type: "button",
1324
+ className: `status-pill ${isActive ? "active" : ""}`,
1325
+ style: { "--status-color": meta.color },
1326
+ onClick: () => toggleKey(key),
1327
+ "aria-pressed": isActive,
1328
+ children: [
1329
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "status-pill__swatch" }),
1330
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "status-pill__label", children: meta.label }),
1331
+ meta.count !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "status-pill__count", children: meta.count })
1332
+ ]
1333
+ },
1334
+ key
1335
+ );
1336
+ }) });
1337
+ };
1338
+
1339
+ // src/filters/PeriodSelector.tsx
1340
+ var import_react11 = require("react");
1341
+ var import_react_bootstrap17 = require("react-bootstrap");
1342
+ var import_fa3 = require("react-icons/fa");
1343
+ var import_dayjs3 = __toESM(require("dayjs"));
1344
+ var import_jsx_runtime28 = require("react/jsx-runtime");
1345
+ var PeriodSelector = ({
1346
+ startDate,
1347
+ endDate,
1348
+ onStartDateChange,
1349
+ onEndDateChange,
1350
+ onPresetSelect,
1351
+ label = "Per\xEDodo",
1352
+ allowFuture = false,
1353
+ className = ""
1354
+ }) => {
1355
+ const [isExpanded, setIsExpanded] = (0, import_react11.useState)(false);
1356
+ const formatDisplayRange = (start, end) => {
1357
+ const s = (0, import_dayjs3.default)(start).format("DD/MM/YY HH:mm");
1358
+ const e = (0, import_dayjs3.default)(end).format("DD/MM/YY HH:mm");
1359
+ return `${s} at\xE9 ${e}`;
1360
+ };
1361
+ const maxDate = allowFuture ? void 0 : (0, import_dayjs3.default)().format("YYYY-MM-DDTHH:mm");
1362
+ const presets = [
1363
+ { key: "today", label: "Hoje" },
1364
+ { key: "week", label: "\xDAltima Semana" },
1365
+ { key: "fortnight", label: "Quinzena" },
1366
+ { key: "month", label: "\xDAltimo M\xEAs" },
1367
+ { key: "year", label: "\xDAltimo Ano" }
1368
+ ];
1369
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react_bootstrap17.Card, { className: `period-selector-card ${isExpanded ? "expanded" : ""} ${className}`, children: [
1370
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "compact-row", onClick: () => setIsExpanded(!isExpanded), children: [
1371
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "d-flex align-items-center", children: [
1372
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_fa3.FaCalendarAlt, { className: "me-2 text-primary" }),
1373
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "date-range-text", children: isExpanded ? label : formatDisplayRange(startDate, endDate) })
1374
+ ] }),
1375
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "period-icon-btn", children: isExpanded ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_fa3.FaChevronUp, {}) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "small text-muted", children: "Editar" }) })
1376
+ ] }),
1377
+ isExpanded && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "expanded-content", children: [
1378
+ onPresetSelect && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
1379
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "d-flex align-items-center mb-2", children: [
1380
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_fa3.FaHistory, { size: 12, className: "me-1 text-muted" }),
1381
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("small", { className: "text-muted fw-bold text-uppercase", style: { fontSize: "0.65rem" }, children: "Atalhos" })
1382
+ ] }),
1383
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "presets-container", children: presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
1384
+ import_react_bootstrap17.Button,
1385
+ {
1386
+ variant: "outline-primary",
1387
+ className: "preset-btn",
1388
+ onClick: (e) => {
1389
+ e.stopPropagation();
1390
+ onPresetSelect(p.key);
1391
+ setIsExpanded(false);
1392
+ },
1393
+ children: p.label
1394
+ },
1395
+ p.key
1396
+ )) })
1397
+ ] }),
1398
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "date-inputs-grid", children: [
1399
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react_bootstrap17.Form.Group, { children: [
1400
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_react_bootstrap17.Form.Label, { className: "small text-muted", children: "In\xEDcio" }),
1401
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
1402
+ import_react_bootstrap17.Form.Control,
1403
+ {
1404
+ type: "datetime-local",
1405
+ size: "sm",
1406
+ value: startDate,
1407
+ max: maxDate,
1408
+ onChange: (e) => onStartDateChange(e.target.value)
1409
+ }
1410
+ )
1411
+ ] }),
1412
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react_bootstrap17.Form.Group, { children: [
1413
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_react_bootstrap17.Form.Label, { className: "small text-muted", children: "Fim" }),
1414
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
1415
+ import_react_bootstrap17.Form.Control,
1416
+ {
1417
+ type: "datetime-local",
1418
+ size: "sm",
1419
+ value: endDate,
1420
+ min: startDate,
1421
+ max: maxDate,
1422
+ onChange: (e) => onEndDateChange(e.target.value)
1423
+ }
1424
+ )
1425
+ ] })
1426
+ ] }),
1427
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "mt-3 d-flex justify-content-end", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
1428
+ import_react_bootstrap17.Button,
1429
+ {
1430
+ variant: "primary",
1431
+ size: "sm",
1432
+ onClick: () => setIsExpanded(false),
1433
+ children: "Aplicar"
1434
+ }
1435
+ ) })
1436
+ ] })
1437
+ ] });
1438
+ };
1439
+
1440
+ // src/filters/AdvancedFilterBar.tsx
1441
+ var import_react12 = require("react");
1442
+ var import_react_bootstrap18 = require("react-bootstrap");
1443
+ var import_fi2 = require("react-icons/fi");
1444
+ var import_jsx_runtime29 = require("react/jsx-runtime");
1445
+ var AdvancedFilterBar = ({
1446
+ children,
1447
+ title = "Filtros e Busca",
1448
+ activeFiltersCount = 0,
1449
+ onClearAll,
1450
+ defaultExpanded = false,
1451
+ className = ""
1452
+ }) => {
1453
+ const [expanded, setExpanded] = (0, import_react12.useState)(defaultExpanded);
1454
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: `advanced-filter-bar ${className}`, children: [
1455
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
1456
+ "div",
1457
+ {
1458
+ className: "filter-bar-header",
1459
+ onClick: () => setExpanded(!expanded),
1460
+ children: [
1461
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "filter-title-group", children: [
1462
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_fi2.FiFilter, { className: "text-primary" }),
1463
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("h5", { className: "filter-title", children: title }),
1464
+ activeFiltersCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("span", { className: "filter-count-badge", children: [
1465
+ activeFiltersCount,
1466
+ " ativos"
1467
+ ] })
1468
+ ] }),
1469
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "filter-chevron", children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_fi2.FiChevronUp, { size: 20 }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_fi2.FiChevronDown, { size: 20 }) })
1470
+ ]
1471
+ }
1472
+ ),
1473
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react_bootstrap18.Collapse, { in: expanded, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "filter-bar-content", children: [
1474
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "filter-grid", children }),
1475
+ (onClearAll || activeFiltersCount > 0) && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "filter-actions", children: [
1476
+ onClearAll && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
1477
+ import_react_bootstrap18.Button,
1478
+ {
1479
+ variant: "link",
1480
+ className: "text-danger text-decoration-none btn-sm d-flex align-items-center",
1481
+ onClick: (e) => {
1482
+ e.stopPropagation();
1483
+ onClearAll();
1484
+ },
1485
+ children: [
1486
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_fi2.FiTrash2, { className: "me-1" }),
1487
+ "Limpar Filtros"
1488
+ ]
1489
+ }
1490
+ ),
1491
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
1492
+ import_react_bootstrap18.Button,
1493
+ {
1494
+ variant: "primary",
1495
+ size: "sm",
1496
+ onClick: () => setExpanded(false),
1497
+ children: "Aplicar Filtros"
1498
+ }
1499
+ )
1500
+ ] })
1501
+ ] }) }) })
1502
+ ] });
1503
+ };
1504
+
1505
+ // src/filters/UnifiedPeriodSelector.tsx
1506
+ var import_react13 = require("react");
1507
+ var import_react_bootstrap19 = require("react-bootstrap");
1508
+ var import_fa4 = require("react-icons/fa");
1509
+ var import_dayjs4 = __toESM(require("dayjs"));
1510
+ var import_isoWeek = __toESM(require("dayjs/plugin/isoWeek"));
1511
+ var import_jsx_runtime30 = require("react/jsx-runtime");
1512
+ import_dayjs4.default.extend(import_isoWeek.default);
1513
+ var MONTHS = [
1514
+ "Jan",
1515
+ "Fev",
1516
+ "Mar",
1517
+ "Abr",
1518
+ "Mai",
1519
+ "Jun",
1520
+ "Jul",
1521
+ "Ago",
1522
+ "Set",
1523
+ "Out",
1524
+ "Nov",
1525
+ "Dez"
1526
+ ];
1527
+ var MONTHS_FULL = [
1528
+ "Janeiro",
1529
+ "Fevereiro",
1530
+ "Mar\xE7o",
1531
+ "Abril",
1532
+ "Maio",
1533
+ "Junho",
1534
+ "Julho",
1535
+ "Agosto",
1536
+ "Setembro",
1537
+ "Outubro",
1538
+ "Novembro",
1539
+ "Dezembro"
1540
+ ];
1541
+ var pad2 = (n) => String(n).padStart(2, "0");
1542
+ var startOfMonthISO = (year, m) => `${year}-${pad2(m + 1)}-01T00:00:00`;
1543
+ var endOfMonthISO = (year, m) => {
1544
+ const lastDay = new Date(year, m + 1, 0).getDate();
1545
+ return `${year}-${pad2(m + 1)}-${pad2(lastDay)}T23:59:59`;
1546
+ };
1547
+ var parseDate = (v) => {
1548
+ if (!v) return null;
1549
+ const d = new Date(v);
1550
+ return isNaN(d.getTime()) ? null : d;
1551
+ };
1552
+ var DEFAULT_PRESETS = [
1553
+ {
1554
+ key: "today",
1555
+ label: "Hoje",
1556
+ start: () => (0, import_dayjs4.default)().startOf("day"),
1557
+ end: () => (0, import_dayjs4.default)().endOf("day")
1558
+ },
1559
+ {
1560
+ key: "week",
1561
+ label: "Esta semana",
1562
+ start: () => (0, import_dayjs4.default)().startOf("isoWeek"),
1563
+ end: () => (0, import_dayjs4.default)().endOf("isoWeek")
1564
+ },
1565
+ {
1566
+ key: "month",
1567
+ label: "Este m\xEAs",
1568
+ start: () => (0, import_dayjs4.default)().startOf("month"),
1569
+ end: () => (0, import_dayjs4.default)().endOf("month")
1570
+ },
1571
+ {
1572
+ key: "year",
1573
+ label: "Este ano",
1574
+ start: () => (0, import_dayjs4.default)().startOf("year"),
1575
+ end: () => (0, import_dayjs4.default)().endOf("year")
1576
+ }
1577
+ ];
1578
+ var TABS = [
1579
+ { key: "quick", icon: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_fa4.FaClock, { size: 12 }), label: "R\xE1pido" },
1580
+ { key: "month", icon: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_fa4.FaCalendarAlt, { size: 12 }), label: "Meses" },
1581
+ { key: "custom", icon: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_fa4.FaCalendarAlt, { size: 12 }), label: "Per\xEDodo" }
1582
+ ];
1583
+ var UnifiedPeriodSelector = ({
1584
+ dataInicio,
1585
+ dataFim,
1586
+ onSelect,
1587
+ defaultTab = "quick",
1588
+ allowFuture = true,
1589
+ quickPresets,
1590
+ className = "",
1591
+ disabled = false,
1592
+ compact = false
1593
+ }) => {
1594
+ const [activeTab, setActiveTab] = (0, import_react13.useState)(defaultTab);
1595
+ const [isExpanded, setIsExpanded] = (0, import_react13.useState)(!compact);
1596
+ const [activePresetKey, setActivePresetKey] = (0, import_react13.useState)(null);
1597
+ const [selectedYear, setSelectedYear] = (0, import_react13.useState)(() => {
1598
+ const d = parseDate(dataInicio);
1599
+ return d ? d.getFullYear() : (/* @__PURE__ */ new Date()).getFullYear();
1600
+ });
1601
+ const [selectedMonths, setSelectedMonths] = (0, import_react13.useState)(/* @__PURE__ */ new Set());
1602
+ const [lastClickedMonth, setLastClickedMonth] = (0, import_react13.useState)(null);
1603
+ const [customStart, setCustomStart] = (0, import_react13.useState)("");
1604
+ const [customEnd, setCustomEnd] = (0, import_react13.useState)("");
1605
+ const presets = quickPresets || DEFAULT_PRESETS;
1606
+ (0, import_react13.useEffect)(() => {
1607
+ const start = parseDate(dataInicio);
1608
+ const end = parseDate(dataFim);
1609
+ if (!start || !end) return;
1610
+ if (start.getFullYear() === selectedYear || end.getFullYear() === selectedYear) {
1611
+ const next = /* @__PURE__ */ new Set();
1612
+ if (start.getFullYear() === end.getFullYear() && start.getFullYear() === selectedYear) {
1613
+ for (let m = start.getMonth(); m <= end.getMonth(); m++) next.add(m);
1614
+ } else {
1615
+ const s = start.getFullYear() === selectedYear ? start.getMonth() : 0;
1616
+ const e = end.getFullYear() === selectedYear ? end.getMonth() : 11;
1617
+ for (let m = s; m <= e; m++) next.add(m);
1618
+ }
1619
+ setSelectedMonths(next);
1620
+ }
1621
+ }, [dataInicio, dataFim, selectedYear]);
1622
+ (0, import_react13.useEffect)(() => {
1623
+ if (dataInicio) setCustomStart((0, import_dayjs4.default)(dataInicio).format("YYYY-MM-DDTHH:mm"));
1624
+ if (dataFim) setCustomEnd((0, import_dayjs4.default)(dataFim).format("YYYY-MM-DDTHH:mm"));
1625
+ }, [dataInicio, dataFim]);
1626
+ const displayLabel = (0, import_react13.useMemo)(() => {
1627
+ const s = parseDate(dataInicio);
1628
+ const e = parseDate(dataFim);
1629
+ if (!s || !e) return "Selecione um per\xEDodo";
1630
+ if (activePresetKey) {
1631
+ const p = presets.find((pr) => pr.key === activePresetKey);
1632
+ if (p) return p.label;
1633
+ }
1634
+ if (s.getFullYear() === e.getFullYear() && s.getMonth() === e.getMonth() && s.getDate() === 1) {
1635
+ return `${MONTHS_FULL[s.getMonth()]} ${s.getFullYear()}`;
1636
+ }
1637
+ return `${(0, import_dayjs4.default)(s).format("DD/MM/YYYY")} \u2013 ${(0, import_dayjs4.default)(e).format("DD/MM/YYYY")}`;
1638
+ }, [dataInicio, dataFim, activePresetKey, presets]);
1639
+ const handlePreset = (0, import_react13.useCallback)(
1640
+ (preset) => {
1641
+ if (disabled) return;
1642
+ setActivePresetKey(preset.key);
1643
+ onSelect({
1644
+ dataInicio: preset.start().toISOString(),
1645
+ dataFim: preset.end().toISOString()
1646
+ });
1647
+ },
1648
+ [disabled, onSelect]
1649
+ );
1650
+ const handleMonthClick = (0, import_react13.useCallback)(
1651
+ (index, event) => {
1652
+ if (disabled) return;
1653
+ const ctrl = event.ctrlKey || event.metaKey;
1654
+ const shift = event.shiftKey;
1655
+ setSelectedMonths((prev) => {
1656
+ let next;
1657
+ if (shift && lastClickedMonth !== null) {
1658
+ next = /* @__PURE__ */ new Set();
1659
+ const start = Math.min(index, lastClickedMonth);
1660
+ const end = Math.max(index, lastClickedMonth);
1661
+ for (let m = start; m <= end; m++) next.add(m);
1662
+ } else if (ctrl) {
1663
+ next = new Set(prev);
1664
+ if (next.has(index)) next.delete(index);
1665
+ else next.add(index);
1666
+ } else {
1667
+ next = /* @__PURE__ */ new Set([index]);
1668
+ }
1669
+ if (next.size === 0) {
1670
+ onSelect({ dataInicio: "", dataFim: "" });
1671
+ } else {
1672
+ const arr = Array.from(next).sort((a, b) => a - b);
1673
+ const first = arr[0];
1674
+ const last = arr[arr.length - 1];
1675
+ onSelect({
1676
+ dataInicio: startOfMonthISO(selectedYear, first),
1677
+ dataFim: endOfMonthISO(selectedYear, last)
1678
+ });
1679
+ }
1680
+ setActivePresetKey(null);
1681
+ return next;
1682
+ });
1683
+ setLastClickedMonth(index);
1684
+ },
1685
+ [disabled, lastClickedMonth, onSelect, selectedYear]
1686
+ );
1687
+ const handleYearChange = (0, import_react13.useCallback)(
1688
+ (delta) => {
1689
+ const newYear = selectedYear + delta;
1690
+ setSelectedYear(newYear);
1691
+ if (selectedMonths.size > 0) {
1692
+ const arr = Array.from(selectedMonths).sort((a, b) => a - b);
1693
+ onSelect({
1694
+ dataInicio: startOfMonthISO(newYear, arr[0]),
1695
+ dataFim: endOfMonthISO(newYear, arr[arr.length - 1])
1696
+ });
1697
+ setActivePresetKey(null);
1698
+ }
1699
+ },
1700
+ [selectedYear, selectedMonths, onSelect]
1701
+ );
1702
+ const quickMonthOptions = (0, import_react13.useMemo)(() => {
1703
+ const now = /* @__PURE__ */ new Date();
1704
+ const opts = [];
1705
+ for (let yearOffset = 0; yearOffset <= 1; yearOffset++) {
1706
+ const year = now.getFullYear() - yearOffset;
1707
+ const lastMonth = yearOffset === 0 ? now.getMonth() : 11;
1708
+ for (let m = lastMonth; m >= 0; m--) {
1709
+ opts.push({
1710
+ value: `${year}-${pad2(m + 1)}`,
1711
+ label: `${MONTHS_FULL[m]} ${year}`,
1712
+ year,
1713
+ month: m
1714
+ });
1715
+ }
1716
+ }
1717
+ return opts;
1718
+ }, []);
1719
+ const quickMonthValue = (0, import_react13.useMemo)(() => {
1720
+ const s = parseDate(dataInicio);
1721
+ const e = parseDate(dataFim);
1722
+ if (!s || !e) return "";
1723
+ if (s.getFullYear() === e.getFullYear() && s.getMonth() === e.getMonth() && s.getDate() === 1) {
1724
+ return `${s.getFullYear()}-${pad2(s.getMonth() + 1)}`;
1725
+ }
1726
+ return "";
1727
+ }, [dataInicio, dataFim]);
1728
+ const handleQuickMonthChange = (0, import_react13.useCallback)(
1729
+ (value) => {
1730
+ if (disabled || !value) return;
1731
+ const opt = quickMonthOptions.find((o) => o.value === value);
1732
+ if (!opt) return;
1733
+ setActivePresetKey(null);
1734
+ setSelectedYear(opt.year);
1735
+ setSelectedMonths(/* @__PURE__ */ new Set([opt.month]));
1736
+ onSelect({
1737
+ dataInicio: startOfMonthISO(opt.year, opt.month),
1738
+ dataFim: endOfMonthISO(opt.year, opt.month)
1739
+ });
1740
+ },
1741
+ [disabled, onSelect, quickMonthOptions]
1742
+ );
1743
+ const handleCustomApply = (0, import_react13.useCallback)(() => {
1744
+ if (!customStart || !customEnd) return;
1745
+ setActivePresetKey(null);
1746
+ onSelect({
1747
+ dataInicio: (0, import_dayjs4.default)(customStart).toISOString(),
1748
+ dataFim: (0, import_dayjs4.default)(customEnd).toISOString()
1749
+ });
1750
+ }, [customStart, customEnd, onSelect]);
1751
+ const handleClear = (0, import_react13.useCallback)(() => {
1752
+ setSelectedMonths(/* @__PURE__ */ new Set());
1753
+ setActivePresetKey(null);
1754
+ setCustomStart("");
1755
+ setCustomEnd("");
1756
+ onSelect({ dataInicio: "", dataFim: "" });
1757
+ }, [onSelect]);
1758
+ const today = /* @__PURE__ */ new Date();
1759
+ const maxDateStr = allowFuture ? void 0 : (0, import_dayjs4.default)().format("YYYY-MM-DDTHH:mm");
1760
+ if (compact && !isExpanded) {
1761
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
1762
+ import_react_bootstrap19.Card,
1763
+ {
1764
+ className: `ups-card ups-card--compact ${className}`,
1765
+ onClick: () => !disabled && setIsExpanded(true),
1766
+ role: "button",
1767
+ tabIndex: 0,
1768
+ children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "ups-compact-row", children: [
1769
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_fa4.FaCalendarAlt, { className: "text-primary me-2" }),
1770
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "ups-display-label", children: displayLabel }),
1771
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "ups-edit-hint text-muted small", children: "Editar" })
1772
+ ] })
1773
+ }
1774
+ );
1775
+ }
1776
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_react_bootstrap19.Card, { className: `ups-card ${className}`, children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_react_bootstrap19.Card.Body, { className: "ups-body", children: [
1777
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "ups-header", children: [
1778
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "d-flex align-items-center gap-2 flex-grow-1 min-w-0", children: [
1779
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_fa4.FaCalendarAlt, { className: "text-primary flex-shrink-0" }),
1780
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "ups-display-label text-truncate", children: displayLabel })
1781
+ ] }),
1782
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "d-flex align-items-center gap-1", children: [
1783
+ (dataInicio || dataFim) && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
1784
+ import_react_bootstrap19.Button,
1785
+ {
1786
+ variant: "link",
1787
+ size: "sm",
1788
+ className: "p-0 text-muted",
1789
+ onClick: handleClear,
1790
+ title: "Limpar per\xEDodo",
1791
+ disabled,
1792
+ children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_fa4.FaTimesCircle, { size: 14 })
1793
+ }
1794
+ ),
1795
+ compact && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
1796
+ import_react_bootstrap19.Button,
1797
+ {
1798
+ variant: "link",
1799
+ size: "sm",
1800
+ className: "p-0 text-muted",
1801
+ onClick: () => setIsExpanded(false),
1802
+ children: "Fechar"
1803
+ }
1804
+ )
1805
+ ] })
1806
+ ] }),
1807
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "ups-tabs", children: TABS.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
1808
+ "button",
1809
+ {
1810
+ className: `ups-tab ${activeTab === tab.key ? "ups-tab--active" : ""}`,
1811
+ onClick: () => setActiveTab(tab.key),
1812
+ disabled,
1813
+ children: [
1814
+ tab.icon,
1815
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { children: tab.label })
1816
+ ]
1817
+ },
1818
+ tab.key
1819
+ )) }),
1820
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "ups-content", children: [
1821
+ activeTab === "quick" && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_jsx_runtime30.Fragment, { children: [
1822
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "ups-quick-grid", children: presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
1823
+ import_react_bootstrap19.Button,
1824
+ {
1825
+ size: "sm",
1826
+ variant: activePresetKey === p.key ? "primary" : "outline-secondary",
1827
+ className: "ups-quick-btn",
1828
+ onClick: () => handlePreset(p),
1829
+ disabled,
1830
+ children: p.label
1831
+ },
1832
+ p.key
1833
+ )) }),
1834
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "ups-quick-month", children: [
1835
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_react_bootstrap19.Form.Label, { className: "small text-muted mb-1", children: "M\xEAs exato" }),
1836
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
1837
+ import_react_bootstrap19.Form.Select,
1838
+ {
1839
+ size: "sm",
1840
+ value: quickMonthValue,
1841
+ onChange: (e) => handleQuickMonthChange(e.target.value),
1842
+ disabled,
1843
+ "aria-label": "Selecionar m\xEAs exato",
1844
+ children: [
1845
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("option", { value: "", children: "Escolha um m\xEAs\u2026" }),
1846
+ quickMonthOptions.map((o) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("option", { value: o.value, children: o.label }, o.value))
1847
+ ]
1848
+ }
1849
+ )
1850
+ ] })
1851
+ ] }),
1852
+ activeTab === "month" && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "ups-month-section", children: [
1853
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "ups-year-nav", children: [
1854
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
1855
+ import_react_bootstrap19.Button,
1856
+ {
1857
+ variant: "outline-secondary",
1858
+ size: "sm",
1859
+ className: "ups-year-btn",
1860
+ onClick: () => handleYearChange(-1),
1861
+ disabled,
1862
+ children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_fa4.FaChevronLeft, { size: 10 })
1863
+ }
1864
+ ),
1865
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "ups-year-label", children: selectedYear }),
1866
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
1867
+ import_react_bootstrap19.Button,
1868
+ {
1869
+ variant: "outline-secondary",
1870
+ size: "sm",
1871
+ className: "ups-year-btn",
1872
+ onClick: () => handleYearChange(1),
1873
+ disabled,
1874
+ children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_fa4.FaChevronRight, { size: 10 })
1875
+ }
1876
+ )
1877
+ ] }),
1878
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "ups-month-grid", children: MONTHS.map((label, idx) => {
1879
+ const isSelected = selectedMonths.has(idx);
1880
+ const isCurrent = today.getFullYear() === selectedYear && today.getMonth() === idx;
1881
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
1882
+ "button",
1883
+ {
1884
+ className: [
1885
+ "ups-month-cell",
1886
+ isSelected && "ups-month-cell--selected",
1887
+ isCurrent && !isSelected && "ups-month-cell--current"
1888
+ ].filter(Boolean).join(" "),
1889
+ onClick: (e) => handleMonthClick(idx, e),
1890
+ disabled,
1891
+ title: "Clique: selecionar \xB7 Shift: range \xB7 Ctrl/Cmd: multi",
1892
+ children: label
1893
+ },
1894
+ idx
1895
+ );
1896
+ }) }),
1897
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "ups-month-hint text-muted", children: "Shift+clique para range \xB7 Ctrl/Cmd+clique para multi-sele\xE7\xE3o" })
1898
+ ] }),
1899
+ activeTab === "custom" && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "ups-custom-section", children: [
1900
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_react_bootstrap19.Row, { className: "g-2", children: [
1901
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_react_bootstrap19.Col, { xs: 12, sm: 6, children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_react_bootstrap19.Form.Group, { children: [
1902
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_react_bootstrap19.Form.Label, { className: "small text-muted mb-1", children: "In\xEDcio" }),
1903
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
1904
+ import_react_bootstrap19.Form.Control,
1905
+ {
1906
+ type: "datetime-local",
1907
+ size: "sm",
1908
+ value: customStart,
1909
+ max: maxDateStr,
1910
+ onChange: (e) => setCustomStart(e.target.value),
1911
+ disabled
1912
+ }
1913
+ )
1914
+ ] }) }),
1915
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_react_bootstrap19.Col, { xs: 12, sm: 6, children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_react_bootstrap19.Form.Group, { children: [
1916
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_react_bootstrap19.Form.Label, { className: "small text-muted mb-1", children: "Fim" }),
1917
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
1918
+ import_react_bootstrap19.Form.Control,
1919
+ {
1920
+ type: "datetime-local",
1921
+ size: "sm",
1922
+ value: customEnd,
1923
+ min: customStart,
1924
+ max: maxDateStr,
1925
+ onChange: (e) => setCustomEnd(e.target.value),
1926
+ disabled
1927
+ }
1928
+ )
1929
+ ] }) })
1930
+ ] }),
1931
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "d-flex justify-content-end mt-2", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
1932
+ import_react_bootstrap19.Button,
1933
+ {
1934
+ variant: "primary",
1935
+ size: "sm",
1936
+ onClick: handleCustomApply,
1937
+ disabled: disabled || !customStart || !customEnd,
1938
+ children: "Aplicar"
1939
+ }
1940
+ ) })
1941
+ ] })
1942
+ ] })
1943
+ ] }) });
1944
+ };
1945
+
1946
+ // src/forms/MailSender.tsx
1947
+ var import_react14 = require("react");
1948
+ var import_react_bootstrap20 = require("react-bootstrap");
1949
+ var import_fi3 = require("react-icons/fi");
1950
+ var import_jsx_runtime31 = require("react/jsx-runtime");
1951
+ var MailSender = ({
1952
+ htmlContent,
1953
+ companyName,
1954
+ onFetchEmails,
1955
+ onSendEmail,
1956
+ hide = false,
1957
+ renderTrigger
1958
+ }) => {
1959
+ const [opened, setOpened] = (0, import_react14.useState)(false);
1960
+ const [addingEmail, setAddingEmail] = (0, import_react14.useState)(false);
1961
+ const [selectedEmails, setSelectedEmails] = (0, import_react14.useState)([]);
1962
+ const [emails, setEmails] = (0, import_react14.useState)([]);
1963
+ const [loading, setLoading] = (0, import_react14.useState)(false);
1964
+ const [postLoading, setPostLoading] = (0, import_react14.useState)(false);
1965
+ const [customEmail, setCustomEmail] = (0, import_react14.useState)("");
1966
+ const [emailError, setEmailError] = (0, import_react14.useState)("");
1967
+ const [searchFilter, setSearchFilter] = (0, import_react14.useState)("");
1968
+ const handleOpen = async () => {
1969
+ setLoading(true);
1970
+ try {
1971
+ const data = await onFetchEmails();
1972
+ setEmails(data || []);
1973
+ setOpened(true);
1974
+ } catch (err) {
1975
+ console.error("Erro ao buscar e-mails:", err);
1976
+ } finally {
1977
+ setLoading(false);
1978
+ }
1979
+ };
1980
+ const mailListLinter = () => {
1981
+ const result = [];
1982
+ const seen = /* @__PURE__ */ new Set();
1983
+ if (emails) {
1984
+ for (const item of emails) {
1985
+ if (item.email && !seen.has(item.email)) {
1986
+ seen.add(item.email);
1987
+ result.push({ email: item.email });
1988
+ }
1989
+ }
1990
+ }
1991
+ return result;
1992
+ };
1993
+ const filteredEmails = emails ? mailListLinter().filter(
1994
+ (email) => email.email.toLowerCase().includes(searchFilter.toLowerCase()) && !selectedEmails.some((selected) => (selected.email || selected) === email.email)
1995
+ ) : [];
1996
+ const sendEmail = async () => {
1997
+ const emailString = selectedEmails.map((email) => email.email ? email.email : email).join(", ");
1998
+ const emailData = {
1999
+ to: emailString,
2000
+ subject: `Relat\xF3rio - ${companyName}`,
2001
+ text: `Relat\xF3rio de processo da empresa ${companyName}`,
2002
+ html: htmlContent
2003
+ };
2004
+ setPostLoading(true);
2005
+ try {
2006
+ await onSendEmail(emailData);
2007
+ setSelectedEmails([]);
2008
+ setCustomEmail("");
2009
+ setOpened(false);
2010
+ } catch (err) {
2011
+ console.error("Erro ao enviar e-mail:", err);
2012
+ } finally {
2013
+ setPostLoading(false);
2014
+ }
2015
+ };
2016
+ const validateEmail = (email) => {
2017
+ const re = /\S+@\S+\.\S+/;
2018
+ return re.test(email);
2019
+ };
2020
+ const handleEmailAdd = () => {
2021
+ if (!customEmail.trim()) {
2022
+ setEmailError("Por favor, digite um e-mail");
2023
+ return;
2024
+ }
2025
+ if (!validateEmail(customEmail)) {
2026
+ setEmailError("Formato de e-mail inv\xE1lido");
2027
+ return;
2028
+ }
2029
+ if (selectedEmails.some((email) => (email.email || email) === customEmail)) {
2030
+ setEmailError("Este e-mail j\xE1 foi selecionado");
2031
+ return;
2032
+ }
2033
+ setSelectedEmails([...selectedEmails, customEmail]);
2034
+ setCustomEmail("");
2035
+ setEmailError("");
2036
+ setAddingEmail(false);
2037
+ };
2038
+ const handleEmailRemove = (emailToRemove) => {
2039
+ setSelectedEmails(
2040
+ selectedEmails.filter(
2041
+ (email) => (email.email || email) !== (emailToRemove.email || emailToRemove)
2042
+ )
2043
+ );
2044
+ };
2045
+ if (hide) return null;
2046
+ if (!opened) {
2047
+ if (renderTrigger) {
2048
+ return renderTrigger({ onClick: handleOpen, loading });
2049
+ }
2050
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react_bootstrap20.Button, { disabled: loading, className: "w-100", onClick: handleOpen, children: loading ? "Carregando..." : "Enviar por E-mail" });
2051
+ }
2052
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
2053
+ "div",
2054
+ {
2055
+ style: {
2056
+ backgroundColor: "#f8f9fa",
2057
+ borderRadius: "12px",
2058
+ overflow: "hidden",
2059
+ border: "1px solid #dee2e6",
2060
+ boxShadow: "0 4px 6px rgba(0, 0, 0, 0.1)"
2061
+ },
2062
+ children: [
2063
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2064
+ "div",
2065
+ {
2066
+ style: {
2067
+ background: "linear-gradient(135deg, #28a745 0%, #20c997 100%)",
2068
+ color: "white",
2069
+ padding: "25px"
2070
+ },
2071
+ children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "d-flex justify-content-between align-items-center", children: [
2072
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { children: [
2073
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("h4", { className: "mb-1", style: { fontWeight: "600", fontSize: "22px" }, children: [
2074
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_fi3.FiMail, { className: "me-2", size: 20 }),
2075
+ "Enviar Relat\xF3rio por E-mail"
2076
+ ] }),
2077
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("small", { style: { opacity: "0.9", fontSize: "14px" }, children: [
2078
+ "Selecione os destinat\xE1rios para envio do relat\xF3rio de ",
2079
+ companyName
2080
+ ] })
2081
+ ] }),
2082
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "d-flex gap-2", children: [
2083
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2084
+ import_react_bootstrap20.Button,
2085
+ {
2086
+ variant: "light",
2087
+ onClick: sendEmail,
2088
+ disabled: selectedEmails.length === 0 || postLoading,
2089
+ style: {
2090
+ borderRadius: "8px",
2091
+ fontWeight: "600",
2092
+ minWidth: "130px",
2093
+ height: "40px"
2094
+ },
2095
+ children: postLoading ? /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
2096
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react_bootstrap20.Spinner, { size: "sm", className: "me-2" }),
2097
+ "Enviando..."
2098
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
2099
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_fi3.FiSend, { className: "me-2", size: 14 }),
2100
+ "Enviar E-mail"
2101
+ ] })
2102
+ }
2103
+ ),
2104
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2105
+ import_react_bootstrap20.Button,
2106
+ {
2107
+ variant: "outline-light",
2108
+ onClick: () => setOpened(false),
2109
+ disabled: postLoading,
2110
+ style: { borderRadius: "8px", width: "40px", height: "40px" },
2111
+ children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_fi3.FiX, { size: 16 })
2112
+ }
2113
+ )
2114
+ ] })
2115
+ ] })
2116
+ }
2117
+ ),
2118
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { style: { padding: "25px" }, children: [
2119
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react_bootstrap20.Card, { className: "mb-4", style: { border: "none", boxShadow: "0 2px 8px rgba(0,0,0,0.05)" }, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_react_bootstrap20.Card.Body, { style: { padding: "20px" }, children: [
2120
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_react_bootstrap20.Row, { className: "align-items-center", children: [
2121
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_react_bootstrap20.Col, { md: 6, children: [
2122
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("h6", { className: "mb-2", style: { color: "#495057", fontWeight: "600" }, children: "\u{1F527} Filtros e A\xE7\xF5es" }),
2123
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_react_bootstrap20.InputGroup, { style: { maxWidth: "300px" }, children: [
2124
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react_bootstrap20.InputGroup.Text, { style: { backgroundColor: "#f8f9fa", border: "1px solid #dee2e6" }, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_fi3.FiSearch, { size: 14, color: "#6c757d" }) }),
2125
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2126
+ import_react_bootstrap20.Form.Control,
2127
+ {
2128
+ type: "text",
2129
+ placeholder: "Buscar e-mails...",
2130
+ value: searchFilter,
2131
+ onChange: (e) => setSearchFilter(e.target.value),
2132
+ style: { border: "1px solid #dee2e6" }
2133
+ }
2134
+ )
2135
+ ] })
2136
+ ] }),
2137
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react_bootstrap20.Col, { md: 6, className: "text-end", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2138
+ import_react_bootstrap20.Button,
2139
+ {
2140
+ variant: addingEmail ? "outline-secondary" : "outline-primary",
2141
+ size: "sm",
2142
+ onClick: () => setAddingEmail(!addingEmail),
2143
+ disabled: postLoading,
2144
+ style: { borderRadius: "8px" },
2145
+ children: addingEmail ? /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
2146
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_fi3.FiX, { className: "me-1", size: 14 }),
2147
+ "Cancelar"
2148
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
2149
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_fi3.FiPlus, { className: "me-1", size: 14 }),
2150
+ "E-mail Personalizado"
2151
+ ] })
2152
+ }
2153
+ ) })
2154
+ ] }),
2155
+ addingEmail && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
2156
+ "div",
2157
+ {
2158
+ style: {
2159
+ marginTop: "20px",
2160
+ padding: "20px",
2161
+ backgroundColor: "#f8f9ff",
2162
+ borderRadius: "8px",
2163
+ border: "1px solid #e3f2fd"
2164
+ },
2165
+ children: [
2166
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("h6", { className: "mb-3", style: { color: "#1976d2", fontWeight: "600" }, children: "\u2709\uFE0F Adicionar E-mail Personalizado" }),
2167
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_react_bootstrap20.Row, { className: "align-items-end", children: [
2168
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_react_bootstrap20.Col, { md: 8, children: [
2169
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react_bootstrap20.Form.Label, { style: { fontSize: "13px", color: "#6c757d", fontWeight: "500" }, children: "Endere\xE7o de E-mail" }),
2170
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2171
+ import_react_bootstrap20.Form.Control,
2172
+ {
2173
+ type: "email",
2174
+ placeholder: "exemplo@empresa.com",
2175
+ value: customEmail,
2176
+ onChange: (e) => {
2177
+ setCustomEmail(e.target.value);
2178
+ if (emailError) setEmailError("");
2179
+ },
2180
+ isInvalid: !!emailError,
2181
+ disabled: postLoading,
2182
+ style: { borderRadius: "8px" },
2183
+ onKeyPress: (e) => e.key === "Enter" && handleEmailAdd()
2184
+ }
2185
+ ),
2186
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react_bootstrap20.Form.Control.Feedback, { type: "invalid", children: emailError })
2187
+ ] }),
2188
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react_bootstrap20.Col, { md: 4, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
2189
+ import_react_bootstrap20.Button,
2190
+ {
2191
+ variant: "success",
2192
+ onClick: handleEmailAdd,
2193
+ disabled: postLoading,
2194
+ style: { borderRadius: "8px", width: "100%" },
2195
+ children: [
2196
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_fi3.FiPlus, { className: "me-1", size: 14 }),
2197
+ "Adicionar"
2198
+ ]
2199
+ }
2200
+ ) })
2201
+ ] })
2202
+ ]
2203
+ }
2204
+ )
2205
+ ] }) }),
2206
+ selectedEmails.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react_bootstrap20.Card, { className: "mb-4", style: { border: "none", boxShadow: "0 2px 8px rgba(0,0,0,0.05)" }, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_react_bootstrap20.Card.Body, { style: { padding: "20px" }, children: [
2207
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "d-flex justify-content-between align-items-center mb-3", children: [
2208
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("h6", { className: "mb-0", style: { color: "#495057", fontWeight: "600" }, children: "\u{1F4CB} Destinat\xE1rios Selecionados" }),
2209
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_react_bootstrap20.Badge, { bg: "primary", style: { fontSize: "12px", padding: "6px 12px" }, children: [
2210
+ selectedEmails.length,
2211
+ " selecionado",
2212
+ selectedEmails.length > 1 ? "s" : ""
2213
+ ] })
2214
+ ] }),
2215
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "d-flex flex-wrap gap-2", children: selectedEmails.map((email, index) => /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
2216
+ "div",
2217
+ {
2218
+ style: {
2219
+ background: "linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%)",
2220
+ border: "1px solid #bbdefb",
2221
+ borderRadius: "20px",
2222
+ padding: "8px 15px",
2223
+ display: "flex",
2224
+ alignItems: "center",
2225
+ fontSize: "14px",
2226
+ fontWeight: "500"
2227
+ },
2228
+ children: [
2229
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_fi3.FiUser, { size: 12, className: "me-2", color: "#1976d2" }),
2230
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { children: email.email || email }),
2231
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2232
+ import_react_bootstrap20.Button,
2233
+ {
2234
+ variant: "link",
2235
+ size: "sm",
2236
+ onClick: () => handleEmailRemove(email),
2237
+ disabled: postLoading,
2238
+ style: {
2239
+ padding: "0 0 0 8px",
2240
+ color: "#dc3545",
2241
+ textDecoration: "none",
2242
+ fontSize: "16px"
2243
+ },
2244
+ children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_fi3.FiX, { size: 14 })
2245
+ }
2246
+ )
2247
+ ]
2248
+ },
2249
+ index
2250
+ )) })
2251
+ ] }) }),
2252
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react_bootstrap20.Card, { style: { border: "none", boxShadow: "0 2px 8px rgba(0,0,0,0.05)" }, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_react_bootstrap20.Card.Body, { style: { padding: "20px" }, children: [
2253
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("h6", { className: "mb-3", style: { color: "#495057", fontWeight: "600" }, children: [
2254
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_fi3.FiUser, { className: "me-2", size: 16 }),
2255
+ "E-mails de ",
2256
+ companyName
2257
+ ] }),
2258
+ loading ? /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "text-center py-4", children: [
2259
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react_bootstrap20.Spinner, {}),
2260
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { className: "mt-2 text-muted", children: "Carregando e-mails..." })
2261
+ ] }) : filteredEmails.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "text-center py-4", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { className: "text-muted mb-0", children: searchFilter ? "Nenhum e-mail encontrado com esse filtro" : "Nenhum e-mail dispon\xEDvel" }) }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react_bootstrap20.Row, { children: filteredEmails.map((email) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react_bootstrap20.Col, { xs: 12, sm: 6, lg: 4, className: "mb-3", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2262
+ import_react_bootstrap20.Card,
2263
+ {
2264
+ onClick: () => setSelectedEmails([...selectedEmails, email]),
2265
+ style: {
2266
+ cursor: "pointer",
2267
+ border: "1px solid #e9ecef",
2268
+ borderRadius: "10px",
2269
+ transition: "all 0.2s ease",
2270
+ backgroundColor: "#fff"
2271
+ },
2272
+ onMouseEnter: (e) => {
2273
+ e.currentTarget.style.transform = "translateY(-2px)";
2274
+ e.currentTarget.style.boxShadow = "0 4px 12px rgba(0,0,0,0.1)";
2275
+ e.currentTarget.style.borderColor = "#007bff";
2276
+ },
2277
+ onMouseLeave: (e) => {
2278
+ e.currentTarget.style.transform = "translateY(0)";
2279
+ e.currentTarget.style.boxShadow = "none";
2280
+ e.currentTarget.style.borderColor = "#e9ecef";
2281
+ },
2282
+ children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_react_bootstrap20.Card.Body, { style: { padding: "15px", textAlign: "center" }, children: [
2283
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_fi3.FiMail, { size: 20, color: "#007bff", className: "mb-2" }),
2284
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2285
+ "div",
2286
+ {
2287
+ style: {
2288
+ fontSize: "14px",
2289
+ fontWeight: "500",
2290
+ color: "#2c3e50",
2291
+ wordBreak: "break-word"
2292
+ },
2293
+ children: email.email
2294
+ }
2295
+ )
2296
+ ] })
2297
+ }
2298
+ ) }, email.email)) })
2299
+ ] }) })
2300
+ ] })
2301
+ ]
2302
+ }
2303
+ );
2304
+ };
2305
+
2306
+ // src/forms/AutoComplete.tsx
2307
+ var import_react15 = require("react");
2308
+ var import_react_bootstrap21 = require("react-bootstrap");
2309
+ var import_jsx_runtime32 = require("react/jsx-runtime");
2310
+ var AutoComplete = ({
2311
+ className,
2312
+ ops = [],
2313
+ sortKey,
2314
+ displayKey,
2315
+ displayKeys,
2316
+ onValueChanged,
2317
+ onSelectedClick,
2318
+ value,
2319
+ actionButton,
2320
+ actionButton2,
2321
+ placeH,
2322
+ title,
2323
+ filter,
2324
+ filterField,
2325
+ loadFunc,
2326
+ loadCondition,
2327
+ onBlurEvent,
2328
+ formatationFunc,
2329
+ onEscKeyDown,
2330
+ onEnterKeyDown,
2331
+ margT,
2332
+ margB,
2333
+ hideComponent,
2334
+ disableComponent = false,
2335
+ disableSelect = false,
2336
+ autoFocusConfig,
2337
+ onLoad,
2338
+ cacheKey,
2339
+ minChars = 0,
2340
+ maxItems,
2341
+ showListOnFocus = true,
2342
+ lazyLoad = false,
2343
+ labelPosition = "top"
2344
+ }) => {
2345
+ const [liItem, setListItem] = (0, import_react15.useState)([]);
2346
+ const [options, setOptions] = (0, import_react15.useState)([]);
2347
+ const [input, setInput] = (0, import_react15.useState)("");
2348
+ const [hide, setHide] = (0, import_react15.useState)(true);
2349
+ const [onLoaded, setOnLoaded] = (0, import_react15.useState)(false);
2350
+ const [loading, setLoading] = (0, import_react15.useState)(false);
2351
+ const cacheStore = (0, import_react15.useMemo)(() => {
2352
+ const win = window;
2353
+ if (!win.__AUTO_COMPLETE_CACHE__) {
2354
+ win.__AUTO_COMPLETE_CACHE__ = /* @__PURE__ */ new Map();
2355
+ }
2356
+ return win.__AUTO_COMPLETE_CACHE__;
2357
+ }, []);
2358
+ const sortOptions = (data, key) => {
2359
+ if (!key || !Array.isArray(data)) return data;
2360
+ return [...data].sort((a, b) => String(a[key]).localeCompare(String(b[key])));
2361
+ };
2362
+ (0, import_react15.useEffect)(() => {
2363
+ setInput(value || "");
2364
+ }, [value]);
2365
+ (0, import_react15.useEffect)(() => {
2366
+ if (!Array.isArray(ops) || ops.length === 0) return;
2367
+ const sortedOptions = sortOptions(ops, sortKey);
2368
+ setListItem(sortedOptions);
2369
+ setOptions(sortedOptions);
2370
+ }, [ops, sortKey]);
2371
+ (0, import_react15.useEffect)(() => {
2372
+ const loadData = async () => {
2373
+ if (!(loadCondition && loadFunc)) return;
2374
+ if (lazyLoad && minChars > 0 && !showListOnFocus && (!value || String(value).length < minChars)) {
2375
+ return;
2376
+ }
2377
+ const key = cacheKey ? `${cacheKey}${filter ? `:${filterField}:${filter}` : ""}` : null;
2378
+ if (key && cacheStore.has(key)) {
2379
+ const cacheEntry = cacheStore.get(key);
2380
+ const data = cacheEntry.promise ? await cacheEntry.promise : cacheEntry.data || cacheEntry;
2381
+ setListItem(data);
2382
+ setOptions(data);
2383
+ triggerOnLoad(data);
2384
+ return;
2385
+ }
2386
+ setLoading(true);
2387
+ try {
2388
+ const requestPromise = loadFunc().then((res) => {
2389
+ let newOps = (res == null ? void 0 : res.content) || res;
2390
+ newOps = Array.isArray(newOps) ? newOps.filter((op) => op != null) : [];
2391
+ if (filter && filterField) {
2392
+ newOps = newOps.filter((op) => op[filterField] === filter);
2393
+ }
2394
+ return sortOptions(newOps, sortKey);
2395
+ });
2396
+ if (key) cacheStore.set(key, { promise: requestPromise });
2397
+ const sortedOptions = await requestPromise;
2398
+ setListItem(sortedOptions);
2399
+ setOptions(sortedOptions);
2400
+ if (key) cacheStore.set(key, { data: sortedOptions });
2401
+ triggerOnLoad(sortedOptions);
2402
+ } catch (error) {
2403
+ if (key) cacheStore.delete(key);
2404
+ setListItem([]);
2405
+ } finally {
2406
+ setLoading(false);
2407
+ }
2408
+ };
2409
+ loadData();
2410
+ }, [loadCondition, filter, filterField, sortKey, cacheKey, lazyLoad, minChars, showListOnFocus]);
2411
+ const triggerOnLoad = (data) => {
2412
+ if (onLoad && !onLoaded) {
2413
+ setOnLoaded(true);
2414
+ onLoad(data);
2415
+ }
2416
+ };
2417
+ const keysJoinner = (li) => {
2418
+ if (!displayKeys || !Array.isArray(displayKeys)) return "";
2419
+ return displayKeys.map((key) => `${li[key]} `).join("").trim();
2420
+ };
2421
+ const getDisplayText = (item) => {
2422
+ if (formatationFunc) return formatationFunc(item);
2423
+ if (displayKey) return item[displayKey];
2424
+ if (displayKeys) return keysJoinner(item);
2425
+ return String(item);
2426
+ };
2427
+ const onFieldUpdate = (val) => {
2428
+ const search = val.toLowerCase();
2429
+ const canSearch = search.length >= minChars;
2430
+ if (canSearch && Array.isArray(options)) {
2431
+ const filtered = options.filter((item) => {
2432
+ const text = getDisplayText(item);
2433
+ return String(text).toLowerCase().includes(search);
2434
+ });
2435
+ setListItem(filtered);
2436
+ } else {
2437
+ setListItem(options || []);
2438
+ }
2439
+ onValueChanged == null ? void 0 : onValueChanged(val);
2440
+ setInput(val);
2441
+ setHide(!canSearch && options.length === 0);
2442
+ };
2443
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
2444
+ "div",
2445
+ {
2446
+ className,
2447
+ style: { marginTop: margT != null ? margT : 4, marginBottom: margB != null ? margB : 4, position: "relative" },
2448
+ onBlur: (e) => {
2449
+ setTimeout(() => {
2450
+ onBlurEvent == null ? void 0 : onBlurEvent(e, input);
2451
+ setHide(true);
2452
+ }, 200);
2453
+ },
2454
+ onKeyDown: (e) => {
2455
+ if (e.key === "Escape") {
2456
+ setHide(true);
2457
+ onEscKeyDown == null ? void 0 : onEscKeyDown();
2458
+ }
2459
+ if (e.key === "Enter" && onEnterKeyDown) {
2460
+ onEnterKeyDown(input);
2461
+ }
2462
+ },
2463
+ onMouseLeave: () => setHide(true),
2464
+ children: [
2465
+ !hideComponent && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
2466
+ labelPosition === "top" && title && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_react_bootstrap21.Form.Label, { className: "fw-semibold small mb-1", children: title }),
2467
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_react_bootstrap21.InputGroup, { children: [
2468
+ labelPosition === "floating" ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_react_bootstrap21.FloatingLabel, { controlId: "floatingInput", label: title, style: { zIndex: 0, flex: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
2469
+ import_react_bootstrap21.Form.Control,
2470
+ {
2471
+ autoFocus: autoFocusConfig,
2472
+ disabled: disableComponent || disableSelect,
2473
+ placeholder: placeH,
2474
+ autoComplete: "off",
2475
+ value: input,
2476
+ onClickCapture: () => {
2477
+ const canOpen = showListOnFocus && input.length >= minChars;
2478
+ setHide(!canOpen);
2479
+ },
2480
+ onChange: (e) => onFieldUpdate(e.currentTarget.value),
2481
+ type: "text"
2482
+ }
2483
+ ) }) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
2484
+ import_react_bootstrap21.Form.Control,
2485
+ {
2486
+ autoFocus: autoFocusConfig,
2487
+ disabled: disableComponent || disableSelect,
2488
+ placeholder: placeH || title,
2489
+ autoComplete: "off",
2490
+ value: input,
2491
+ onClickCapture: () => {
2492
+ const canOpen = showListOnFocus && input.length >= minChars;
2493
+ setHide(!canOpen);
2494
+ },
2495
+ onChange: (e) => onFieldUpdate(e.currentTarget.value),
2496
+ type: "text"
2497
+ }
2498
+ ),
2499
+ loading && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_react_bootstrap21.InputGroup.Text, { children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_react_bootstrap21.Spinner, { animation: "border", size: "sm" }) }),
2500
+ !disableComponent && (actionButton == null ? void 0 : actionButton(() => setInput(""))),
2501
+ !disableComponent && (actionButton2 == null ? void 0 : actionButton2(input))
2502
+ ] })
2503
+ ] }),
2504
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
2505
+ import_react_bootstrap21.ListGroup,
2506
+ {
2507
+ className: "listgroup-autocomplete shadow-sm",
2508
+ hidden: hide || liItem.length === 0,
2509
+ style: {
2510
+ position: "absolute",
2511
+ top: "100%",
2512
+ left: 0,
2513
+ width: "100%",
2514
+ maxHeight: "250px",
2515
+ overflowY: "auto",
2516
+ zIndex: 1050,
2517
+ backgroundColor: "#fff"
2518
+ },
2519
+ children: (maxItems ? liItem.slice(0, maxItems) : liItem).map((li, index) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
2520
+ import_react_bootstrap21.ListGroup.Item,
2521
+ {
2522
+ action: true,
2523
+ onClick: () => {
2524
+ const text = getDisplayText(li);
2525
+ setInput(text);
2526
+ onSelectedClick(li, index, liItem);
2527
+ setHide(true);
2528
+ },
2529
+ children: getDisplayText(li)
2530
+ },
2531
+ index
2532
+ ))
2533
+ }
2534
+ )
2535
+ ]
2536
+ }
2537
+ );
2538
+ };
2539
+
2540
+ // src/forms/GenericForm.tsx
2541
+ var import_react16 = require("react");
2542
+ var import_react_bootstrap22 = require("react-bootstrap");
2543
+ var import_jsx_runtime33 = require("react/jsx-runtime");
2544
+ var GenericForm = ({ fields, onSubmit, renderCustomSelect }) => {
2545
+ const [formValues, setFormValues] = (0, import_react16.useState)({});
2546
+ const [errors, setErrors] = (0, import_react16.useState)({});
2547
+ const handleChange = (key, value) => {
2548
+ setFormValues({
2549
+ ...formValues,
2550
+ [key]: value
2551
+ });
2552
+ };
2553
+ const validate = () => {
2554
+ const newErrors = {};
2555
+ fields.forEach((field) => {
2556
+ if (field.required && !formValues[field.key]) {
2557
+ newErrors[field.key] = `${field.label} \xE9 obrigat\xF3rio`;
2558
+ }
2559
+ });
2560
+ setErrors(newErrors);
2561
+ return Object.keys(newErrors).length === 0;
2562
+ };
2563
+ const handleSubmit = (e) => {
2564
+ e.preventDefault();
2565
+ if (validate()) {
2566
+ onSubmit(formValues);
2567
+ }
2568
+ };
2569
+ const renderField = (field) => {
2570
+ const { label, key, type, options, placeholder } = field;
2571
+ const value = formValues[key] || "";
2572
+ switch (type) {
2573
+ case "text":
2574
+ case "number":
2575
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_react_bootstrap22.Form.Group, { className: "mb-3", children: [
2576
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react_bootstrap22.Form.Label, { children: label }),
2577
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2578
+ import_react_bootstrap22.Form.Control,
2579
+ {
2580
+ type,
2581
+ placeholder,
2582
+ value,
2583
+ onChange: (e) => handleChange(key, e.target.value),
2584
+ isInvalid: !!errors[key]
2585
+ }
2586
+ ),
2587
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react_bootstrap22.Form.Control.Feedback, { type: "invalid", children: errors[key] })
2588
+ ] }, key);
2589
+ case "select": {
2590
+ const orderedOptions = (options || []).filter((opt) => opt && opt.value !== void 0 && opt.label !== void 0).sort((a, b) => a.label.localeCompare(b.label));
2591
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_react_bootstrap22.Form.Group, { className: "mb-3", children: [
2592
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react_bootstrap22.Form.Label, { children: label }),
2593
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
2594
+ import_react_bootstrap22.Form.Select,
2595
+ {
2596
+ value,
2597
+ onChange: (e) => handleChange(key, e.target.value),
2598
+ isInvalid: !!errors[key],
2599
+ children: [
2600
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("option", { value: "", children: "Selecione..." }),
2601
+ orderedOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("option", { value: option.value, children: option.label }, String(option.value)))
2602
+ ]
2603
+ }
2604
+ ),
2605
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react_bootstrap22.Form.Control.Feedback, { type: "invalid", children: errors[key] })
2606
+ ] }, key);
2607
+ }
2608
+ case "custom-select":
2609
+ if (renderCustomSelect) {
2610
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { children: [
2611
+ renderCustomSelect({
2612
+ label,
2613
+ value,
2614
+ options,
2615
+ onChange: (v) => handleChange(key, v),
2616
+ placeholder
2617
+ }),
2618
+ errors[key] && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "invalid-feedback d-block", children: errors[key] })
2619
+ ] }, key);
2620
+ }
2621
+ return null;
2622
+ case "date":
2623
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_react_bootstrap22.Form.Group, { className: "mb-3", children: [
2624
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react_bootstrap22.Form.Label, { children: label }),
2625
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2626
+ import_react_bootstrap22.Form.Control,
2627
+ {
2628
+ type: "date",
2629
+ value,
2630
+ onChange: (e) => handleChange(key, e.target.value),
2631
+ isInvalid: !!errors[key]
2632
+ }
2633
+ ),
2634
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react_bootstrap22.Form.Control.Feedback, { type: "invalid", children: errors[key] })
2635
+ ] }, key);
2636
+ default:
2637
+ return null;
2638
+ }
2639
+ };
2640
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_react_bootstrap22.Form, { onSubmit: handleSubmit, children: [
2641
+ fields.map((field) => renderField(field)),
2642
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "d-grid", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react_bootstrap22.Button, { variant: "primary", type: "submit", children: "Salvar" }) })
2643
+ ] });
2644
+ };
2645
+ var GenericForm_default = GenericForm;
2646
+
2647
+ // src/forms/GenericSelect.tsx
2648
+ var import_react17 = require("react");
2649
+ var import_react_bootstrap23 = require("react-bootstrap");
2650
+ var import_jsx_runtime34 = require("react/jsx-runtime");
2651
+ var GenericSelectOps = class {
2652
+ constructor(noLabel, title, onChange, ops, selection, returnType, displayType, filter, filterField, valueType, loadFunc, loadCondition, actionClick, locked) {
2653
+ this.noLabel = noLabel;
2654
+ this.title = title;
2655
+ this.onChange = onChange;
2656
+ this.ops = ops;
2657
+ this.selection = selection;
2658
+ this.returnType = returnType;
2659
+ this.displayType = displayType;
2660
+ this.filter = filter;
2661
+ this.filterField = filterField;
2662
+ this.valueType = valueType;
2663
+ this.loadFunc = loadFunc;
2664
+ this.loadCondition = loadCondition;
2665
+ this.actionClick = actionClick;
2666
+ this.locked = locked;
2667
+ }
2668
+ };
2669
+ var GenericSelect = ({
2670
+ noLabel,
2671
+ title,
2672
+ onChange,
2673
+ ops,
2674
+ selection,
2675
+ returnType,
2676
+ displayType,
2677
+ filter,
2678
+ filterField,
2679
+ valueType,
2680
+ loadFunc,
2681
+ loadCondition = true,
2682
+ actionClick,
2683
+ locked,
2684
+ isBold,
2685
+ ...restProps
2686
+ }) => {
2687
+ const [options, setOptions] = (0, import_react17.useState)(ops || []);
2688
+ (0, import_react17.useEffect)(() => {
2689
+ const loadFunction = async () => {
2690
+ if (loadCondition && loadFunc) {
2691
+ loadFunc().then((res) => {
2692
+ let newOps = res.content ? res.content : res;
2693
+ if (filter && filterField) {
2694
+ newOps = res.filter((op) => op[filterField] == filter);
2695
+ }
2696
+ setOptions(newOps);
2697
+ });
2698
+ }
2699
+ };
2700
+ loadFunction().catch((error) => console.log(error));
2701
+ }, [loadCondition]);
2702
+ const getTrueValue = (clickedIndex) => {
2703
+ const returnValue = options.filter((_op, index) => index == clickedIndex - 1)[0];
2704
+ if (returnType == "index") {
2705
+ onChange(clickedIndex);
2706
+ } else if (returnType) {
2707
+ onChange(returnValue[returnType]);
2708
+ } else {
2709
+ onChange(returnValue);
2710
+ }
2711
+ };
2712
+ const defaultPlaceholder = (restProps == null ? void 0 : restProps.default) || "Seleciona uma Op\xE7\xE3o";
2713
+ const selectContent = /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
2714
+ import_react_bootstrap23.Form.Control,
2715
+ {
2716
+ disabled: locked,
2717
+ as: "select",
2718
+ value: selection,
2719
+ onChange: (event) => getTrueValue(event.target.selectedIndex),
2720
+ children: [
2721
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("option", { value: void 0, children: [
2722
+ "-- ",
2723
+ defaultPlaceholder,
2724
+ " --"
2725
+ ] }, 0),
2726
+ (options == null ? void 0 : options.length) > 0 && options.map((op, index) => {
2727
+ const val = valueType && op[valueType] || op.id || op;
2728
+ let fill = displayType && op[displayType] || op;
2729
+ if (typeof fill == "object") fill = "";
2730
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("option", { value: val, children: fill }, op.id || index);
2731
+ })
2732
+ ]
2733
+ }
2734
+ );
2735
+ if (actionClick) {
2736
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
2737
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react_bootstrap23.Form.Label, { style: { fontWeight: isBold ? "bold" : void 0 }, hidden: noLabel, children: title }),
2738
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_react_bootstrap23.InputGroup, { children: [
2739
+ selectContent,
2740
+ actionClick()
2741
+ ] })
2742
+ ] });
2743
+ }
2744
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
2745
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react_bootstrap23.Form.Label, { style: { fontWeight: isBold ? "bold" : void 0 }, hidden: noLabel, children: title }),
2746
+ selectContent
2747
+ ] });
2748
+ };
2749
+ var GenericSelect_default = GenericSelect;
2750
+
2751
+ // src/forms/FormField.tsx
2752
+ var import_react_bootstrap24 = require("react-bootstrap");
2753
+ var import_jsx_runtime35 = require("react/jsx-runtime");
2754
+ var FormField = ({
2755
+ val,
2756
+ onValueUpdate,
2757
+ onBlur,
2758
+ label,
2759
+ labelPosition = "top",
2760
+ ty,
2761
+ actionClick,
2762
+ actionClick2,
2763
+ reference,
2764
+ others,
2765
+ styleObj,
2766
+ locked,
2767
+ hide,
2768
+ onMouseLv,
2769
+ onEnterPress,
2770
+ className,
2771
+ isInvalid,
2772
+ feedback,
2773
+ onFocus,
2774
+ rows,
2775
+ asTextArea,
2776
+ controlId
2777
+ }) => {
2778
+ const onKeyDownHandler = (event) => {
2779
+ if (event.code === "Enter" || event.key === "Enter") {
2780
+ onEnterPress && onEnterPress(event.target.value);
2781
+ }
2782
+ };
2783
+ const onFocusHandler = (value) => {
2784
+ onFocus && onFocus(value);
2785
+ };
2786
+ const renderField = () => {
2787
+ const fieldProps = {
2788
+ autoComplete: "off",
2789
+ isInvalid,
2790
+ className,
2791
+ ...others,
2792
+ onBlur: (event) => onBlur && onBlur(event.target.value, event),
2793
+ disabled: locked,
2794
+ style: styleObj,
2795
+ ref: reference,
2796
+ placeholder: (others == null ? void 0 : others.placeholder) || label,
2797
+ type: ty || "text",
2798
+ value: val != null ? val : "",
2799
+ onChange: (event) => onValueUpdate && onValueUpdate(event.target.value, event)
2800
+ };
2801
+ if (asTextArea) {
2802
+ fieldProps.as = "textarea";
2803
+ fieldProps.rows = rows || 3;
2804
+ }
2805
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_react_bootstrap24.Form.Control, { ...fieldProps });
2806
+ };
2807
+ if (hide) return null;
2808
+ const useFloating = labelPosition === "floating" && !asTextArea;
2809
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
2810
+ import_react_bootstrap24.Form.Group,
2811
+ {
2812
+ onFocusCapture: (e) => onFocusHandler(e.target.value),
2813
+ onMouseLeave: onMouseLv,
2814
+ onKeyDown: onKeyDownHandler,
2815
+ style: { marginTop: 4, marginBottom: 4, width: "100%" },
2816
+ controlId: !useFloating ? controlId : void 0,
2817
+ children: [
2818
+ !useFloating && label && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_react_bootstrap24.Form.Label, { className: "fw-semibold small mb-1", children: label }),
2819
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_react_bootstrap24.InputGroup, { children: [
2820
+ useFloating ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_react_bootstrap24.FloatingLabel, { style: { zIndex: 0, flex: 1 }, label, controlId: controlId || "floatingInput", children: renderField() }) : renderField(),
2821
+ actionClick && actionClick(),
2822
+ actionClick2 && actionClick2()
2823
+ ] }),
2824
+ feedback && isInvalid && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_react_bootstrap24.Form.Control.Feedback, { type: "invalid", style: { display: "block" }, children: feedback })
2825
+ ]
2826
+ }
2827
+ );
2828
+ };
2829
+
2830
+ // src/forms/ClickToWriteField.tsx
2831
+ var import_react18 = require("react");
2832
+ var import_react_bootstrap25 = require("react-bootstrap");
2833
+ var import_jsx_runtime36 = require("react/jsx-runtime");
2834
+ var ClickToWriteField = ({
2835
+ buttonDisplay,
2836
+ fieldType = "text",
2837
+ fieldLabel = "",
2838
+ buttonProps,
2839
+ fieldProps,
2840
+ onFieldValueUpdate,
2841
+ enableFieldActionButton = false,
2842
+ fieldActionButtonIcon,
2843
+ fieldActionButtonProps,
2844
+ fieldActionButtonCallback = () => {
2845
+ },
2846
+ onEnterPress,
2847
+ cleanRef
2848
+ }) => {
2849
+ const [showClick, setShowClick] = (0, import_react18.useState)(false);
2850
+ const inputRef = (0, import_react18.useRef)(null);
2851
+ (0, import_react18.useEffect)(() => {
2852
+ if (showClick) {
2853
+ setTimeout(() => {
2854
+ if (inputRef.current) {
2855
+ inputRef.current.focus();
2856
+ cleanRef && cleanRef(inputRef);
2857
+ }
2858
+ }, 100);
2859
+ }
2860
+ }, [showClick, cleanRef]);
2861
+ const handleShowClick = () => {
2862
+ setShowClick(!showClick);
2863
+ };
2864
+ const resolveButtonDisplay = () => {
2865
+ if (typeof buttonDisplay === "function") return buttonDisplay();
2866
+ return buttonDisplay;
2867
+ };
2868
+ const renderFieldActionButtonIcon = () => {
2869
+ if (fieldActionButtonIcon) return fieldActionButtonIcon();
2870
+ return "OK";
2871
+ };
2872
+ const closeOnEscape = (e) => {
2873
+ if (e.key === "Escape") {
2874
+ setShowClick(false);
2875
+ }
2876
+ if (e.key === "Enter" && onEnterPress) {
2877
+ onEnterPress(inputRef);
2878
+ }
2879
+ };
2880
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { style: { display: "flex", width: "100%", margin: 0, padding: 0 }, children: [
2881
+ !showClick && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
2882
+ import_react_bootstrap25.Button,
2883
+ {
2884
+ style: { flexGrow: 1 },
2885
+ onClick: handleShowClick,
2886
+ ...buttonProps,
2887
+ children: resolveButtonDisplay()
2888
+ }
2889
+ ),
2890
+ showClick && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
2891
+ FormField,
2892
+ {
2893
+ reference: inputRef,
2894
+ others: { ...fieldProps, onKeyUp: closeOnEscape },
2895
+ hide: !showClick,
2896
+ ty: fieldType,
2897
+ label: fieldLabel,
2898
+ onValueUpdate: onFieldValueUpdate,
2899
+ onBlur: () => setShowClick(false),
2900
+ actionClick: () => enableFieldActionButton ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
2901
+ import_react_bootstrap25.Button,
2902
+ {
2903
+ ...fieldActionButtonProps,
2904
+ onClick: () => fieldActionButtonCallback(inputRef),
2905
+ children: renderFieldActionButtonIcon()
2906
+ }
2907
+ ) : null
2908
+ }
2909
+ )
2910
+ ] });
2911
+ };
2912
+
2913
+ // src/forms/ColorPicker.tsx
2914
+ var import_react_bootstrap26 = require("react-bootstrap");
2915
+ var import_fa5 = require("react-icons/fa");
2916
+ var import_jsx_runtime37 = require("react/jsx-runtime");
2917
+ var ColorPicker = ({
2918
+ selectedColor,
2919
+ onColorChange,
2920
+ defaultColor,
2921
+ setCor,
2922
+ presetColors = ["#ff0000", "#ffd700", "#008000", "#0000ff", "#800080"],
2923
+ title = "Cor de Identifica\xE7\xE3o"
2924
+ }) => {
2925
+ var _a, _b;
2926
+ const safeSelectedColor = (_b = (_a = selectedColor != null ? selectedColor : defaultColor) != null ? _a : presetColors[0]) != null ? _b : "#000000";
2927
+ const handleColorChange = (color) => {
2928
+ onColorChange == null ? void 0 : onColorChange(color);
2929
+ setCor == null ? void 0 : setCor(color);
2930
+ };
2931
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
2932
+ import_react_bootstrap26.Card,
2933
+ {
2934
+ className: "shadow-sm border-primary-hover mb-3",
2935
+ style: { maxWidth: "320px", transition: "0.3s" },
2936
+ children: [
2937
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_react_bootstrap26.Card.Header, { className: "bg-light d-flex align-items-center", children: [
2938
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_fa5.FaPalette, { className: "me-2 text-primary" }),
2939
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: "fw-medium", children: title })
2940
+ ] }),
2941
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_react_bootstrap26.Card.Body, { children: [
2942
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_react_bootstrap26.Row, { className: "g-3 align-items-center mb-3", children: [
2943
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_react_bootstrap26.Col, { xs: "auto", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
2944
+ "div",
2945
+ {
2946
+ className: "rounded-circle shadow-sm border",
2947
+ style: {
2948
+ width: "40px",
2949
+ height: "40px",
2950
+ backgroundColor: safeSelectedColor,
2951
+ cursor: "pointer",
2952
+ border: "2px solid #dee2e6"
2953
+ },
2954
+ onClick: () => {
2955
+ const el = document.getElementById("color-input-hidden");
2956
+ if (el) el.click();
2957
+ },
2958
+ title: "Clique para abrir o seletor"
2959
+ }
2960
+ ) }),
2961
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_react_bootstrap26.Col, { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
2962
+ import_react_bootstrap26.Form.Control,
2963
+ {
2964
+ type: "color",
2965
+ id: "color-input-hidden",
2966
+ value: safeSelectedColor,
2967
+ onChange: (e) => handleColorChange(e.target.value),
2968
+ className: "form-control-color-lg",
2969
+ style: { width: "100%", height: "40px", cursor: "pointer" }
2970
+ }
2971
+ ) })
2972
+ ] }),
2973
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_react_bootstrap26.Row, { className: "g-2 justify-content-start", children: presetColors.map((cor) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_react_bootstrap26.Col, { xs: "auto", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
2974
+ "div",
2975
+ {
2976
+ className: "rounded-1 shadow-sm",
2977
+ style: {
2978
+ width: "28px",
2979
+ height: "28px",
2980
+ backgroundColor: cor,
2981
+ cursor: "pointer",
2982
+ border: cor.toLowerCase() === safeSelectedColor.toLowerCase() ? "2px solid #0d6efd" : "1px solid #dee2e6"
2983
+ },
2984
+ onClick: () => handleColorChange(cor)
2985
+ }
2986
+ ) }, cor)) })
2987
+ ] })
2988
+ ]
2989
+ }
2990
+ );
2991
+ };
2992
+
2993
+ // src/forms/Switch.tsx
2994
+ var import_react_bootstrap27 = require("react-bootstrap");
2995
+ var import_jsx_runtime38 = require("react/jsx-runtime");
2996
+ var Switch = ({
2997
+ label,
2998
+ onSwitchChange,
2999
+ value,
3000
+ disabled = false,
3001
+ defaultChecked,
3002
+ ...props
3003
+ }) => {
3004
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
3005
+ import_react_bootstrap27.Form.Check,
3006
+ {
3007
+ ...props,
3008
+ disabled,
3009
+ type: "switch",
3010
+ label,
3011
+ checked: value,
3012
+ defaultChecked,
3013
+ onChange: (event) => onSwitchChange && onSwitchChange(event.target.checked)
3014
+ }
3015
+ );
3016
+ };
3017
+
3018
+ // src/forms/UploadArea.tsx
3019
+ var import_react19 = require("react");
3020
+ var import_react_dropzone = require("react-dropzone");
3021
+ var import_fi4 = require("react-icons/fi");
3022
+ var import_jsx_runtime39 = require("react/jsx-runtime");
3023
+ var UploadArea = ({
3024
+ onFilePut,
3025
+ anexo,
3026
+ accept = { "image/jpeg": [], "image/png": [] },
3027
+ maxSize = 50 * 1024 * 1024
3028
+ }) => {
3029
+ const onDrop = (0, import_react19.useCallback)(
3030
+ (acceptedFiles) => {
3031
+ const file = acceptedFiles[0];
3032
+ if (file && typeof onFilePut === "function") {
3033
+ onFilePut(file);
3034
+ }
3035
+ },
3036
+ [onFilePut]
3037
+ );
3038
+ const { getRootProps, getInputProps, isDragActive } = (0, import_react_dropzone.useDropzone)({
3039
+ onDrop,
3040
+ maxSize,
3041
+ accept
3042
+ });
3043
+ const hasAnexo = Boolean(anexo);
3044
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
3045
+ "div",
3046
+ {
3047
+ ...getRootProps(),
3048
+ className: `upload-area
3049
+ ${isDragActive ? "drag-active" : ""}
3050
+ ${hasAnexo ? "upload-has-file" : ""}
3051
+ `,
3052
+ children: [
3053
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("input", { ...getInputProps() }),
3054
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "upload-content", children: [
3055
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "upload-icon", children: hasAnexo ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_fi4.FiCheckCircle, { size: 24 }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_fi4.FiUploadCloud, { size: 24 }) }),
3056
+ hasAnexo ? /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
3057
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "upload-link", children: "Arquivo anexado" }),
3058
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "upload-info", children: anexo == null ? void 0 : anexo.name })
3059
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
3060
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("p", { children: [
3061
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "upload-link", children: "Adicione" }),
3062
+ " ou arraste arquivos aqui"
3063
+ ] }),
3064
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("p", { className: "upload-info", children: [
3065
+ "Formatos aceitos: ",
3066
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("b", { children: Object.keys(accept).map((t) => t.split("/")[1].toUpperCase()).join(", ") }),
3067
+ " | Tamanho m\xE1ximo:",
3068
+ " ",
3069
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("b", { children: [
3070
+ (maxSize / (1024 * 1024)).toFixed(0),
3071
+ "MB"
3072
+ ] })
3073
+ ] })
3074
+ ] })
3075
+ ] })
3076
+ ]
3077
+ }
3078
+ );
3079
+ };
3080
+
3081
+ // src/index.ts
3082
+ var import_ui_kit_core = require("@teraprox/ui-kit-core");
3083
+
3084
+ // src/forms/FindRecursoByTagField.tsx
3085
+ var import_ui_kit_sgm3 = require("@teraprox/ui-kit-sgm");
3086
+
3087
+ // src/forms/SectorSelector.tsx
3088
+ var import_react20 = require("react");
3089
+ var import_react_bootstrap28 = require("react-bootstrap");
3090
+ var import_bs2 = require("react-icons/bs");
3091
+ var import_jsx_runtime40 = require("react/jsx-runtime");
3092
+ var SectorSelector = ({
3093
+ setores,
3094
+ onSectorSelect,
3095
+ selectionLabel = "Selecione o Setor",
3096
+ selectionPlaceholder = "Selecione o setor",
3097
+ hideComponent = false,
3098
+ defaultSectorName = false,
3099
+ allowAll = false
3100
+ }) => {
3101
+ const [expanded, setExpanded] = (0, import_react20.useState)(false);
3102
+ const [selectedSector, setSelectedSector] = (0, import_react20.useState)(null);
3103
+ (0, import_react20.useEffect)(() => {
3104
+ if (defaultSectorName && setores.length > 0) {
3105
+ const setor = setores.find((s) => s.nome === defaultSectorName);
3106
+ if (setor && setor.id !== (selectedSector == null ? void 0 : selectedSector.id)) {
3107
+ setSelectedSector(setor);
3108
+ }
3109
+ } else if (!defaultSectorName) {
3110
+ setSelectedSector(null);
3111
+ }
3112
+ }, [defaultSectorName, setores]);
3113
+ const handleSelectSetor = (setor) => {
3114
+ setSelectedSector(setor);
3115
+ onSectorSelect(setor);
3116
+ setExpanded(false);
3117
+ };
3118
+ const toggleExpand = () => {
3119
+ setExpanded(!expanded);
3120
+ };
3121
+ if (hideComponent) return null;
3122
+ const setorOptions = allowAll ? [{ id: "all", nome: "Todos" }, ...setores] : [...setores];
3123
+ return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_react_bootstrap28.Form.Floating, { className: "sector-selector-floating", children: [
3124
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "custom-select-container", onClick: toggleExpand, children: [
3125
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "selected-sector-label mt-1", children: (selectedSector == null ? void 0 : selectedSector.nome) || selectionPlaceholder }),
3126
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "zoom-container", children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_bs2.BsChevronUp, {}) : /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_bs2.BsChevronDown, {}) })
3127
+ ] }),
3128
+ (selectedSector == null ? void 0 : selectedSector.nome) && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("label", { htmlFor: "floatingInputCustom", children: selectionLabel }),
3129
+ expanded && /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
3130
+ "div",
3131
+ {
3132
+ className: "custom-dropdown-menu",
3133
+ onMouseLeave: () => setExpanded(false),
3134
+ children: [
3135
+ setorOptions.sort((a, b) => a.nome.localeCompare(b.nome)).map((setor, idx) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
3136
+ "div",
3137
+ {
3138
+ className: `dropdown-option ${setor.nome === (selectedSector == null ? void 0 : selectedSector.nome) ? "selected-option" : ""}`,
3139
+ onClick: () => handleSelectSetor(setor),
3140
+ children: setor.nome === "default" ? "Nenhum" : setor.nome
3141
+ },
3142
+ idx
3143
+ )),
3144
+ setores.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "dropdown-option text-muted italic", children: "Carregando setores..." })
3145
+ ]
3146
+ }
3147
+ )
3148
+ ] });
3149
+ };
3150
+
3151
+ // src/forms/UnidadeMaterialForm.tsx
3152
+ var import_react_bootstrap29 = require("react-bootstrap");
3153
+ var import_jsx_runtime41 = require("react/jsx-runtime");
3154
+ var UnidadeMaterialForm = ({
3155
+ value,
3156
+ onMaterialSelected,
3157
+ onQuantidadeUpdate,
3158
+ onUnidadeSelected,
3159
+ onNavigateToCreateMaterial,
3160
+ onNavigateToCreateUnidade,
3161
+ loadMaterialsFunc,
3162
+ loadUnidadesFunc,
3163
+ materialLabel = "Materia Prima",
3164
+ hideMaterial = false,
3165
+ hideQuantidade = false,
3166
+ hideUnidade = false,
3167
+ className = ""
3168
+ }) => {
3169
+ var _a, _b, _c;
3170
+ const renderNewMaterialButton = () => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_react_bootstrap29.Button, { onClick: onNavigateToCreateMaterial, size: "sm", variant: "outline-primary", children: "Novo Material" });
3171
+ const renderNewUnidadeButton = () => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_react_bootstrap29.Button, { onClick: onNavigateToCreateUnidade, size: "sm", variant: "outline-primary", children: "Nova Unidade" });
3172
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: `unidade-material-form ${className}`, children: [
3173
+ !hideMaterial && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
3174
+ AutoComplete,
3175
+ {
3176
+ displayKey: "nome",
3177
+ value: ((_a = value == null ? void 0 : value.material) == null ? void 0 : _a.nome) || "",
3178
+ loadCondition: true,
3179
+ title: materialLabel,
3180
+ loadFunc: loadMaterialsFunc,
3181
+ onSelectedClick: onMaterialSelected,
3182
+ actionButton: onNavigateToCreateMaterial ? renderNewMaterialButton : void 0
3183
+ }
3184
+ ),
3185
+ !hideQuantidade && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
3186
+ FormField,
3187
+ {
3188
+ label: "Quantidade",
3189
+ val: (_b = value == null ? void 0 : value.quantidade) != null ? _b : "",
3190
+ onValueUpdate: onQuantidadeUpdate,
3191
+ ty: "number"
3192
+ }
3193
+ ),
3194
+ !hideUnidade && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
3195
+ AutoComplete,
3196
+ {
3197
+ displayKey: "nome",
3198
+ value: ((_c = value == null ? void 0 : value.unidade) == null ? void 0 : _c.nome) || "",
3199
+ loadCondition: true,
3200
+ title: "Unidade",
3201
+ loadFunc: loadUnidadesFunc,
3202
+ onSelectedClick: onUnidadeSelected,
3203
+ actionButton: onNavigateToCreateUnidade ? renderNewUnidadeButton : void 0
3204
+ }
3205
+ )
3206
+ ] });
3207
+ };
3208
+
3209
+ // src/icons/IconLabelItem.tsx
3210
+ var import_jsx_runtime42 = require("react/jsx-runtime");
3211
+ var IconLabelItem = ({
3212
+ icon,
3213
+ label,
3214
+ containerClassName = "",
3215
+ labelClassName = "",
3216
+ onClick,
3217
+ style
3218
+ }) => {
3219
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: containerClassName, onClick, style: { ...style, cursor: onClick ? "pointer" : "default" }, children: [
3220
+ icon,
3221
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: labelClassName, children: label })
3222
+ ] });
3223
+ };
3224
+
3225
+ // src/icons/IconLabelList.tsx
3226
+ var import_jsx_runtime43 = require("react/jsx-runtime");
3227
+ var IconLabelList = ({ items, className = "" }) => {
3228
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: `icon-label-list ${className}`, children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
3229
+ IconLabelItem,
3230
+ {
3231
+ labelClassName: "icon-label",
3232
+ containerClassName: "icon-label-item",
3233
+ icon: item.icon,
3234
+ label: item.label,
3235
+ onClick: item.onClick
3236
+ },
3237
+ index
3238
+ )) });
3239
+ };
3240
+
3241
+ // src/icons/NotificationItem.tsx
3242
+ var import_react21 = require("react");
3243
+ var import_react_bootstrap30 = require("react-bootstrap");
3244
+ var import_fi5 = require("react-icons/fi");
3245
+ var import_dayjs5 = __toESM(require("dayjs"));
3246
+ var import_jsx_runtime44 = require("react/jsx-runtime");
3247
+ var NotificationItem = ({
3248
+ notification,
3249
+ onRead,
3250
+ onDismiss,
3251
+ emptyContentLabel = "Sem conte\xFAdo adicional dispon\xEDvel."
3252
+ }) => {
3253
+ const [showModal, setShowModal] = (0, import_react21.useState)(false);
3254
+ const { context, contextId, content, status, createdAt, readAt } = notification;
3255
+ const handleOpenModal = (e) => {
3256
+ e.stopPropagation();
3257
+ setShowModal(true);
3258
+ };
3259
+ const handleCloseModal = () => setShowModal(false);
3260
+ const handleReadAndClose = () => {
3261
+ onRead(notification);
3262
+ handleCloseModal();
3263
+ };
3264
+ const handleDismiss = (e) => {
3265
+ e.stopPropagation();
3266
+ onDismiss(notification);
3267
+ };
3268
+ const displayTitle = contextId ? `${context} - ${contextId}` : context || "Notifica\xE7\xE3o";
3269
+ return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
3270
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
3271
+ "div",
3272
+ {
3273
+ className: `notification-item-modern ${status === "unread" ? "unread" : ""}`,
3274
+ onClick: handleOpenModal,
3275
+ children: [
3276
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: `notification-status-indicator ${status}`, children: status === "unread" ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_fi5.FiClock, { size: 14 }) : /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_fi5.FiCheck, { size: 14 }) }),
3277
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "notification-main-content", children: [
3278
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "notification-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "notification-title-modern", children: [
3279
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "notification-context", children: context }),
3280
+ contextId && /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
3281
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "notification-separator", children: "/" }),
3282
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "notification-context-id", children: contextId })
3283
+ ] })
3284
+ ] }) }),
3285
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "notification-preview", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("p", { className: "notification-content-preview", children: content || "Nova mensagem recebida" }) }),
3286
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "notification-meta", children: [
3287
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "notification-timestamp", children: [
3288
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_fi5.FiClock, { size: 12, className: "me-1" }),
3289
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("small", { children: (0, import_dayjs5.default)(createdAt).format("DD/MM/YYYY HH:mm") })
3290
+ ] }),
3291
+ readAt && /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "notification-read-time", children: [
3292
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_fi5.FiCheck, { size: 12, className: "me-1" }),
3293
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("small", { children: [
3294
+ "Lida em ",
3295
+ (0, import_dayjs5.default)(readAt).format("DD/MM HH:mm")
3296
+ ] })
3297
+ ] })
3298
+ ] })
3299
+ ] }),
3300
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "notification-quick-actions", children: status === "unread" && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3301
+ import_react_bootstrap30.OverlayTrigger,
3302
+ {
3303
+ placement: "top",
3304
+ overlay: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_react_bootstrap30.Tooltip, { children: "Descartar" }),
3305
+ children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3306
+ "button",
3307
+ {
3308
+ className: "notification-action-btn notification-dismiss-btn",
3309
+ onClick: handleDismiss,
3310
+ "aria-label": "Descartar notifica\xE7\xE3o",
3311
+ children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_fi5.FiTrash2, { size: 14 })
3312
+ }
3313
+ )
3314
+ }
3315
+ ) })
3316
+ ]
3317
+ }
3318
+ ),
3319
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
3320
+ import_react_bootstrap30.Modal,
3321
+ {
3322
+ show: showModal,
3323
+ onHide: handleCloseModal,
3324
+ centered: true,
3325
+ className: "notification-modal",
3326
+ children: [
3327
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_react_bootstrap30.Modal.Header, { closeButton: true, className: "notification-modal-header", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_react_bootstrap30.Modal.Title, { className: "notification-modal-title", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "d-flex align-items-center", children: [
3328
+ status === "unread" ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_fi5.FiClock, { className: "me-2 text-warning" }) : /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_fi5.FiCheck, { className: "me-2 text-success" }),
3329
+ "Detalhes da Notifica\xE7\xE3o"
3330
+ ] }) }) }),
3331
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_react_bootstrap30.Modal.Body, { className: "notification-modal-body", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "notification-modal-content", children: [
3332
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "notification-modal-meta", children: [
3333
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("h6", { className: "notification-modal-source", children: displayTitle }),
3334
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "notification-modal-timestamps", children: [
3335
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("small", { className: "text-muted", children: [
3336
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_fi5.FiClock, { size: 12, className: "me-1" }),
3337
+ "Criada em ",
3338
+ (0, import_dayjs5.default)(createdAt).format("DD/MM/YYYY [\xE0s] HH:mm")
3339
+ ] }),
3340
+ readAt && /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("small", { className: "text-muted ms-3", children: [
3341
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_fi5.FiCheck, { size: 12, className: "me-1" }),
3342
+ "Lida em ",
3343
+ (0, import_dayjs5.default)(readAt).format("DD/MM/YYYY [\xE0s] HH:mm")
3344
+ ] })
3345
+ ] })
3346
+ ] }),
3347
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "notification-modal-message", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("p", { className: "mb-0", children: content || emptyContentLabel }) })
3348
+ ] }) }),
3349
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_react_bootstrap30.Modal.Footer, { className: "notification-modal-footer", children: [
3350
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_react_bootstrap30.Button, { variant: "outline-secondary", onClick: handleCloseModal, children: "Fechar" }),
3351
+ status === "unread" && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_react_bootstrap30.Button, { variant: "primary", onClick: handleReadAndClose, children: "Marcar como lida" })
3352
+ ] })
3353
+ ]
3354
+ }
3355
+ )
3356
+ ] });
3357
+ };
3358
+
3359
+ // src/icons/NotificationBell.tsx
3360
+ var import_react_bootstrap31 = require("react-bootstrap");
3361
+ var import_fi6 = require("react-icons/fi");
3362
+ var import_jsx_runtime45 = require("react/jsx-runtime");
3363
+ var NotificationBell = ({
3364
+ notifications,
3365
+ onItemRead,
3366
+ onItemDismiss,
3367
+ onMarkAllRead,
3368
+ size = 20,
3369
+ className = ""
3370
+ }) => {
3371
+ const unreadCount = notifications.filter((n) => n.status === "unread").length;
3372
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_react_bootstrap31.Dropdown, { align: "end", className: `notification-bell-dropdown ${className}`, children: [
3373
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_react_bootstrap31.Dropdown.Toggle, { as: "div", className: "position-relative cursor-pointer p-2", children: [
3374
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_fi6.FiBell, { size }),
3375
+ unreadCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
3376
+ import_react_bootstrap31.Badge,
3377
+ {
3378
+ pill: true,
3379
+ bg: "danger",
3380
+ className: "position-absolute",
3381
+ style: { top: 0, right: 0, fontSize: "0.65rem" },
3382
+ children: unreadCount > 99 ? "99+" : unreadCount
3383
+ }
3384
+ )
3385
+ ] }),
3386
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
3387
+ import_react_bootstrap31.Dropdown.Menu,
3388
+ {
3389
+ className: "shadow-lg border-0",
3390
+ style: { width: "320px", padding: 0, maxHeight: "500px", overflowY: "auto" },
3391
+ children: [
3392
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "p-3 border-bottom d-flex justify-content-between align-items-center bg-light", children: [
3393
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h6", { className: "mb-0 fw-bold", children: "Notifica\xE7\xF5es" }),
3394
+ unreadCount > 0 && onMarkAllRead && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
3395
+ "button",
3396
+ {
3397
+ className: "btn btn-link btn-sm p-0 text-decoration-none",
3398
+ onClick: (e) => {
3399
+ e.stopPropagation();
3400
+ onMarkAllRead();
3401
+ },
3402
+ children: "Limpar tudo"
3403
+ }
3404
+ )
3405
+ ] }),
3406
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "notification-list", children: notifications.length > 0 ? notifications.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()).map((n) => /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
3407
+ NotificationItem,
3408
+ {
3409
+ notification: n,
3410
+ onRead: onItemRead,
3411
+ onDismiss: onItemDismiss
3412
+ },
3413
+ n.id
3414
+ )) : /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "p-4 text-center text-muted", children: [
3415
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_fi6.FiBell, { size: 24, className: "mb-2 opacity-25" }),
3416
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "mb-0 small", children: "Nenhuma notifica\xE7\xE3o por aqui." })
3417
+ ] }) }),
3418
+ notifications.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "p-2 border-top text-center bg-light", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("small", { className: "text-muted", children: [
3419
+ "Total: ",
3420
+ notifications.length,
3421
+ " notifica\xE7\xF5es"
3422
+ ] }) })
3423
+ ]
3424
+ }
3425
+ )
3426
+ ] });
3427
+ };
3428
+
3429
+ // src/modals/ModalBasicTemplate.tsx
3430
+ var import_react_bootstrap32 = require("react-bootstrap");
3431
+ var import_jsx_runtime46 = require("react/jsx-runtime");
3432
+ var ModalBasicTemplate = ({
3433
+ show,
3434
+ closeFunc,
3435
+ body,
3436
+ header,
3437
+ footer,
3438
+ props = {}
3439
+ }) => {
3440
+ const { bodyStyle, dialogStyle, ...modalProps } = props;
3441
+ const renderPart = (part) => {
3442
+ if (typeof part === "function") return part();
3443
+ return part;
3444
+ };
3445
+ return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
3446
+ import_react_bootstrap32.Modal,
3447
+ {
3448
+ show,
3449
+ onHide: closeFunc,
3450
+ centered: true,
3451
+ style: dialogStyle,
3452
+ ...modalProps,
3453
+ children: [
3454
+ header && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_react_bootstrap32.Modal.Header, { closeButton: true, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_react_bootstrap32.Modal.Title, { children: renderPart(header) }) }),
3455
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_react_bootstrap32.Modal.Body, { style: bodyStyle, children: renderPart(body) }),
3456
+ footer && /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_react_bootstrap32.Modal.Footer, { children: [
3457
+ renderPart(footer),
3458
+ !footer && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_react_bootstrap32.Button, { variant: "secondary", onClick: closeFunc, children: "Fechar" })
3459
+ ] })
3460
+ ]
3461
+ }
3462
+ );
3463
+ };
3464
+ var ModalBasicTemplate_default = ModalBasicTemplate;
3465
+
3466
+ // src/modals/SelectDateModal.tsx
3467
+ var import_react22 = require("react");
3468
+ var import_react_bootstrap33 = require("react-bootstrap");
3469
+ var import_dayjs6 = __toESM(require("dayjs"));
3470
+ var import_jsx_runtime47 = require("react/jsx-runtime");
3471
+ var SelectDateModal = ({
3472
+ show,
3473
+ onClose,
3474
+ onSelect,
3475
+ title = "Selecionar Data",
3476
+ label = "Escolha a data",
3477
+ initialDate,
3478
+ allowFuture = true
3479
+ }) => {
3480
+ const [selectedDate, setSelectedDate] = (0, import_react22.useState)(
3481
+ initialDate || (0, import_dayjs6.default)().format("YYYY-MM-DDTHH:mm")
3482
+ );
3483
+ const handleConfirm = () => {
3484
+ onSelect(selectedDate);
3485
+ onClose();
3486
+ };
3487
+ return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_react_bootstrap33.Modal, { show, onHide: onClose, centered: true, size: "sm", children: [
3488
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_react_bootstrap33.Modal.Header, { closeButton: true, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_react_bootstrap33.Modal.Title, { children: title }) }),
3489
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_react_bootstrap33.Modal.Body, { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_react_bootstrap33.Form.Group, { children: [
3490
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_react_bootstrap33.Form.Label, { children: label }),
3491
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
3492
+ import_react_bootstrap33.Form.Control,
3493
+ {
3494
+ type: "datetime-local",
3495
+ value: selectedDate,
3496
+ max: allowFuture ? void 0 : (0, import_dayjs6.default)().format("YYYY-MM-DDTHH:mm"),
3497
+ onChange: (e) => setSelectedDate(e.target.value)
3498
+ }
3499
+ )
3500
+ ] }) }),
3501
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_react_bootstrap33.Modal.Footer, { children: [
3502
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_react_bootstrap33.Button, { variant: "outline-secondary", onClick: onClose, children: "Cancelar" }),
3503
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_react_bootstrap33.Button, { variant: "primary", onClick: handleConfirm, children: "Confirmar" })
3504
+ ] })
3505
+ ] });
3506
+ };
3507
+
3508
+ // src/modals/JustificativaModal.tsx
3509
+ var import_react23 = require("react");
3510
+ var import_react_bootstrap34 = require("react-bootstrap");
3511
+ var import_fa6 = require("react-icons/fa");
3512
+ var import_dayjs7 = __toESM(require("dayjs"));
3513
+ var import_jsx_runtime48 = require("react/jsx-runtime");
3514
+ var JustificativaModal = ({
3515
+ show,
3516
+ onClose,
3517
+ justificativas: initialJustificativas = [],
3518
+ currentUserId,
3519
+ currentUserName,
3520
+ onUpdateJustificativas
3521
+ }) => {
3522
+ const [localJustificativas, setLocalJustificativas] = (0, import_react23.useState)(initialJustificativas);
3523
+ const [novaDescricao, setNovaDescricao] = (0, import_react23.useState)("");
3524
+ const [editandoId, setEditandoId] = (0, import_react23.useState)(null);
3525
+ (0, import_react23.useEffect)(() => {
3526
+ setLocalJustificativas(initialJustificativas);
3527
+ }, [initialJustificativas]);
3528
+ const handleAddOrEdit = async () => {
3529
+ if (!novaDescricao.trim()) return;
3530
+ let updatedList = [];
3531
+ if (editandoId) {
3532
+ updatedList = localJustificativas.map(
3533
+ (j) => j.id === editandoId ? { ...j, descricao: novaDescricao } : j
3534
+ );
3535
+ setEditandoId(null);
3536
+ } else {
3537
+ const nova = {
3538
+ id: Math.random().toString(36).substr(2, 9),
3539
+ // Simples ID local se uuid não estiver disp.
3540
+ descricao: novaDescricao,
3541
+ user: { userId: currentUserId, firstName: currentUserName },
3542
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
3543
+ isNew: true
3544
+ };
3545
+ updatedList = [...localJustificativas, nova];
3546
+ }
3547
+ setNovaDescricao("");
3548
+ await onUpdateJustificativas(updatedList);
3549
+ setLocalJustificativas(updatedList);
3550
+ };
3551
+ const handleRemove = async (id) => {
3552
+ const updated = localJustificativas.map((j) => j.id === id ? { ...j, removed: true } : j);
3553
+ await onUpdateJustificativas(updated);
3554
+ setLocalJustificativas(updated);
3555
+ };
3556
+ const handleUndoRemove = async (id) => {
3557
+ const updated = localJustificativas.map((j) => j.id === id ? { ...j, removed: false } : j);
3558
+ await onUpdateJustificativas(updated);
3559
+ setLocalJustificativas(updated);
3560
+ };
3561
+ return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_react_bootstrap34.Modal, { show, onHide: onClose, centered: true, size: "lg", children: [
3562
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_react_bootstrap34.Modal.Header, { closeButton: true, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_react_bootstrap34.Modal.Title, { children: "Justificativas / Coment\xE1rios" }) }),
3563
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_react_bootstrap34.Modal.Body, { children: [
3564
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_react_bootstrap34.Form, { className: "mb-4", children: [
3565
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_react_bootstrap34.Form.Group, { controlId: "justificativaInput", className: "mb-2", children: [
3566
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_react_bootstrap34.Form.Label, { className: "small text-muted fw-bold", children: "NOVO REGISTRO" }),
3567
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
3568
+ import_react_bootstrap34.Form.Control,
3569
+ {
3570
+ as: "textarea",
3571
+ rows: 2,
3572
+ value: novaDescricao,
3573
+ onChange: (e) => setNovaDescricao(e.target.value),
3574
+ placeholder: "Descreva o motivo ou informa\xE7\xE3o adicional..."
3575
+ }
3576
+ )
3577
+ ] }),
3578
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "d-flex justify-content-end", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_react_bootstrap34.Button, { variant: "primary", size: "sm", onClick: handleAddOrEdit, children: editandoId ? "Salvar Edi\xE7\xE3o" : "Adicionar Justificativa" }) })
3579
+ ] }),
3580
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_react_bootstrap34.ListGroup, { className: "border-0", children: localJustificativas.map((j) => {
3581
+ var _a, _b, _c;
3582
+ const isMe = ((_a = j.user) == null ? void 0 : _a.userId) === currentUserId;
3583
+ return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
3584
+ import_react_bootstrap34.ListGroup.Item,
3585
+ {
3586
+ className: "border-0 px-0",
3587
+ style: {
3588
+ opacity: j.removed ? 0.5 : 1,
3589
+ display: "flex",
3590
+ flexDirection: "column",
3591
+ alignItems: isMe ? "flex-start" : "flex-end",
3592
+ backgroundColor: "transparent"
3593
+ },
3594
+ children: [
3595
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "d-flex align-items-center mb-1", style: { width: "100%", justifyContent: isMe ? "flex-start" : "flex-end" }, children: [
3596
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("span", { className: "small fw-bold text-dark me-2", children: isMe ? "Voc\xEA" : ((_b = j.user) == null ? void 0 : _b.userName) || ((_c = j.user) == null ? void 0 : _c.firstName) || "Usu\xE1rio" }),
3597
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_react_bootstrap34.Badge, { bg: "secondary", style: { fontSize: "0.65rem" }, children: (0, import_dayjs7.default)(j.createdAt).format("DD/MM [\xE0s] HH:mm") })
3598
+ ] }),
3599
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
3600
+ "div",
3601
+ {
3602
+ onClick: () => !j.removed && isMe && (setNovaDescricao(j.descricao), setEditandoId(j.id)),
3603
+ style: {
3604
+ maxWidth: "85%",
3605
+ alignSelf: isMe ? "flex-start" : "flex-end",
3606
+ backgroundColor: j.removed ? "#f8d7da" : isMe ? "#e3f2fd" : "#f8f9fa",
3607
+ color: "#333",
3608
+ padding: "12px 16px",
3609
+ borderRadius: "12px",
3610
+ cursor: isMe && !j.removed ? "pointer" : "default",
3611
+ textDecoration: j.removed ? "line-through" : "none",
3612
+ boxShadow: "0 1px 3px rgba(0,0,0,0.1)",
3613
+ border: isMe ? "1px solid #bbdefb" : "1px solid #e0e0e0"
3614
+ },
3615
+ children: j.descricao
3616
+ }
3617
+ ),
3618
+ isMe && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "mt-1 d-flex gap-2", children: j.removed ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_react_bootstrap34.OverlayTrigger, { placement: "top", overlay: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_react_bootstrap34.Tooltip, { children: "Desfazer" }), children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
3619
+ import_fa6.FaUndo,
3620
+ {
3621
+ onClick: () => handleUndoRemove(j.id),
3622
+ className: "text-success cursor-pointer",
3623
+ size: 14
3624
+ }
3625
+ ) }) : /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_react_bootstrap34.OverlayTrigger, { placement: "top", overlay: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_react_bootstrap34.Tooltip, { children: "Remover" }), children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
3626
+ import_fa6.FaTrashAlt,
3627
+ {
3628
+ onClick: () => handleRemove(j.id),
3629
+ className: "text-danger cursor-pointer",
3630
+ size: 14
3631
+ }
3632
+ ) }) })
3633
+ ]
3634
+ },
3635
+ j.id
3636
+ );
3637
+ }) })
3638
+ ] }),
3639
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_react_bootstrap34.Modal.Footer, { children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_react_bootstrap34.Button, { variant: "outline-secondary", onClick: onClose, children: "Fechar" }) })
3640
+ ] });
3641
+ };
3642
+
3643
+ // src/modals/ImageViewModal.tsx
3644
+ var import_react24 = require("react");
3645
+ var import_react_bootstrap35 = require("react-bootstrap");
3646
+ var import_jsx_runtime49 = require("react/jsx-runtime");
3647
+ var ImageViewModal = ({
3648
+ show,
3649
+ onHide,
3650
+ imagesData = [],
3651
+ initialImageData,
3652
+ imageAltText = "Visualiza\xE7\xE3o de imagem",
3653
+ resolveImageUrl
3654
+ }) => {
3655
+ const [selectedImageKey, setSelectedImageKey] = (0, import_react24.useState)(null);
3656
+ const [imageSrc, setImageSrc] = (0, import_react24.useState)(null);
3657
+ const [currentAuthor, setCurrentAuthor] = (0, import_react24.useState)("Desconhecido");
3658
+ (0, import_react24.useEffect)(() => {
3659
+ if (show && initialImageData) {
3660
+ setSelectedImageKey(initialImageData.key);
3661
+ setCurrentAuthor(initialImageData.author || "Desconhecido");
3662
+ } else if (show && imagesData.length > 0) {
3663
+ setSelectedImageKey(imagesData[0].key);
3664
+ setCurrentAuthor(imagesData[0].author || "Desconhecido");
3665
+ }
3666
+ }, [show, initialImageData]);
3667
+ (0, import_react24.useEffect)(() => {
3668
+ if (show && selectedImageKey) {
3669
+ setImageSrc(null);
3670
+ const file = imagesData.find((f) => f.key === selectedImageKey);
3671
+ if (file == null ? void 0 : file.signedUrl) {
3672
+ setImageSrc(file.signedUrl);
3673
+ } else if (resolveImageUrl) {
3674
+ setImageSrc(resolveImageUrl(selectedImageKey));
3675
+ }
3676
+ }
3677
+ }, [show, selectedImageKey]);
3678
+ const renderImageSelector = () => {
3679
+ if (imagesData.length <= 1) return null;
3680
+ return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "mb-3 d-flex flex-wrap justify-content-center gap-2", children: imagesData.map((img, idx) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
3681
+ import_react_bootstrap35.Button,
3682
+ {
3683
+ variant: selectedImageKey === img.key ? "primary" : "outline-secondary",
3684
+ size: "sm",
3685
+ onClick: () => {
3686
+ setSelectedImageKey(img.key);
3687
+ setCurrentAuthor(img.author || "Desconhecido");
3688
+ },
3689
+ children: img.dataContext ? `${img.dataContext}-${img.dataId}` : `Imagem ${idx + 1}`
3690
+ },
3691
+ idx
3692
+ )) });
3693
+ };
3694
+ const body = /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "text-center", children: [
3695
+ renderImageSelector(),
3696
+ imageSrc ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
3697
+ "img",
3698
+ {
3699
+ src: imageSrc,
3700
+ alt: imageAltText,
3701
+ className: "img-fluid rounded shadow-sm",
3702
+ style: { maxHeight: "75vh", objectFit: "contain" }
3703
+ }
3704
+ ) : /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "p-5 text-muted", children: "Aguardando imagem..." })
3705
+ ] });
3706
+ return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
3707
+ ModalBasicTemplate_default,
3708
+ {
3709
+ header: "Visualiza\xE7\xE3o de Imagem",
3710
+ closeFunc: onHide,
3711
+ show,
3712
+ body,
3713
+ props: { size: "lg" },
3714
+ footer: () => /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "w-100 d-flex justify-content-between align-items-center", children: [
3715
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("small", { className: "text-muted", children: [
3716
+ "Enviado por: ",
3717
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("strong", { children: currentAuthor })
3718
+ ] }),
3719
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_react_bootstrap35.Button, { variant: "outline-secondary", size: "sm", onClick: onHide, children: "Fechar" })
3720
+ ] })
3721
+ }
3722
+ );
3723
+ };
3724
+
3725
+ // src/qr/QrReader.tsx
3726
+ var import_qr_scanner = __toESM(require("qr-scanner"));
3727
+ var import_react25 = require("react");
3728
+ var import_jsx_runtime50 = require("react/jsx-runtime");
3729
+ var QrReader = ({ callback }) => {
3730
+ const scanner = (0, import_react25.useRef)(null);
3731
+ const videoEl = (0, import_react25.useRef)(null);
3732
+ const qrBoxEl = (0, import_react25.useRef)(null);
3733
+ const [qrOn, setQrOn] = (0, import_react25.useState)(true);
3734
+ const [scannedResult, setScannedResult] = (0, import_react25.useState)("");
3735
+ const onScanSuccess = (result) => {
3736
+ setScannedResult(result.data);
3737
+ callback(result.data);
3738
+ };
3739
+ const onScanFail = (err) => {
3740
+ if (typeof err === "string" && !err.includes("No QR code found")) {
3741
+ console.error("QR Scanner Error:", err);
3742
+ }
3743
+ };
3744
+ (0, import_react25.useEffect)(() => {
3745
+ if (videoEl.current && !scanner.current) {
3746
+ scanner.current = new import_qr_scanner.default(videoEl.current, onScanSuccess, {
3747
+ onDecodeError: onScanFail,
3748
+ preferredCamera: "environment",
3749
+ highlightScanRegion: true,
3750
+ highlightCodeOutline: true,
3751
+ overlay: qrBoxEl.current || void 0
3752
+ });
3753
+ scanner.current.start().then(() => setQrOn(true)).catch((err) => {
3754
+ console.error("Failed to start QR Scanner:", err);
3755
+ setQrOn(false);
3756
+ });
3757
+ }
3758
+ return () => {
3759
+ if (scanner.current) {
3760
+ scanner.current.stop();
3761
+ scanner.current.destroy();
3762
+ scanner.current = null;
3763
+ }
3764
+ };
3765
+ }, []);
3766
+ (0, import_react25.useEffect)(() => {
3767
+ if (!qrOn) {
3768
+ alert(
3769
+ "C\xE2mera est\xE1 bloqueada ou inacess\xEDvel. Por favor, habilite a c\xE2mera nas permiss\xF5es do seu navegador e recarregue a p\xE1gina."
3770
+ );
3771
+ }
3772
+ }, [qrOn]);
3773
+ return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "qr-reader", style: { position: "relative", width: "100%", maxWidth: "500px", margin: "0 auto" }, children: [
3774
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("video", { ref: videoEl, style: { width: "100%", borderRadius: "8px" } }),
3775
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { ref: qrBoxEl, className: "qr-box" }),
3776
+ scannedResult && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
3777
+ "div",
3778
+ {
3779
+ style: {
3780
+ position: "absolute",
3781
+ top: 10,
3782
+ left: 10,
3783
+ zIndex: 10,
3784
+ background: "rgba(0,0,0,0.6)",
3785
+ color: "white",
3786
+ padding: "4px 8px",
3787
+ borderRadius: "4px",
3788
+ fontSize: "0.8rem"
3789
+ },
3790
+ children: [
3791
+ "Lido: ",
3792
+ scannedResult
3793
+ ]
3794
+ }
3795
+ )
3796
+ ] });
3797
+ };
3798
+
3799
+ // src/qr/QrCodeScanButton.tsx
3800
+ var import_react26 = require("react");
3801
+ var import_bs3 = require("react-icons/bs");
3802
+ var import_jsx_runtime51 = require("react/jsx-runtime");
3803
+ var QrCodeScanButton = ({ callback, size = 25 }) => {
3804
+ const [showQr, setShowQr] = (0, import_react26.useState)(false);
3805
+ const toggleQr = () => {
3806
+ setShowQr((prev) => !prev);
3807
+ };
3808
+ return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
3809
+ "div",
3810
+ {
3811
+ className: "hoverable-div",
3812
+ style: {
3813
+ border: "solid",
3814
+ borderTopRightRadius: "3px",
3815
+ borderBottomRightRadius: "3px",
3816
+ padding: "8px",
3817
+ borderLeft: "none",
3818
+ borderColor: "#ccc",
3819
+ borderWidth: "1px",
3820
+ cursor: "pointer",
3821
+ display: "flex",
3822
+ alignItems: "center"
3823
+ },
3824
+ onClick: toggleQr,
3825
+ children: [
3826
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_bs3.BsQrCode, { size }),
3827
+ showQr && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
3828
+ "div",
3829
+ {
3830
+ style: {
3831
+ position: "fixed",
3832
+ top: 0,
3833
+ left: 0,
3834
+ right: 0,
3835
+ bottom: 0,
3836
+ backgroundColor: "rgba(0,0,0,0.8)",
3837
+ zIndex: 9999,
3838
+ display: "flex",
3839
+ flexDirection: "column",
3840
+ alignItems: "center",
3841
+ justifyContent: "center",
3842
+ padding: "20px"
3843
+ },
3844
+ onClick: (e) => e.stopPropagation(),
3845
+ children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { style: { width: "100%", maxWidth: "500px", backgroundColor: "#fff", borderRadius: "12px", padding: "20px", position: "relative" }, children: [
3846
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
3847
+ "div",
3848
+ {
3849
+ onClick: toggleQr,
3850
+ style: { position: "absolute", top: "10px", right: "15px", fontSize: "1.5rem", cursor: "pointer", zIndex: 10001 },
3851
+ children: "\xD7"
3852
+ }
3853
+ ),
3854
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("h5", { className: "mb-3 text-center", children: "Escaneie o QR Code" }),
3855
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
3856
+ QrReader,
3857
+ {
3858
+ callback: (v) => {
3859
+ toggleQr();
3860
+ callback(v);
3861
+ }
3862
+ }
3863
+ ),
3864
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("p", { className: "mt-3 text-muted text-center small", children: "Aponte a c\xE2mera para o c\xF3digo" })
3865
+ ] })
3866
+ }
3867
+ )
3868
+ ]
3869
+ }
3870
+ );
3871
+ };
3872
+
3873
+ // src/tables/ReusableTableWithModal.tsx
3874
+ var import_react27 = require("react");
3875
+ var import_react_bootstrap36 = require("react-bootstrap");
3876
+ var import_jsx_runtime52 = require("react/jsx-runtime");
3877
+ var ReusableTableWithModal = ({
3878
+ fetchDataCallback,
3879
+ modalButtonCallback,
3880
+ configureColumnsCallback,
3881
+ headers,
3882
+ modalContent,
3883
+ confirmLabel = "Aceitar",
3884
+ onFetchData
3885
+ }) => {
3886
+ const [data, setData] = (0, import_react27.useState)([]);
3887
+ const [selectedItem, setSelectedItem] = (0, import_react27.useState)(null);
3888
+ const [showModal, setShowModal] = (0, import_react27.useState)(false);
3889
+ const [loading, setLoading] = (0, import_react27.useState)(false);
3890
+ const [tableDataRows, setTableDataRows] = (0, import_react27.useState)([]);
3891
+ const fetchData = async () => {
3892
+ setLoading(true);
3893
+ try {
3894
+ const response = await fetchDataCallback();
3895
+ onFetchData && onFetchData(response);
3896
+ setData(response);
3897
+ const items = Array.isArray(response) ? response : [response];
3898
+ const tabData = items.map((r) => configureColumnsCallback(r));
3899
+ setTableDataRows(tabData);
3900
+ } catch (error) {
3901
+ console.error("Erro ao buscar dados na ReusableTable:", error);
3902
+ } finally {
3903
+ setLoading(false);
3904
+ }
3905
+ };
3906
+ (0, import_react27.useEffect)(() => {
3907
+ fetchData();
3908
+ }, []);
3909
+ const handleRowClick = (td) => {
3910
+ setSelectedItem(td.dataObj);
3911
+ setShowModal(true);
3912
+ };
3913
+ const handleCloseModal = () => {
3914
+ setShowModal(false);
3915
+ setSelectedItem(null);
3916
+ };
3917
+ return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_jsx_runtime52.Fragment, { children: [
3918
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_react_bootstrap36.Table, { striped: true, bordered: true, hover: true, responsive: true, children: [
3919
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("tr", { children: headers.map((col, index) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("th", { children: col }, index)) }) }),
3920
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("tbody", { children: loading ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("td", { colSpan: headers.length, className: "text-center py-4", children: "Carregando..." }) }) : tableDataRows.length > 0 ? tableDataRows.map((td, index) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
3921
+ "tr",
3922
+ {
3923
+ onClick: () => handleRowClick(td),
3924
+ style: { cursor: "pointer" },
3925
+ children: td.columns.map((col, colIndex) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("td", { children: col || "N/A" }, colIndex))
3926
+ },
3927
+ index
3928
+ )) : /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("td", { colSpan: headers.length, className: "text-center py-4", children: "Nenhum dado encontrado." }) }) })
3929
+ ] }),
3930
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_react_bootstrap36.Modal, { show: showModal, onHide: handleCloseModal, centered: true, children: [
3931
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_react_bootstrap36.Modal.Header, { closeButton: true, children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_react_bootstrap36.Modal.Title, { children: "Detalhes" }) }),
3932
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_react_bootstrap36.Modal.Body, { children: selectedItem && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { children: modalContent ? modalContent(selectedItem) : "Visualizando detalhes do item." }) }),
3933
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_react_bootstrap36.Modal.Footer, { children: [
3934
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_react_bootstrap36.Button, { variant: "outline-secondary", onClick: handleCloseModal, children: "Fechar" }),
3935
+ modalButtonCallback && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
3936
+ import_react_bootstrap36.Button,
3937
+ {
3938
+ variant: "primary",
3939
+ onClick: () => {
3940
+ modalButtonCallback(selectedItem);
3941
+ handleCloseModal();
3942
+ },
3943
+ children: confirmLabel
3944
+ }
3945
+ )
3946
+ ] })
3947
+ ] })
3948
+ ] });
3949
+ };
3950
+
3951
+ // src/text/TextWithMore.tsx
3952
+ var import_react28 = require("react");
3953
+ var import_react_bootstrap37 = require("react-bootstrap");
3954
+ var import_jsx_runtime53 = require("react/jsx-runtime");
3955
+ var TextWithMore = ({
3956
+ text = "Carregando...",
3957
+ maxLength,
3958
+ moreLabel = "ver mais",
3959
+ lessLabel = "ver menos"
3960
+ }) => {
3961
+ const [expanded, setExpanded] = (0, import_react28.useState)(false);
3962
+ const handleToggleExpand = () => {
3963
+ setExpanded(!expanded);
3964
+ };
3965
+ const isTruncated = text.length > maxLength;
3966
+ const displayText = isTruncated && !expanded ? text.slice(0, maxLength) + "\u2026" : text;
3967
+ return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, { children: [
3968
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "text-with-more-content", children: displayText }),
3969
+ isTruncated && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
3970
+ import_react_bootstrap37.Button,
3971
+ {
3972
+ variant: "link",
3973
+ className: "p-0 ms-2",
3974
+ style: { fontSize: "0.85rem", textDecoration: "none" },
3975
+ onClick: handleToggleExpand,
3976
+ children: expanded ? lessLabel : moreLabel
3977
+ }
3978
+ )
3979
+ ] });
3980
+ };
3981
+
3982
+ // src/index.ts
3983
+ var import_ui_kit_sgp = require("@teraprox/ui-kit-sgp");
3984
+ // Annotate the CommonJS export names for ESM import in node:
3985
+ 0 && (module.exports = {
3986
+ ActionButtons,
3987
+ AddButton,
3988
+ AdvancedFilterBar,
3989
+ AnexoManager,
3990
+ ApproveAndReproveButtons,
3991
+ AsyncButton,
3992
+ AutoComplete,
3993
+ BonusButton,
3994
+ BranchDropDisplay,
3995
+ ButtonWithDropdown,
3996
+ CalculadoraCorrecaoModal,
3997
+ CalculoCorrecao,
3998
+ CampoDeVerificacaoV2,
3999
+ CheckBox,
4000
+ ClickToWriteField,
4001
+ ColorPicker,
4002
+ ConfigObject,
4003
+ DeleteButton,
4004
+ DeleteConfirm,
4005
+ ExpandableCard,
4006
+ FindRecursoByTagField,
4007
+ FormField,
4008
+ FrequenciaFormV2,
4009
+ Generic3DotMenu,
4010
+ GenericChart,
4011
+ GenericDisplay,
4012
+ GenericForm,
4013
+ GenericREchart,
4014
+ GenericSelect,
4015
+ GenericSelectOps,
4016
+ IconLabelItem,
4017
+ IconLabelList,
4018
+ ImageViewModal,
4019
+ JustificativaModal,
4020
+ LoadingButton,
4021
+ LoadingProgress,
4022
+ MailSender,
4023
+ MenuEvent,
4024
+ ModalBasicTemplate,
4025
+ NavigateButton,
4026
+ NotificationBell,
4027
+ NotificationItem,
4028
+ PeriodSelector,
4029
+ QrCodeScanButton,
4030
+ QrReader,
4031
+ RateLimitBar,
4032
+ RecursoDisplayer,
4033
+ ResponsiveContainer,
4034
+ ReusableTableWithModal,
4035
+ SectorSelector,
4036
+ SelectDateModal,
4037
+ StatusBadge,
4038
+ StatusIndicator,
4039
+ StatusLight,
4040
+ StatusPills,
4041
+ Switch,
4042
+ SwitchOnClick,
4043
+ TarefaUnidadeForm,
4044
+ TextWithMore,
4045
+ TimerDisplay,
4046
+ UnidadeMaterialCard,
4047
+ UnidadeMaterialForm,
4048
+ UnifiedPeriodSelector,
4049
+ UploadArea,
4050
+ UuidPill,
4051
+ VerticalItemsDisplay
4052
+ });