forlogic-core 2.3.2 → 2.3.4
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/action-plans/auth/services/AuthService.d.ts +19 -0
- package/dist/action-plans/exports/ui.d.ts +2 -0
- package/dist/action-plans/i18n/LanguageBootstrap.d.ts +14 -0
- package/dist/action-plans/i18n/index.d.ts +1 -0
- package/dist/action-plans/index.d.ts +14 -103
- package/dist/action-plans/index.esm.js +1 -1
- package/dist/action-plans/index.js +1 -1
- package/dist/action-plans/types.d.ts +361 -551
- package/dist/audit-trail/auth/services/AuthService.d.ts +19 -0
- package/dist/audit-trail/exports/ui.d.ts +2 -0
- package/dist/audit-trail/i18n/LanguageBootstrap.d.ts +14 -0
- package/dist/audit-trail/i18n/index.d.ts +1 -0
- package/dist/audit-trail/index.d.ts +8 -103
- package/dist/audit-trail/types.d.ts +173 -567
- package/dist/auth/services/AuthService.d.ts +19 -0
- package/dist/auth/services/TokenService.d.ts +1 -0
- package/dist/auth/utils/authDebug.d.ts +18 -0
- package/dist/components/ui/combobox.d.ts +2 -1
- package/dist/exports/ui.d.ts +2 -0
- package/dist/i18n/LanguageBootstrap.d.ts +14 -0
- package/dist/i18n/index.d.ts +1 -0
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/leadership/auth/services/AuthService.d.ts +19 -0
- package/dist/leadership/exports/ui.d.ts +2 -0
- package/dist/leadership/i18n/LanguageBootstrap.d.ts +14 -0
- package/dist/leadership/i18n/index.d.ts +1 -0
- package/dist/leadership/index.d.ts +12 -103
- package/dist/leadership/types.d.ts +13 -593
- package/dist/places/auth/services/AuthService.d.ts +19 -0
- package/dist/places/exports/ui.d.ts +2 -0
- package/dist/places/i18n/LanguageBootstrap.d.ts +14 -0
- package/dist/places/i18n/index.d.ts +1 -0
- package/dist/places/index.d.ts +8 -104
- package/dist/places/types.d.ts +6 -599
- package/dist/qualiex/hooks/useQualiexReady.d.ts +15 -0
- package/dist/qualiex/services/qualiexApiService.d.ts +18 -0
- package/dist/sign/auth/services/AuthService.d.ts +19 -0
- package/dist/sign/exports/ui.d.ts +2 -0
- package/dist/sign/i18n/LanguageBootstrap.d.ts +14 -0
- package/dist/sign/i18n/index.d.ts +1 -0
- package/dist/sign/index.d.ts +8 -104
- package/dist/sign/index.esm.js +1 -1
- package/dist/sign/index.js +1 -1
- package/dist/sign/types.d.ts +46 -596
- package/dist/updates/components/UpdatesBar.d.ts +10 -0
- package/dist/updates/components/UpdatesDialog.d.ts +10 -0
- package/dist/updates/components/UserUpdatesViewer.d.ts +5 -0
- package/dist/updates/hooks/useUserUpdates.d.ts +5 -0
- package/dist/updates/index.d.ts +9 -0
- package/dist/updates/services/userUpdatesApi.d.ts +3 -0
- package/dist/updates/types.d.ts +24 -0
- package/dist/updates/utils/dismissedStore.d.ts +4 -0
- package/package.json +2 -2
|
@@ -42,4 +42,23 @@ export declare class AuthService {
|
|
|
42
42
|
* Extrai alias do access token (campo default)
|
|
43
43
|
*/
|
|
44
44
|
private static extractAliasFromAccessToken;
|
|
45
|
+
/**
|
|
46
|
+
* Detecta o alias a partir do subdomínio da URL atual.
|
|
47
|
+
*
|
|
48
|
+
* Padrões reconhecidos:
|
|
49
|
+
* - `educacao.sabergestao.com.br` → "sabergestao"
|
|
50
|
+
* - `<modulo>.<alias>.<tld>` → alias
|
|
51
|
+
* - `<alias>.qualiex.com` → alias
|
|
52
|
+
* - localhost / *.lovable.app / *.lovable.dev → null
|
|
53
|
+
*/
|
|
54
|
+
private static getSubdomainAlias;
|
|
55
|
+
/**
|
|
56
|
+
* Resolve o alias ativo seguindo prioridade:
|
|
57
|
+
* 1. Subdomínio da URL (se válido contra companies)
|
|
58
|
+
* 2. Alias do Supabase token (se válido)
|
|
59
|
+
* 3. Alias armazenado (se válido)
|
|
60
|
+
* 4. `default` do access token (se válido)
|
|
61
|
+
* 5. Primeira company
|
|
62
|
+
*/
|
|
63
|
+
private static resolveAliasFromContext;
|
|
45
64
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Componente interno (renderiza `null`) que aplica automaticamente o idioma
|
|
3
|
+
* do usuário ao i18next assim que `useModuleAccess` resolver a associação atual.
|
|
4
|
+
*
|
|
5
|
+
* - Fonte de verdade: `association.language` (vindo de `/users/{userId}/associations`).
|
|
6
|
+
* - Não persiste em `localStorage` — o React-Query já cacheia o resultado e o
|
|
7
|
+
* próximo boot refaz a chamada para revalidar.
|
|
8
|
+
* - Reage a `switchUnit`: ao trocar de unidade, useModuleAccess refaz a query
|
|
9
|
+
* e o efeito reaplica o idioma da nova associação.
|
|
10
|
+
*
|
|
11
|
+
* Para que funcione, deve ser montado dentro do `AuthProvider`, `LocaleProvider`
|
|
12
|
+
* e `ModuleProvider`. `CoreProviders` já cuida disso.
|
|
13
|
+
*/
|
|
14
|
+
export declare function LanguageBootstrap(): any;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* Import this instead of importing directly from react-i18next.
|
|
6
6
|
*/
|
|
7
7
|
export { default as i18n, addAppTranslations } from './config';
|
|
8
|
+
export { LanguageBootstrap } from './LanguageBootstrap';
|
|
8
9
|
export { useTranslation } from 'react-i18next';
|
|
9
10
|
export { I18nextProvider } from 'react-i18next';
|
|
10
11
|
export { mergeTranslationFiles } from './utils';
|
|
@@ -1,104 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export { Badge } from './components/ui/badge';
|
|
14
|
-
export { LoadingState } from './components/ui/loading-state';
|
|
15
|
-
export { Toaster, toast } from './components/ui/sonner';
|
|
16
|
-
export { DisabledMenuItem } from './components/ui/disabled-menu-item';
|
|
17
|
-
export { Combobox } from './components/ui/combobox';
|
|
18
|
-
export type { ComboboxProps } from './components/ui/combobox';
|
|
19
|
-
export { Combobox as SelectSearch } from './components/ui/combobox';
|
|
20
|
-
export type { ComboboxProps as SelectSearchProps } from './components/ui/combobox';
|
|
21
|
-
export { Combobox as MultiSelect } from './components/ui/combobox';
|
|
22
|
-
export type { ComboboxProps as MultiSelectProps } from './components/ui/combobox';
|
|
23
|
-
export { ComboTree } from './components/ui/combo-tree';
|
|
24
|
-
export type { ComboTreeProps, ComboTreeOption } from './components/ui/combo-tree';
|
|
25
|
-
export { createSimpleService } from './crud/createSimpleService';
|
|
26
|
-
export { createCrudPage, createSimpleSaveHandler, CrudPageInternal } from './crud/createCrudPage';
|
|
27
|
-
export { generateCrudConfig } from './crud/generateCrudConfig';
|
|
28
|
-
export { default as BaseForm } from './crud/components/BaseForm';
|
|
29
|
-
export { useAuth } from './auth/contexts/AuthContext';
|
|
30
|
-
export { ProtectedRoute } from './auth/components/ProtectedRoute';
|
|
31
|
-
export { AliasRouteGuard } from './auth/components/AliasRouteGuard';
|
|
32
|
-
export { AliasRedirect } from './auth/components/AliasRedirect';
|
|
33
|
-
export type { AliasRouteGuardProps } from './auth/components/AliasRouteGuard';
|
|
34
|
-
export { CallbackPage } from './auth/pages/CallbackPage';
|
|
35
|
-
export { LoginPage } from './auth/pages/LoginPage';
|
|
36
|
-
export { cn } from './utils';
|
|
37
|
-
export { formatDatetime, formatDate, formatCurrency } from './utils';
|
|
38
|
-
export { usePageMetadata, PageMetadataProvider, usePageMetadataContext } from './contexts/PageMetadataContext';
|
|
39
|
-
export type { PageBreadcrumbItem } from './contexts/PageMetadataContext';
|
|
40
|
-
export type { CrudEntity, FormSection, BulkAction, CrudFilter, QualiexUserFieldMapping, QualiexEnrichmentConfig } from './types';
|
|
41
|
-
export { setupQualiexCore } from './setup';
|
|
42
|
-
export { CoreProviders } from './providers/CoreProviders';
|
|
43
|
-
export type { CoreProvidersProps, AppTranslationsMap } from './providers/CoreProviders';
|
|
44
|
-
export * from './exports/ui';
|
|
45
|
-
export * from './exports/crud';
|
|
46
|
-
export * from './exports/integrations';
|
|
47
|
-
export { default as AppHeader } from './components/layout/AppHeader';
|
|
48
|
-
export * from './components/layout/AppSidebar';
|
|
49
|
-
export * from './components/layout/AppLayout';
|
|
50
|
-
export { SidebarHeader } from './components/layout/SidebarHeader';
|
|
51
|
-
export type { SidebarHeaderProps } from './components/layout/SidebarHeader';
|
|
52
|
-
export { SidebarLogo } from './components/layout/SidebarLogo';
|
|
53
|
-
export { SidebarActionTrigger } from './components/layout/SidebarActionTrigger';
|
|
54
|
-
export type { SidebarActionTriggerProps } from './components/layout/SidebarActionTrigger';
|
|
55
|
-
export { BodyContent, ContentContainer } from './components/layout/BodyContent';
|
|
56
|
-
export type { BodyContentProps, ContentContainerProps, BreadcrumbItemConfig } from './components/layout/BodyContent';
|
|
57
|
-
export * from './components/ErrorBoundary';
|
|
58
|
-
export * from './hooks/useActiveModules';
|
|
59
|
-
export * from './hooks/useDebounce';
|
|
60
|
-
export * from './hooks/usePageTitle';
|
|
61
|
-
export { useMediaQuery, useIsMobile } from './hooks/useMediaQuery';
|
|
62
|
-
export * from './hooks/usePermissionQuery';
|
|
63
|
-
export { useSidebarResize } from './hooks/useSidebarResize';
|
|
64
|
-
export { useColumnResize } from './hooks/useColumnResize';
|
|
65
|
-
export { useRowResize } from './hooks/useRowResize';
|
|
66
|
-
export { useWizard } from './hooks/useWizard';
|
|
67
|
-
export type { WizardStep, UseWizardOptions, UseWizardReturn } from './hooks/useWizard';
|
|
68
|
-
export { useAliasFromUrl } from './hooks/useAliasFromUrl';
|
|
69
|
-
export type { UseAliasFromUrlOptions, UseAliasFromUrlReturn } from './hooks/useAliasFromUrl';
|
|
70
|
-
export { useModuleAccess } from './hooks/useModuleAccess';
|
|
71
|
-
export { useDerivedContractedModules } from './hooks/useDerivedContractedModules';
|
|
72
|
-
export * from './i18n';
|
|
73
|
-
export * from './contexts/LocaleContext';
|
|
74
|
-
export * from './hooks/useI18nFormatters';
|
|
75
|
-
export * from './utils/formatters/dateFormatters';
|
|
76
|
-
export * from './utils/formatters/currencyFormatters';
|
|
77
|
-
export * from './contexts/NavigationContext';
|
|
78
|
-
export { ModalStateProvider, useModalState, useHasOpenModal } from './contexts/ModalStateContext';
|
|
79
|
-
export type { ModalStateProviderProps } from './contexts/ModalStateContext';
|
|
80
|
-
export { ModuleProvider, useModuleConfig } from './contexts/ModuleContext';
|
|
81
|
-
export type { ModuleProviderProps } from './contexts/ModuleContext';
|
|
82
|
-
export * from './services/BaseService';
|
|
83
|
-
export { errorService } from './services/ErrorService';
|
|
84
|
-
export { emailService, EmailService } from './services/EmailService';
|
|
85
|
-
export type { SendEmailParams } from './services/EmailService';
|
|
86
|
-
export * from './services/QualiexEnrichmentService';
|
|
87
|
-
export { resolveFieldMappings, deriveNameField, deriveEmailField, deriveUsernameField } from './services/QualiexFieldHelpers';
|
|
88
|
-
export * from './utils';
|
|
89
|
-
export { loadForlogicFonts } from './utils/load-fonts';
|
|
1
|
+
export { ActionPlanPage } from './components/ActionPlanPage';
|
|
2
|
+
export { ActionPlanGeneralTab } from './components/ActionPlanGeneralTab';
|
|
3
|
+
export { ActionPlanProgressTab } from './components/ActionPlanProgressTab';
|
|
4
|
+
export { ActionPlanPredecessorsTab } from './components/ActionPlanPredecessorsTab';
|
|
5
|
+
export { ActionPlanCostTab } from './components/ActionPlanCostTab';
|
|
6
|
+
export { ActionPlanCommentsTab } from './components/ActionPlanCommentsTab';
|
|
7
|
+
export { ActionPlanHistoryTab } from './components/ActionPlanHistoryTab';
|
|
8
|
+
export { ActionPlanAttachmentsTab } from './components/ActionPlanAttachmentsTab';
|
|
9
|
+
export { ActionPlanStatusBadge } from './components/ActionPlanStatusBadge';
|
|
10
|
+
export { ActionPlanProgressDialog } from './components/ActionPlanProgressDialog';
|
|
11
|
+
export { useActionPlan } from './hooks/useActionPlan';
|
|
12
|
+
export { useActionPlanProgress } from './hooks/useActionPlanProgress';
|
|
90
13
|
export * from './types';
|
|
91
|
-
export * from './
|
|
92
|
-
export
|
|
93
|
-
export { getEnvironmentConfig, isDevEnv, getAppEnv, type AppEnv } from './config/environments';
|
|
94
|
-
export type { EnvironmentConfig } from './config/environments';
|
|
95
|
-
export { setBackendMode, getBackendMode, isSupabaseBackend } from './config/backend';
|
|
96
|
-
export type { BackendMode } from './config/backend';
|
|
97
|
-
export { isSupabaseConfigured } from './supabase/SupabaseSingleton';
|
|
98
|
-
export * from './assets';
|
|
99
|
-
export * from './components/modules';
|
|
100
|
-
export * from './media';
|
|
101
|
-
export * from './file-upload';
|
|
102
|
-
export * from './custom-form-fields';
|
|
103
|
-
export * from './approval-flow';
|
|
104
|
-
export * from './team-selector';
|
|
14
|
+
export * from './constants';
|
|
15
|
+
export { formatTime, formatTimeProgress, getProgressColor } from './utils/formatTime';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as a,Fragment as t}from"react/jsx-runtime";import{StatusBadge as n,Label as i,cn as s,Input as r,Select as l,SelectTrigger as c,SelectValue as d,SelectContent as o,SelectItem as m,DatePicker as u,Textarea as p,Dialog as h,DialogContent as g,DialogHeader as f,DialogTitle as v,DialogFooter as x,Button as N,Progress as b,DropdownMenu as y,DropdownMenuTrigger as C,ActionButton as w,DropdownMenuContent as _,DropdownMenuItem as D,Badge as S,DropdownMenuSeparator as k,LoadingState as P,Tabs as A,TabsList as F,TabsTrigger as I,TabsContent as E}from"forlogic-core";import{X as L,Pause as R,CheckCircle2 as j,ShieldCheck as B,Play as z,Clock as T,Plus as $,MessageSquare as V,Calendar as M,Smartphone as U,Paperclip as O,ArrowLeft as q,MoreVertical as W}from"lucide-react";import H from"i18next";import G,{useState as K,useEffect as J,useCallback as Q,useRef as X}from"react";import{useTranslation as Y}from"react-i18next";var Z,ee,ae,te,ne,ie,se,re,le,ce;(ee=Z||(Z={}))[ee.waitingStart=1]="waitingStart",ee[ee.running=2]="running",ee[ee.effectivenessCheck=3]="effectivenessCheck",ee[ee.done=4]="done",ee[ee.suspended=5]="suspended",ee[ee.canceled=6]="canceled",(te=ae||(ae={}))[te.low=0]="low",te[te.medium=1]="medium",te[te.high=2]="high",(ie=ne||(ne={}))[ie.plan=2]="plan",ie[ie.occurrence=3]="occurrence",ie[ie.risk=4]="risk",ie[ie.decisions=5]="decisions",ie[ie.audit=6]="audit",ie[ie.strategyExtension=7]="strategyExtension",ie[ie.standardization=8]="standardization",ie[ie.supplier=9]="supplier",ie[ie.auditItems=10]="auditItems",(re=se||(se={}))[re.currentProgress=1]="currentProgress",re[re.cumulativeProgress=2]="cumulativeProgress",(ce=le||(le={})).uploading="uploading",ce.waiting="waiting",ce.done="done",ce.error="error",ce.canceled="canceled",ce.duplicateItem="duplicateItem";const de={[Z.waitingStart]:"#D6D6D6",[Z.running]:"#DAE9F4",[Z.effectivenessCheck]:"#1B75BB29",[Z.done]:"#DDEECA",[Z.suspended]:"#FFF2D6",[Z.canceled]:"#F4433629"},oe={[Z.waitingStart]:"#666666",[Z.running]:"#1B75BB",[Z.effectivenessCheck]:"#1B75BB",[Z.done]:"#4CAF50",[Z.suspended]:"#FF9800",[Z.canceled]:"#F44336"},me={[Z.waitingStart]:"waiting-start",[Z.running]:"running",[Z.effectivenessCheck]:"effectiveness-check",[Z.done]:"done",[Z.suspended]:"suspended",[Z.canceled]:"canceled"};function ue(){return{[Z.waitingStart]:H.t("ap_status_waiting_start"),[Z.running]:H.t("ap_status_running"),[Z.effectivenessCheck]:H.t("ap_status_effectiveness_check"),[Z.done]:H.t("ap_status_done"),[Z.suspended]:H.t("ap_status_suspended"),[Z.canceled]:H.t("ap_status_canceled")}}const pe=new Proxy({},{get:(e,a)=>{if("symbol"==typeof a)return;return ue()[a]}});function he(){return[{id:"immediate",label:H.t("ap_type_immediate")},{id:"corrective",label:H.t("ap_type_corrective")},{id:"preventive",label:H.t("ap_type_preventive")},{id:"improvement",label:H.t("ap_type_improvement")},{id:"standardization",label:H.t("ap_type_standardization")}]}const ge=[{id:"immediate",label:"Imediata"},{id:"corrective",label:"Corretiva"},{id:"preventive",label:"Preventiva"},{id:"improvement",label:"Oportunidade de Melhoria"},{id:"standardization",label:"Padronização"}];function fe(){return[{id:ae.low,label:H.t("ap_priority_low"),color:"#4CAF50"},{id:ae.medium,label:H.t("ap_priority_medium"),color:"#FF9800"},{id:ae.high,label:H.t("ap_priority_high"),color:"#F44336"}]}const ve=[{id:ae.low,label:"Baixa",color:"#4CAF50"},{id:ae.medium,label:"Média",color:"#FF9800"},{id:ae.high,label:"Alta",color:"#F44336"}],xe=[Z.done,Z.canceled],Ne=[Z.waitingStart,Z.running,Z.effectivenessCheck,Z.suspended];function be(e){const{actionPlan:a,isNew:t=!1,config:n,onSave:i,onCancel:s,onDelete:r,onChangeStatus:l}=e,[c,d]=K({formData:a||{},isLoading:e.isLoading||!1,isSaving:!1,activeTab:"general",isFormDisabled:!1});J(()=>{a&&d(e=>({...e,formData:a,isFormDisabled:n?.disableFields||xe.includes(a.statusId)}))},[a,n?.disableFields]),J(()=>{d(a=>({...a,isLoading:e.isLoading||!1}))},[e.isLoading]);const o=Q((e,a)=>{d(t=>({...t,formData:{...t.formData,[e]:a}}))},[]),m=Q(e=>{d(a=>({...a,activeTab:e}))},[]),u=Q(async()=>{if(i){d(e=>({...e,isSaving:!0}));try{await i(c.formData)}finally{d(e=>({...e,isSaving:!1}))}}},[i,c.formData]),p=Q(async e=>{if(l&&c.formData.id){d(e=>({...e,isLoading:!0}));try{await l(c.formData.id,e)}finally{d(e=>({...e,isLoading:!1}))}}},[l,c.formData.id]),h=Q(async()=>{if(r&&c.formData.id){d(e=>({...e,isLoading:!0}));try{await r(c.formData.id)}finally{d(e=>({...e,isLoading:!1}))}}},[r,c.formData.id]);return{formData:c.formData,isLoading:c.isLoading,isSaving:c.isSaving,activeTab:c.activeTab,isFormDisabled:c.isFormDisabled,updateField:o,setActiveTab:m,save:u,changeStatus:p,remove:h,cancel:s}}const ye={[Z.waitingStart]:{label:"",color:"#8B7355",icon:T},[Z.running]:{label:"",color:"#2E7D5B",icon:z},[Z.effectivenessCheck]:{label:"",color:"#4A6FA5",icon:B},[Z.done]:{label:"",color:"#3D7A40",icon:j},[Z.suspended]:{label:"",color:"#6B7280",icon:R},[Z.canceled]:{label:"",color:"#B44A4A",icon:L}};function Ce({status:a,labels:t,className:i,size:s,showIcon:r,variant:l}){const c=ue(),d=ye[a];if(!d)return null;const o=t?.[a]||c[a]||"";return e(n,{label:o,color:d.color,icon:d.icon,size:s,showIcon:r,variant:l,className:i})}function we({formData:t,updateField:n,disabled:h=!1,users:g=[],places:f=[],actionTypes:v,causes:x=[],parentActions:N=[],config:b}){const{t:y}=Y(),C=b?.requiredFields,w=v||ge,_=e=>{if(b?.hiddenFields?.includes(e))return!1;if(b?.visibleFields&&b.visibleFields.length>0)return b.visibleFields.includes(e);const a=`${e}Visible`;return!C||!(a in C)||!1!==C[a]},D=e=>C?!!C[e]:"name"===e,S=G.useMemo(()=>{if(t.startDate&&t.endDate){const e=new Date(t.startDate),a=new Date(t.endDate).getTime()-e.getTime();return Math.max(0,Math.ceil(a/864e5))}return t.duration||0},[t.startDate,t.endDate,t.duration]);return a("div",{className:"space-y-6 p-1",children:[a("div",{className:"space-y-2",children:[e(i,{className:s(D("name")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Nome"}),e(r,{value:t.name||"",onChange:e=>n("name",e.target.value),maxLength:500,disabled:h,placeholder:y("ap_plan_name_placeholder")})]}),a("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[_("responsibleWho")&&a("div",{className:"space-y-2",children:[e(i,{className:s(D("responsibleWho")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Responsável"}),a(l,{value:t.responsibleId||"",onValueChange:e=>n("responsibleId",e),disabled:h,children:[e(c,{children:e(d,{placeholder:y("ap_select_responsible")})}),e(o,{children:g.map(a=>e(m,{value:a.id,children:a.name},a.id))})]})]}),_("checkerWho")&&a("div",{className:"space-y-2",children:[e(i,{className:s(D("checkerWho")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Verificador"}),a(l,{value:t.checkerId||"",onValueChange:e=>n("checkerId",e),disabled:h,children:[e(c,{children:e(d,{placeholder:y("ap_select_checker")})}),e(o,{children:g.map(a=>e(m,{value:a.id,children:a.name},a.id))})]})]})]}),a("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[_("place")&&a("div",{className:"space-y-2",children:[e(i,{className:s(D("place")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Local"}),a(l,{value:t.placeId||"",onValueChange:e=>n("placeId",e),disabled:h,children:[e(c,{children:e(d,{placeholder:y("ap_select_place")})}),e(o,{children:_e(f).map(a=>e(m,{value:a.id,children:a.name},a.id))})]})]}),_("planType")&&a("div",{className:"space-y-2",children:[e(i,{className:s(D("planType")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Tipo de Ação"}),a(l,{value:t.typeId||"",onValueChange:e=>n("typeId",e),disabled:h,children:[e(c,{children:e(d,{placeholder:y("ap_select_type")})}),e(o,{children:w.map(a=>e(m,{value:a.id,children:a.label},a.id))})]})]})]}),a("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[_("priority")&&a("div",{className:"space-y-2",children:[e(i,{className:s(D("priority")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Prioridade"}),a(l,{value:t.priorityType?.toString()||"",onValueChange:e=>n("priorityType",Number(e)),disabled:h,children:[e(c,{children:e(d,{placeholder:y("ap_select_priority")})}),e(o,{children:ve.map(t=>e(m,{value:t.id.toString(),children:a("span",{className:"flex items-center gap-2",children:[e("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:t.color}}),t.label]})},t.id))})]})]}),N.length>0&&a("div",{className:"space-y-2",children:[e(i,{children:y("ap_belongs_to")}),a(l,{value:t.parentId||"",onValueChange:e=>n("parentId",e),disabled:h,children:[e(c,{children:e(d,{placeholder:y("ap_select_parent")})}),e(o,{children:N.map(a=>e(m,{value:a.id,children:a.label},a.id))})]})]})]}),a("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[_("startDate")&&a("div",{className:"space-y-2",children:[e(i,{className:s(D("startDate")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Data de Início"}),e(u,{date:t.startDate?new Date(t.startDate):void 0,onDateChange:e=>n("startDate",e||null),disabled:h,placeholder:y("ap_select_date")})]}),_("endDate")&&a("div",{className:"space-y-2",children:[e(i,{className:s(D("endDate")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Data de Término"}),e(u,{date:t.endDate?new Date(t.endDate):void 0,onDateChange:e=>n("endDate",e||null),disabled:h,placeholder:y("ap_select_date"),disabledDates:t.startDate?e=>e<new Date(t.startDate):void 0})]}),a("div",{className:"space-y-2",children:[e(i,{children:y("ap_duration_days")}),e(r,{type:"number",value:S,disabled:!0,className:"bg-muted"})]})]}),_("estimatedCost")&&a("div",{className:"space-y-2 max-w-xs",children:[e(i,{className:s(D("estimatedCost")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Custo Estimado"}),a("div",{className:"relative",children:[e("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"R$"}),e(r,{type:"number",min:0,step:.01,value:t.estimatedCost||"",onChange:e=>n("estimatedCost",Number(e.target.value)),disabled:h,className:"pl-9",placeholder:"0,00"})]})]}),_("cause")&&x.length>0&&a("div",{className:"space-y-2",children:[e(i,{children:"Causa"}),a(l,{value:t.causeId||"",onValueChange:e=>n("causeId",e),disabled:h,children:[e(c,{children:e(d,{placeholder:y("ap_select_cause")})}),e(o,{children:x.map(a=>e(m,{value:a.id,children:a.label},a.id))})]})]}),_("description")&&a("div",{className:"space-y-2",children:[e(i,{className:s(D("description")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Descrição"}),e(p,{value:t.description||"",onChange:e=>n("description",e.target.value),maxLength:4e3,disabled:h,rows:4,placeholder:y("ap_description_placeholder")})]}),_("justification")&&a("div",{className:"space-y-2",children:[e(i,{className:s(D("justification")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Justificativa"}),e(p,{value:t.justification||"",onChange:e=>n("justification",e.target.value),maxLength:4e3,disabled:h,rows:4,placeholder:y("ap_justification_placeholder")})]})]})}function _e(e,a=0){const t=[];for(const n of e)t.push({...n,depth:a}),n.children?.length&&t.push(..._e(n.children,a+1));return t}function De(e){const{progress:a,onReportProgress:t,onEditProgress:n,onDeleteProgress:i}=e,[s,r]=K(!1),[l,c]=K(null),d=!!a&&Ne.includes(a.status),o=Q(async e=>{if(t&&a){r(!0);try{const n=100===e.percentProgress;await t({id:a.id,...e,conclude:n})}finally{r(!1)}}},[t,a]),m=Q(async e=>{if(n){r(!0);try{await n(e)}finally{r(!1),c(null)}}},[n]),u=Q(async e=>{if(i){r(!0);try{await i(e)}finally{r(!1)}}},[i]);return{progress:a,canReportProgress:d,isSubmitting:s,editingReport:l,setEditingReport:c,reportProgress:o,editProgress:m,deleteProgress:u}}function Se(e){if(!e)return"";let a=(e||"").trim();if(!a)return"00:00";if(a.includes(":")){const e=a.split(":");if(e.length>=2){const a=e[0].replace(/\D/g,""),t=e[1].replace(/\D/g,"");let n=parseInt(a)||0,i=parseInt(t)||0;return n+=Math.floor(i/60),i%=60,`${n.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`}}if(a=a.replace(/\D/g,""),!a)return"00:00";let t=0,n=0;return 4===a.length?(t=parseInt(a.substring(0,2))||0,n=parseInt(a.substring(2,4))||0,t+=Math.floor(n/60),n%=60):(t=parseInt(a)||0,n=0),`${t.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`}function ke(e){if(null==e)return"00:00";const a=String(e).replace(/\D/g,"");if(a.length<3){let e=parseInt(a)||0;const t=Math.floor(e/60);return e%=60,`${t.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`}{const e=a.slice(-2),t=a.slice(0,-2);let n=parseInt(t)||0,i=parseInt(e)||0;return n+=Math.floor(i/60),i%=60,`${n.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`}}function Pe(e){return 100===e?"#84c148":e>0?"#1b75bb":""}function Ae({open:t,onOpenChange:n,report:s,onSave:l,isSubmitting:c=!1}){const{t:d}=Y(),[o,m]=K(s?.percentProgress||0),[u,b]=K(s?.timeProgress||""),[y,C]=K(s?.comments||""),w=o!==(s?.percentProgress??0)||u!==(s?.timeProgress??"")||y!==(s?.comments??"");G.useEffect(()=>{s&&(m(s.percentProgress),b(s.timeProgress||""),C(s.comments||""))},[s]);return e(h,{open:t,onOpenChange:n,children:a(g,{className:"sm:max-w-md",variant:"form",isDirty:w,children:[e(f,{children:e(v,{children:d("ap_edit_progress")})}),a("div",{className:"space-y-4 py-4",children:[a("div",{className:"space-y-2",children:[e(i,{children:d("ap_progress_percent")}),e(r,{type:"number",min:0,max:100,value:o,onChange:e=>m(Number(e.target.value))})]}),a("div",{className:"space-y-2",children:[e(i,{children:d("ap_time_spent")}),e(r,{value:u,onChange:e=>b(e.target.value),onBlur:()=>b(Se(u)||""),placeholder:"00:00"})]}),a("div",{className:"space-y-2",children:[e(i,{children:d("ap_comments")}),e(p,{value:y,onChange:e=>C(e.target.value),rows:3,maxLength:4e3})]})]}),a(x,{children:[e(N,{variant:"outline",onClick:()=>n(!1),disabled:c,children:"Cancelar"}),e(N,{onClick:()=>{s&&l({...s,percentProgress:o,timeProgress:Se(u)||"00:00",comments:y})},disabled:c,children:c?"Salvando...":"Salvar"})]})]})})}function Fe(t){const{t:n}=Y(),{progress:s,canReportProgress:l,isSubmitting:c,editingReport:d,setEditingReport:o,reportProgress:m,editProgress:u,deleteProgress:h}=De(t),[g,f]=K(""),[v,x]=K(""),[y,C]=K("");if(!s)return e("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:"Sem dados de progresso disponíveis"});const w=Pe(s.percentProgress),_=!g,D=!g&&!v&&!y;return a("div",{className:"space-y-6 p-1",children:[a("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[a("div",{className:"flex items-center justify-between text-sm",children:[e("span",{className:"font-medium",children:n("ap_overall_progress")}),a("span",{className:"font-semibold",style:{color:w||void 0},children:[s.percentProgress,"%"]})]}),e(b,{value:s.percentProgress,className:"h-3"}),s.timeProgress&&a("div",{className:"text-xs text-muted-foreground",children:["Tempo total: ",ke(s.timeProgress)]})]}),l&&a("div",{className:"rounded-lg border bg-card p-4 space-y-4",children:[e("h4",{className:"text-sm font-medium",children:n("ap_report_progress")}),a("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a("div",{className:"space-y-2",children:[e(i,{children:n("ap_progress_percent")}),e(r,{type:"number",min:0,max:100,value:g,onChange:e=>f(e.target.value),placeholder:"0"})]}),a("div",{className:"space-y-2",children:[e(i,{children:n("ap_time_spent")}),e(r,{value:v,onChange:e=>x(e.target.value),onBlur:()=>x(Se(v)||""),placeholder:"00:00"})]})]}),a("div",{className:"space-y-2",children:[e(i,{children:n("ap_comments")}),e(p,{value:y,onChange:e=>C(e.target.value),rows:3,maxLength:4e3,placeholder:n("ap_progress_comment_placeholder")})]}),a("div",{className:"flex gap-2 justify-end",children:[e(N,{variant:"outline",size:"sm",onClick:()=>{f(""),x(""),C("")},disabled:D||c,children:"Limpar"}),e(N,{size:"sm",onClick:async()=>{const e=Number(g);(e||0===e)&&(await m({percentProgress:e,timeProgress:Se(v)||"00:00",comments:y}),f(""),x(""),C(""))},disabled:_||c,children:c?"Reportando...":"Reportar"})]})]}),s.reports.length>0&&a("div",{className:"space-y-3",children:[e("h4",{className:"text-sm font-medium",children:n("ap_reports_history")}),e("div",{className:"space-y-2",children:s.reports.map(a=>e(Ie,{report:a,onEdit:()=>o(a),onDelete:()=>h(a.id),disabled:!l},a.id))})]}),e(Ae,{open:!!d,onOpenChange:e=>!e&&o(null),report:d,onSave:u,isSubmitting:c})]})}function Ie({report:t,onEdit:n,onDelete:i,disabled:s}){const r=t.date?new Date(t.date):null,l=Pe(t.percentProgress);return a("div",{className:"flex items-start gap-3 rounded-lg border bg-card p-3",children:[e("div",{className:"flex-shrink-0 h-8 w-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground",children:t.userName?.charAt(0)?.toUpperCase()||"?"}),a("div",{className:"flex-1 min-w-0 space-y-1",children:[a("div",{className:"flex items-center gap-2 text-sm",children:[e("span",{className:"font-medium truncate",children:t.userName}),r&&e("span",{className:"text-xs text-muted-foreground",children:r.toLocaleDateString("pt-BR")})]}),a("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[a("span",{style:{color:l||void 0},className:"font-semibold",children:[t.percentProgress,"%"]}),t.timeProgress&&a("span",{children:["Tempo: ",ke(t.timeProgress)]})]}),t.comments&&e("p",{className:"text-xs text-muted-foreground mt-1",children:t.comments})]}),!s&&a(y,{children:[e(C,{asChild:!0,children:e(w,{})}),a(_,{align:"end",children:[e(D,{onClick:n,children:H.t("edit")}),e(D,{className:"text-destructive",onClick:i,children:H.t("ap_delete")})]})]})]})}function Ee({predecessors:t=[],availablePredecessors:n=[],onAdd:s,onRemove:r,disabled:u=!1}){const{t:p}=Y(),[h,g]=G.useState(""),f=n.filter(e=>!t.some(a=>a.predecessorId===e.id));return a("div",{className:"space-y-6 p-1",children:[!u&&f.length>0&&a("div",{className:"flex items-end gap-3",children:[a("div",{className:"flex-1 space-y-2",children:[e(i,{children:p("ap_add_predecessor")}),a(l,{value:h,onValueChange:g,children:[e(c,{children:e(d,{placeholder:p("ap_select_action")})}),e(o,{children:f.map(a=>e(m,{value:a.id,children:a.label},a.id))})]})]}),a(N,{size:"sm",onClick:()=>{h&&s&&(s(h),g(""))},disabled:!h,children:[e($,{className:"h-4 w-4 mr-1"}),"Adicionar"]})]}),t.length>0?e("div",{className:"space-y-2",children:t.map(t=>a("div",{className:"flex items-center justify-between rounded-lg border bg-card p-3",children:[a("div",{className:"flex items-center gap-3",children:[t.predecessorCode&&e("span",{className:"text-xs text-muted-foreground font-mono",children:t.predecessorCode}),e("span",{className:"text-sm font-medium",children:t.predecessorName}),null!=t.predecessorStatus&&e(Ce,{status:t.predecessorStatus})]}),!u&&r&&a(y,{children:[e(C,{asChild:!0,children:e(w,{})}),e(_,{align:"end",children:e(D,{className:"text-destructive",onClick:()=>r(t.predecessorId),children:"Remover"})})]})]},t.id))}):e("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"Nenhum predecessor adicionado"})]})}function Le({costs:t=[],onAdd:n,onEdit:s,onDelete:l,disabled:c=!1}){const{t:d}=Y(),[o,m]=K(""),[u,p]=K(""),h=t.reduce((e,a)=>e+(a.value||0),0);return a("div",{className:"space-y-6 p-1",children:[a("div",{className:"rounded-lg border bg-card p-4 flex items-center justify-between",children:[e("span",{className:"text-sm font-medium",children:d("ap_total_cost")}),a("span",{className:"text-lg font-semibold text-foreground",children:["R$ ",h.toLocaleString("pt-BR",{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),!c&&n&&a("div",{className:"rounded-lg border bg-card p-4 space-y-4",children:[e("h4",{className:"text-sm font-medium",children:d("ap_add_cost")}),a("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a("div",{className:"space-y-2",children:[e(i,{children:"Descrição"}),e(r,{value:o,onChange:e=>m(e.target.value),placeholder:d("ap_cost_description")})]}),a("div",{className:"space-y-2",children:[e(i,{children:"Valor (R$)"}),e(r,{type:"number",min:0,step:.01,value:u,onChange:e=>p(e.target.value),placeholder:"0,00"})]})]}),e("div",{className:"flex justify-end",children:a(N,{size:"sm",onClick:()=>{o&&u&&n&&(n({description:o,value:Number(u),date:(new Date).toISOString()}),m(""),p(""))},disabled:!o||!u,children:[e($,{className:"h-4 w-4 mr-1"}),"Adicionar"]})})]}),t.length>0?e("div",{className:"space-y-2",children:t.map(t=>a("div",{className:"flex items-center justify-between rounded-lg border bg-card p-3",children:[a("div",{className:"flex-1 min-w-0",children:[e("p",{className:"text-sm font-medium truncate",children:t.description}),t.date&&e("p",{className:"text-xs text-muted-foreground",children:new Date(t.date).toLocaleDateString("pt-BR")})]}),a("div",{className:"flex items-center gap-3",children:[a("span",{className:"text-sm font-semibold whitespace-nowrap",children:["R$ ",t.value.toLocaleString("pt-BR",{minimumFractionDigits:2,maximumFractionDigits:2})]}),!c&&(s||l)&&a(y,{children:[e(C,{asChild:!0,children:e(w,{})}),a(_,{align:"end",children:[s&&e(D,{onClick:()=>s(t),children:d("edit")}),l&&e(D,{className:"text-destructive",onClick:()=>l(t.id),children:d("ap_delete")})]})]})]})]},t.id))}):e("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"Nenhum custo registrado"})]})}function Re({comments:t=[],currentUserId:n,onAdd:i,onEdit:s,onDelete:r,disabled:l=!1,maxLength:c=4e3}){const{t:d}=Y(),[o,m]=K(""),[u,h]=K(!1),[g,f]=K(null),[v,x]=K(""),b=()=>{f(null),x("")};return a("div",{className:"space-y-6 p-1",children:[!l&&i&&a("div",{className:"space-y-3",children:[e(p,{value:o,onChange:e=>m(e.target.value),placeholder:d("ap_add_comment_placeholder"),maxLength:c,rows:3}),a("div",{className:"flex items-center justify-between",children:[c&&a("span",{className:"text-xs text-muted-foreground",children:[o.length,"/",c]}),a("div",{className:"flex gap-2 ml-auto",children:[e(N,{variant:"outline",size:"sm",onClick:()=>m(""),disabled:!o||u,children:"Limpar"}),e(N,{size:"sm",onClick:async()=>{if(o.trim()&&i){h(!0);try{await i(o),m("")}finally{h(!1)}}},disabled:!o.trim()||u,children:u?"Enviando...":"Comentar"})]})]})]}),a("div",{className:"space-y-1",children:[t.length>0?a("div",{className:"flex items-center gap-2 mb-3",children:[e("span",{className:"text-sm font-medium",children:d("ap_comments")}),e(S,{variant:"info",className:"text-[10px] px-1.5 py-0",children:t.length})]}):a("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e(V,{className:"h-8 w-8 mb-2 opacity-50"}),e("p",{className:"text-sm",children:"Nenhum comentário adicionado"})]}),t.map(t=>a("div",{className:"flex gap-3 rounded-lg border bg-card p-3",children:[e("div",{className:"flex-shrink-0 h-8 w-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground overflow-hidden",children:t.userPhotoUrl?e("img",{src:t.userPhotoUrl,alt:t.userName,className:"h-full w-full object-cover"}):t.userName?.charAt(0)?.toUpperCase()||"?"}),a("div",{className:"flex-1 min-w-0 space-y-1",children:[a("div",{className:"flex items-center gap-2 text-sm",children:[e("span",{className:"font-medium truncate",children:t.userName}),t.userEmail&&e("span",{className:"text-xs text-muted-foreground truncate",children:t.userEmail}),e("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:je(t.dateEdited||t.dateCreation)}),t.dateEdited&&e("span",{className:"text-xs text-muted-foreground italic",children:"editado"})]}),g===t.id?a("div",{className:"space-y-2",children:[e(p,{value:v,onChange:e=>x(e.target.value),maxLength:c,rows:3}),a("div",{className:"flex gap-2 justify-end",children:[e(N,{variant:"outline",size:"sm",onClick:b,disabled:u,children:"Cancelar"}),e(N,{size:"sm",onClick:()=>(async e=>{if(v.trim()&&s){h(!0);try{await s({...e,text:v,stringText:v}),f(null),x("")}finally{h(!1)}}})(t),disabled:!v.trim()||u,children:u?"Salvando...":"Salvar"})]})]}):e("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:t.stringText||t.text})]}),!l&&n===t.userId&&g!==t.id&&a(y,{children:[e(C,{asChild:!0,children:e(w,{})}),a(_,{align:"end",children:[s&&e(D,{onClick:()=>(e=>{f(e.id),x(e.stringText||e.text)})(t),children:d("edit")}),r&&e(D,{className:"text-destructive",onClick:()=>(async e=>{if(r){h(!0);try{await r(e)}finally{h(!1)}}})(t.id),children:"Excluir"})]})]})]},t.id))]})]})}function je(e){const{t:a}=Y();if(!e)return"";const t=new Date(e);return`${t.toLocaleDateString("pt-BR")} ${t.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}`}function Be({history:t=[],isLoading:n=!1}){const{t:i}=Y();return n?e("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:"Carregando histórico..."}):0===t.length?a("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e(T,{className:"h-8 w-8 mb-2 opacity-50"}),e("p",{className:"text-sm",children:i("ap_no_history")})]}):e("div",{className:"p-1",children:a("div",{className:"relative",children:[e("div",{className:"absolute left-4 top-0 bottom-0 w-px bg-border"}),e("div",{className:"space-y-0",children:t.map((t,n)=>a("div",{className:"relative flex gap-4 pb-6 last:pb-0",children:[e("div",{className:"relative z-10 flex-shrink-0 h-8 w-8 rounded-full bg-primary/10 border-2 border-primary/30 flex items-center justify-center",children:t.icon?e("span",{className:"text-xs text-primary",children:t.icon}):e("div",{className:"h-2 w-2 rounded-full bg-primary"})}),a("div",{className:"flex-1 min-w-0 rounded-lg border bg-card p-3 space-y-2",children:[a("div",{children:[e("h4",{className:"text-sm font-medium",children:t.translateEvent||t.eventName}),t.eventDescription&&e("p",{className:"text-xs text-muted-foreground",children:t.eventDescription})]}),a("div",{className:"flex items-center gap-2",children:[e("div",{className:"flex-shrink-0 h-6 w-6 rounded-full bg-muted overflow-hidden flex items-center justify-center text-[10px] font-medium text-muted-foreground",children:t.userPhotoUrl?e("img",{src:t.userPhotoUrl,alt:t.userName,className:"h-full w-full object-cover"}):t.userName?.charAt(0)?.toUpperCase()||"?"}),a("div",{className:"min-w-0",children:[e("span",{className:"text-xs font-medium truncate block",children:t.userName}),t.userEmail&&e("span",{className:"text-[10px] text-muted-foreground truncate block",children:t.userEmail})]})]}),a("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[a("div",{className:"flex items-center gap-1",children:[e(M,{className:"h-3 w-3"}),e("span",{children:ze(t.date)})]}),a("div",{className:"flex items-center gap-1",children:[e(T,{className:"h-3 w-3"}),e("span",{children:Te(t.date)})]}),t.isMobileRequest&&a("div",{className:"flex items-center gap-1",children:[e(U,{className:"h-3 w-3"}),e("span",{children:i("ap_via_app")})]})]})]})]},t.id))})]})})}function ze(e){const{t:a}=Y();return new Date(e).toLocaleDateString("pt-BR")}function Te(e){const{t:a}=Y();return new Date(e).toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}function $e({attachments:n=[],onUpload:i,onDelete:r,onRename:l,onDownload:c,onView:d,disabled:o=!1}){const{t:m}=Y(),u=X(null),[p,h]=K(null),[g,f]=K(""),v=async e=>{g.trim()&&l&&(await l(e.id,g),h(null),f(""))},x=()=>{h(null),f("")};return a("div",{className:"space-y-4 p-1",children:[!o&&i&&a(t,{children:[e("input",{ref:u,type:"file",multiple:!0,className:"hidden",onChange:e=>{const a=e.target.files;if(a&&i){for(let e=0;e<a.length;e++){const t=a.item(e);t&&i(t)}u.current&&(u.current.value="")}}}),a(N,{size:"sm",onClick:()=>u.current?.click(),children:[e($,{className:"h-4 w-4 mr-1"}),"Adicionar anexo"]})]}),n.length>0?e("div",{className:"space-y-2",children:n.map(n=>a("div",{className:s("flex items-center gap-3 rounded-lg border bg-card p-3",n.status===le.error&&"border-destructive/50 bg-destructive/5",n.status===le.canceled&&"opacity-50"),children:[e("div",{className:"flex-shrink-0 h-9 w-9 rounded bg-muted flex items-center justify-center",children:e("span",{className:"text-[10px] font-bold uppercase text-muted-foreground",children:n.extension.replace(".","").substring(0,4)})}),a("div",{className:"flex-1 min-w-0 space-y-1",children:[p===n.id?a("div",{className:"flex items-center gap-2",children:[e("input",{className:"flex-1 text-sm border rounded px-2 py-1 bg-background",value:g,onChange:e=>f(e.target.value),onKeyDown:e=>{"Enter"===e.key&&v(n),"Escape"===e.key&&x()},autoFocus:!0}),e(N,{size:"sm",variant:"outline",onClick:x,children:m("cancel")}),e(N,{size:"sm",onClick:()=>v(n),children:m("save")})]}):e("button",{type:"button",className:"text-sm font-medium truncate block text-left hover:underline cursor-pointer",onClick:()=>d?.(n.id),children:n.name}),(n.status===le.uploading||n.status===le.waiting)&&e(b,{value:n.progress||0,className:"h-1.5"}),n.status===le.error&&e("p",{className:"text-xs text-destructive",children:"Erro ao enviar arquivo"}),n.status===le.duplicateItem&&e("p",{className:"text-xs text-warning",children:"Arquivo duplicado"}),n.status===le.canceled&&e("p",{className:"text-xs text-muted-foreground",children:"Upload cancelado"})]}),a("div",{className:"flex items-center gap-2",children:[n.status===le.done&&a(t,{children:[e("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:Ve(n.size)}),a(y,{children:[e(C,{asChild:!0,children:e(w,{})}),a(_,{align:"end",children:[l&&!o&&e(D,{onClick:()=>(e=>{const a=e.name.replace(e.extension,"");h(e.id),f(a)})(n),children:"Renomear"}),d&&e(D,{onClick:()=>d(n.id),children:"Visualizar"}),c&&e(D,{onClick:()=>c(n.id),children:"Download"}),r&&!o&&a(t,{children:[e(k,{}),e(D,{className:"text-destructive",onClick:()=>r(n.id),children:"Excluir"})]})]})]})]}),n.status===le.uploading&&e(N,{variant:"outline",size:"sm",onClick:()=>r?.(n.id),children:"Cancelar"})]})]},n.id))}):a("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e(O,{className:"h-8 w-8 mb-2 opacity-50"}),e("p",{className:"text-sm",children:"Nenhum anexo adicionado"})]})]})}function Ve(e){const{t:a}=Y();if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,t)).toFixed(1))} ${["B","KB","MB","GB"][t]}`}function Me(t){const{formData:n,isLoading:i,isSaving:s,activeTab:r,isFormDisabled:l,updateField:c,setActiveTab:d,save:o,changeStatus:m,remove:u,cancel:p}=be(t),{t:h}=Y(),{isNew:g=!1,config:f,users:v,places:x,actionTypes:b,causes:w,parentActions:S,progress:k,predecessors:L,availablePredecessors:R,costs:j,comments:B,history:z,attachments:T,attachmentsSlot:$,commentsSlot:V,historySlot:M,onAddPredecessor:U,onRemovePredecessor:O,onAddCost:H,onEditCost:G,onDeleteCost:K,onAddComment:J,onEditComment:Q,onDeleteComment:X,onUploadAttachment:ee,onDeleteAttachment:ae,onRenameAttachment:te,onDownloadAttachment:ne,onViewAttachment:ie}=t;if(i&&!n.id)return e(P,{isLoading:!0,children:e("div",{})});const se=function(e){const{t:a}=Y();if(!e)return[];return{[Z.waitingStart]:[Z.running,Z.suspended,Z.canceled],[Z.running]:[Z.effectivenessCheck,Z.done,Z.suspended,Z.canceled],[Z.effectivenessCheck]:[Z.running,Z.done,Z.suspended,Z.canceled],[Z.done]:[Z.running],[Z.suspended]:[Z.running,Z.canceled],[Z.canceled]:[Z.waitingStart]}[e]||[]}(n.statusId);return a("div",{className:"flex flex-col h-full",children:[a("div",{className:"flex items-center justify-between border-b bg-card px-6 py-4",children:[a("div",{className:"flex items-center gap-4",children:[p&&e(N,{variant:"ghost",size:"icon",onClick:p,children:e(q,{className:"h-4 w-4"})}),a("div",{className:"space-y-1",children:[a("div",{className:"flex items-center gap-3",children:[e("h1",{className:"text-lg font-semibold",children:g?h("ap_new_action"):n.name||h("ap_action_plan")}),!g&&n.statusId&&e(Ce,{status:n.statusId})]}),n.code&&e("p",{className:"text-xs text-muted-foreground font-mono",children:n.code})]})]}),a("div",{className:"flex items-center gap-2",children:[!g&&se.length>0&&!l&&a(y,{children:[e(C,{asChild:!0,children:e(N,{variant:"outline",size:"sm",children:"Alterar Status"})}),e(_,{align:"end",children:se.map(a=>e(D,{onClick:()=>m(a),children:pe[a]},a))})]}),!g&&t.onDelete&&a(y,{children:[e(C,{asChild:!0,children:e(N,{variant:"ghost",size:"icon",children:e(W,{className:"h-4 w-4"})})}),e(_,{align:"end",children:e(D,{className:"text-destructive",onClick:u,children:"Excluir"})})]})]})]}),e("div",{className:"flex-1 min-h-0 overflow-y-auto",children:e("div",{className:"max-w-4xl mx-auto px-6 py-6",children:a(A,{value:r,onValueChange:d,children:[a(F,{className:"mb-6",children:[e(I,{value:"general",children:"Geral"}),!g&&e(I,{value:"progress",children:"Progresso"}),!g&&f?.enablePredecessors&&e(I,{value:"predecessors",children:h("ap_predecessors")}),!g&&f?.enableCosts&&e(I,{value:"costs",children:"Custos"}),!g&&f?.enableAttachments&&e(I,{value:"attachments",children:h("ap_attachments")}),!g&&f?.enableComments&&e(I,{value:"comments",children:h("ap_comments")}),!g&&f?.enableHistory&&e(I,{value:"history",children:"Histórico"})]}),e(E,{value:"general",children:e(we,{formData:n,updateField:c,disabled:l,users:v,places:x,actionTypes:b,causes:w,parentActions:S,config:f})}),!g&&e(E,{value:"progress",children:e(Fe,{...t})}),!g&&f?.enablePredecessors&&e(E,{value:"predecessors",children:e(Ee,{predecessors:L,availablePredecessors:R,onAdd:U,onRemove:O,disabled:l})}),!g&&f?.enableCosts&&e(E,{value:"costs",children:e(Le,{costs:j,onAdd:H,onEdit:G,onDelete:K,disabled:l})}),!g&&f?.enableAttachments&&e(E,{value:"attachments",children:$||e($e,{attachments:T,onUpload:ee,onDelete:ae,onRename:te,onDownload:ne,onView:ie,disabled:l})}),!g&&f?.enableComments&&e(E,{value:"comments",children:V||e(Re,{comments:B,onAdd:J,onEdit:Q,onDelete:X,disabled:l})}),!g&&f?.enableHistory&&e(E,{value:"history",children:M||e(Be,{history:z})})]})})}),a("div",{className:"flex items-center justify-end gap-3 border-t bg-card px-6 py-4",children:[p&&e(N,{variant:"outline",onClick:p,disabled:s,children:"Cancelar"}),e(N,{onClick:o,disabled:s||l,children:s?"Salvando...":"Salvar"})]})]})}export{$e as ActionPlanAttachmentsTab,Re as ActionPlanCommentsTab,Le as ActionPlanCostTab,we as ActionPlanGeneralTab,Be as ActionPlanHistoryTab,Me as ActionPlanPage,Ee as ActionPlanPredecessorsTab,Ae as ActionPlanProgressDialog,Fe as ActionPlanProgressTab,Ce as ActionPlanStatusBadge,xe as CLOSED_STATUSES,ge as DEFAULT_ACTION_TYPES,le as EAttachmentItemStatus,ne as ETaskPlanAssociationType,ae as ETaskPlanPriority,Z as ETaskPlanStatus,se as ETaskPlanTypeProgress,ve as PRIORITIES,Ne as PROGRESS_ALLOWED_STATUSES,de as STATUS_COLORS,pe as STATUS_LABELS,me as STATUS_MAP,oe as STATUS_TEXT_COLORS,ke as formatTime,Se as formatTimeProgress,he as getActionTypes,fe as getPriorities,Pe as getProgressColor,ue as getStatusLabels,be as useActionPlan,De as useActionPlanProgress};
|
|
1
|
+
import{jsx as e,jsxs as a,Fragment as t}from"react/jsx-runtime";import{StatusBadge as n,Label as i,cn as s,Input as r,Select as l,SelectTrigger as c,SelectValue as d,SelectContent as o,SelectItem as m,DatePicker as u,Textarea as p,Dialog as h,DialogContent as g,DialogHeader as f,DialogTitle as v,DialogFooter as x,Button as N,Progress as b,DropdownMenu as y,DropdownMenuTrigger as C,ActionButton as w,DropdownMenuContent as _,DropdownMenuItem as D,Badge as S,DropdownMenuSeparator as k,LoadingState as P,Tabs as A,TabsList as F,TabsTrigger as I,TabsContent as E}from"forlogic-core";import{X as L,Pause as R,CheckCircle2 as j,ShieldCheck as B,Play as z,Clock as T,Plus as $,MessageSquare as V,Calendar as M,Smartphone as U,Paperclip as O,ArrowLeft as q,MoreVertical as W}from"lucide-react";import H from"i18next";import G,{useState as K,useEffect as J,useCallback as Q,useRef as X}from"react";import{useTranslation as Y}from"react-i18next";var Z=(e=>(e[e.waitingStart=1]="waitingStart",e[e.running=2]="running",e[e.effectivenessCheck=3]="effectivenessCheck",e[e.done=4]="done",e[e.suspended=5]="suspended",e[e.canceled=6]="canceled",e))(Z||{}),ee=(e=>(e[e.low=0]="low",e[e.medium=1]="medium",e[e.high=2]="high",e))(ee||{}),ae=(e=>(e[e.plan=2]="plan",e[e.occurrence=3]="occurrence",e[e.risk=4]="risk",e[e.decisions=5]="decisions",e[e.audit=6]="audit",e[e.strategyExtension=7]="strategyExtension",e[e.standardization=8]="standardization",e[e.supplier=9]="supplier",e[e.auditItems=10]="auditItems",e))(ae||{}),te=(e=>(e[e.currentProgress=1]="currentProgress",e[e.cumulativeProgress=2]="cumulativeProgress",e))(te||{}),ne=(e=>(e.uploading="uploading",e.waiting="waiting",e.done="done",e.error="error",e.canceled="canceled",e.duplicateItem="duplicateItem",e))(ne||{});const ie={[Z.waitingStart]:"#D6D6D6",[Z.running]:"#DAE9F4",[Z.effectivenessCheck]:"#1B75BB29",[Z.done]:"#DDEECA",[Z.suspended]:"#FFF2D6",[Z.canceled]:"#F4433629"},se={[Z.waitingStart]:"#666666",[Z.running]:"#1B75BB",[Z.effectivenessCheck]:"#1B75BB",[Z.done]:"#4CAF50",[Z.suspended]:"#FF9800",[Z.canceled]:"#F44336"},re={[Z.waitingStart]:"waiting-start",[Z.running]:"running",[Z.effectivenessCheck]:"effectiveness-check",[Z.done]:"done",[Z.suspended]:"suspended",[Z.canceled]:"canceled"};function le(){return{[Z.waitingStart]:H.t("ap_status_waiting_start"),[Z.running]:H.t("ap_status_running"),[Z.effectivenessCheck]:H.t("ap_status_effectiveness_check"),[Z.done]:H.t("ap_status_done"),[Z.suspended]:H.t("ap_status_suspended"),[Z.canceled]:H.t("ap_status_canceled")}}const ce=new Proxy({},{get:(e,a)=>{if("symbol"==typeof a)return;return le()[a]}});function de(){return[{id:"immediate",label:H.t("ap_type_immediate")},{id:"corrective",label:H.t("ap_type_corrective")},{id:"preventive",label:H.t("ap_type_preventive")},{id:"improvement",label:H.t("ap_type_improvement")},{id:"standardization",label:H.t("ap_type_standardization")}]}const oe=[{id:"immediate",label:"Imediata"},{id:"corrective",label:"Corretiva"},{id:"preventive",label:"Preventiva"},{id:"improvement",label:"Oportunidade de Melhoria"},{id:"standardization",label:"Padronização"}];function me(){return[{id:ee.low,label:H.t("ap_priority_low"),color:"#4CAF50"},{id:ee.medium,label:H.t("ap_priority_medium"),color:"#FF9800"},{id:ee.high,label:H.t("ap_priority_high"),color:"#F44336"}]}const ue=[{id:ee.low,label:"Baixa",color:"#4CAF50"},{id:ee.medium,label:"Média",color:"#FF9800"},{id:ee.high,label:"Alta",color:"#F44336"}],pe=[Z.done,Z.canceled],he=[Z.waitingStart,Z.running,Z.effectivenessCheck,Z.suspended];function ge(e){const{actionPlan:a,isNew:t=!1,config:n,onSave:i,onCancel:s,onDelete:r,onChangeStatus:l}=e,[c,d]=K({formData:a||{},isLoading:e.isLoading||!1,isSaving:!1,activeTab:"general",isFormDisabled:!1});J(()=>{a&&d(e=>({...e,formData:a,isFormDisabled:n?.disableFields||pe.includes(a.statusId)}))},[a,n?.disableFields]),J(()=>{d(a=>({...a,isLoading:e.isLoading||!1}))},[e.isLoading]);const o=Q((e,a)=>{d(t=>({...t,formData:{...t.formData,[e]:a}}))},[]),m=Q(e=>{d(a=>({...a,activeTab:e}))},[]),u=Q(async()=>{if(i){d(e=>({...e,isSaving:!0}));try{await i(c.formData)}finally{d(e=>({...e,isSaving:!1}))}}},[i,c.formData]),p=Q(async e=>{if(l&&c.formData.id){d(e=>({...e,isLoading:!0}));try{await l(c.formData.id,e)}finally{d(e=>({...e,isLoading:!1}))}}},[l,c.formData.id]),h=Q(async()=>{if(r&&c.formData.id){d(e=>({...e,isLoading:!0}));try{await r(c.formData.id)}finally{d(e=>({...e,isLoading:!1}))}}},[r,c.formData.id]);return{formData:c.formData,isLoading:c.isLoading,isSaving:c.isSaving,activeTab:c.activeTab,isFormDisabled:c.isFormDisabled,updateField:o,setActiveTab:m,save:u,changeStatus:p,remove:h,cancel:s}}const fe={[Z.waitingStart]:{label:"",color:"#8B7355",icon:T},[Z.running]:{label:"",color:"#2E7D5B",icon:z},[Z.effectivenessCheck]:{label:"",color:"#4A6FA5",icon:B},[Z.done]:{label:"",color:"#3D7A40",icon:j},[Z.suspended]:{label:"",color:"#6B7280",icon:R},[Z.canceled]:{label:"",color:"#B44A4A",icon:L}};function ve({status:a,labels:t,className:i,size:s,showIcon:r,variant:l}){const c=le(),d=fe[a];if(!d)return null;const o=t?.[a]||c[a]||"";return e(n,{label:o,color:d.color,icon:d.icon,size:s,showIcon:r,variant:l,className:i})}function xe({formData:t,updateField:n,disabled:h=!1,users:g=[],places:f=[],actionTypes:v,causes:x=[],parentActions:N=[],config:b}){const{t:y}=Y(),C=b?.requiredFields,w=v||oe,_=e=>{if(b?.hiddenFields?.includes(e))return!1;if(b?.visibleFields&&b.visibleFields.length>0)return b.visibleFields.includes(e);const a=`${e}Visible`;return!C||!(a in C)||!1!==C[a]},D=e=>C?!!C[e]:"name"===e,S=G.useMemo(()=>{if(t.startDate&&t.endDate){const e=new Date(t.startDate),a=new Date(t.endDate).getTime()-e.getTime();return Math.max(0,Math.ceil(a/864e5))}return t.duration||0},[t.startDate,t.endDate,t.duration]);return a("div",{className:"space-y-6 p-1",children:[a("div",{className:"space-y-2",children:[e(i,{className:s(D("name")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Nome"}),e(r,{value:t.name||"",onChange:e=>n("name",e.target.value),maxLength:500,disabled:h,placeholder:y("ap_plan_name_placeholder")})]}),a("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[_("responsibleWho")&&a("div",{className:"space-y-2",children:[e(i,{className:s(D("responsibleWho")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Responsável"}),a(l,{value:t.responsibleId||"",onValueChange:e=>n("responsibleId",e),disabled:h,children:[e(c,{children:e(d,{placeholder:y("ap_select_responsible")})}),e(o,{children:g.map(a=>e(m,{value:a.id,children:a.name},a.id))})]})]}),_("checkerWho")&&a("div",{className:"space-y-2",children:[e(i,{className:s(D("checkerWho")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Verificador"}),a(l,{value:t.checkerId||"",onValueChange:e=>n("checkerId",e),disabled:h,children:[e(c,{children:e(d,{placeholder:y("ap_select_checker")})}),e(o,{children:g.map(a=>e(m,{value:a.id,children:a.name},a.id))})]})]})]}),a("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[_("place")&&a("div",{className:"space-y-2",children:[e(i,{className:s(D("place")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Local"}),a(l,{value:t.placeId||"",onValueChange:e=>n("placeId",e),disabled:h,children:[e(c,{children:e(d,{placeholder:y("ap_select_place")})}),e(o,{children:Ne(f).map(a=>e(m,{value:a.id,children:a.name},a.id))})]})]}),_("planType")&&a("div",{className:"space-y-2",children:[e(i,{className:s(D("planType")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Tipo de Ação"}),a(l,{value:t.typeId||"",onValueChange:e=>n("typeId",e),disabled:h,children:[e(c,{children:e(d,{placeholder:y("ap_select_type")})}),e(o,{children:w.map(a=>e(m,{value:a.id,children:a.label},a.id))})]})]})]}),a("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[_("priority")&&a("div",{className:"space-y-2",children:[e(i,{className:s(D("priority")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Prioridade"}),a(l,{value:t.priorityType?.toString()||"",onValueChange:e=>n("priorityType",Number(e)),disabled:h,children:[e(c,{children:e(d,{placeholder:y("ap_select_priority")})}),e(o,{children:ue.map(t=>e(m,{value:t.id.toString(),children:a("span",{className:"flex items-center gap-2",children:[e("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:t.color}}),t.label]})},t.id))})]})]}),N.length>0&&a("div",{className:"space-y-2",children:[e(i,{children:y("ap_belongs_to")}),a(l,{value:t.parentId||"",onValueChange:e=>n("parentId",e),disabled:h,children:[e(c,{children:e(d,{placeholder:y("ap_select_parent")})}),e(o,{children:N.map(a=>e(m,{value:a.id,children:a.label},a.id))})]})]})]}),a("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[_("startDate")&&a("div",{className:"space-y-2",children:[e(i,{className:s(D("startDate")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Data de Início"}),e(u,{date:t.startDate?new Date(t.startDate):void 0,onDateChange:e=>n("startDate",e||null),disabled:h,placeholder:y("ap_select_date")})]}),_("endDate")&&a("div",{className:"space-y-2",children:[e(i,{className:s(D("endDate")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Data de Término"}),e(u,{date:t.endDate?new Date(t.endDate):void 0,onDateChange:e=>n("endDate",e||null),disabled:h,placeholder:y("ap_select_date"),disabledDates:t.startDate?e=>e<new Date(t.startDate):void 0})]}),a("div",{className:"space-y-2",children:[e(i,{children:y("ap_duration_days")}),e(r,{type:"number",value:S,disabled:!0,className:"bg-muted"})]})]}),_("estimatedCost")&&a("div",{className:"space-y-2 max-w-xs",children:[e(i,{className:s(D("estimatedCost")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Custo Estimado"}),a("div",{className:"relative",children:[e("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"R$"}),e(r,{type:"number",min:0,step:.01,value:t.estimatedCost||"",onChange:e=>n("estimatedCost",Number(e.target.value)),disabled:h,className:"pl-9",placeholder:"0,00"})]})]}),_("cause")&&x.length>0&&a("div",{className:"space-y-2",children:[e(i,{children:"Causa"}),a(l,{value:t.causeId||"",onValueChange:e=>n("causeId",e),disabled:h,children:[e(c,{children:e(d,{placeholder:y("ap_select_cause")})}),e(o,{children:x.map(a=>e(m,{value:a.id,children:a.label},a.id))})]})]}),_("description")&&a("div",{className:"space-y-2",children:[e(i,{className:s(D("description")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Descrição"}),e(p,{value:t.description||"",onChange:e=>n("description",e.target.value),maxLength:4e3,disabled:h,rows:4,placeholder:y("ap_description_placeholder")})]}),_("justification")&&a("div",{className:"space-y-2",children:[e(i,{className:s(D("justification")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Justificativa"}),e(p,{value:t.justification||"",onChange:e=>n("justification",e.target.value),maxLength:4e3,disabled:h,rows:4,placeholder:y("ap_justification_placeholder")})]})]})}function Ne(e,a=0){const t=[];for(const n of e)t.push({...n,depth:a}),n.children?.length&&t.push(...Ne(n.children,a+1));return t}function be(e){const{progress:a,onReportProgress:t,onEditProgress:n,onDeleteProgress:i}=e,[s,r]=K(!1),[l,c]=K(null),d=!!a&&he.includes(a.status),o=Q(async e=>{if(t&&a){r(!0);try{const n=100===e.percentProgress;await t({id:a.id,...e,conclude:n})}finally{r(!1)}}},[t,a]),m=Q(async e=>{if(n){r(!0);try{await n(e)}finally{r(!1),c(null)}}},[n]),u=Q(async e=>{if(i){r(!0);try{await i(e)}finally{r(!1)}}},[i]);return{progress:a,canReportProgress:d,isSubmitting:s,editingReport:l,setEditingReport:c,reportProgress:o,editProgress:m,deleteProgress:u}}function ye(e){if(!e)return"";let a=(e||"").trim();if(!a)return"00:00";if(a.includes(":")){const e=a.split(":");if(e.length>=2){const a=e[0].replace(/\D/g,""),t=e[1].replace(/\D/g,"");let n=parseInt(a)||0,i=parseInt(t)||0;return n+=Math.floor(i/60),i%=60,`${n.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`}}if(a=a.replace(/\D/g,""),!a)return"00:00";let t=0,n=0;return 4===a.length?(t=parseInt(a.substring(0,2))||0,n=parseInt(a.substring(2,4))||0,t+=Math.floor(n/60),n%=60):(t=parseInt(a)||0,n=0),`${t.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`}function Ce(e){if(null==e)return"00:00";const a=String(e).replace(/\D/g,"");if(a.length<3){let e=parseInt(a)||0;const t=Math.floor(e/60);return e%=60,`${t.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`}{const e=a.slice(-2),t=a.slice(0,-2);let n=parseInt(t)||0,i=parseInt(e)||0;return n+=Math.floor(i/60),i%=60,`${n.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`}}function we(e){return 100===e?"#84c148":e>0?"#1b75bb":""}function _e({open:t,onOpenChange:n,report:s,onSave:l,isSubmitting:c=!1}){const{t:d}=Y(),[o,m]=K(s?.percentProgress||0),[u,b]=K(s?.timeProgress||""),[y,C]=K(s?.comments||""),w=o!==(s?.percentProgress??0)||u!==(s?.timeProgress??"")||y!==(s?.comments??"");G.useEffect(()=>{s&&(m(s.percentProgress),b(s.timeProgress||""),C(s.comments||""))},[s]);return e(h,{open:t,onOpenChange:n,children:a(g,{className:"sm:max-w-md",variant:"form",isDirty:w,children:[e(f,{children:e(v,{children:d("ap_edit_progress")})}),a("div",{className:"space-y-4 py-4",children:[a("div",{className:"space-y-2",children:[e(i,{children:d("ap_progress_percent")}),e(r,{type:"number",min:0,max:100,value:o,onChange:e=>m(Number(e.target.value))})]}),a("div",{className:"space-y-2",children:[e(i,{children:d("ap_time_spent")}),e(r,{value:u,onChange:e=>b(e.target.value),onBlur:()=>b(ye(u)||""),placeholder:"00:00"})]}),a("div",{className:"space-y-2",children:[e(i,{children:d("ap_comments")}),e(p,{value:y,onChange:e=>C(e.target.value),rows:3,maxLength:4e3})]})]}),a(x,{children:[e(N,{variant:"outline",onClick:()=>n(!1),disabled:c,children:"Cancelar"}),e(N,{onClick:()=>{s&&l({...s,percentProgress:o,timeProgress:ye(u)||"00:00",comments:y})},disabled:c,children:c?"Salvando...":"Salvar"})]})]})})}function De(t){const{t:n}=Y(),{progress:s,canReportProgress:l,isSubmitting:c,editingReport:d,setEditingReport:o,reportProgress:m,editProgress:u,deleteProgress:h}=be(t),[g,f]=K(""),[v,x]=K(""),[y,C]=K("");if(!s)return e("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:"Sem dados de progresso disponíveis"});const w=we(s.percentProgress),_=!g,D=!g&&!v&&!y;return a("div",{className:"space-y-6 p-1",children:[a("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[a("div",{className:"flex items-center justify-between text-sm",children:[e("span",{className:"font-medium",children:n("ap_overall_progress")}),a("span",{className:"font-semibold",style:{color:w||void 0},children:[s.percentProgress,"%"]})]}),e(b,{value:s.percentProgress,className:"h-3"}),s.timeProgress&&a("div",{className:"text-xs text-muted-foreground",children:["Tempo total: ",Ce(s.timeProgress)]})]}),l&&a("div",{className:"rounded-lg border bg-card p-4 space-y-4",children:[e("h4",{className:"text-sm font-medium",children:n("ap_report_progress")}),a("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a("div",{className:"space-y-2",children:[e(i,{children:n("ap_progress_percent")}),e(r,{type:"number",min:0,max:100,value:g,onChange:e=>f(e.target.value),placeholder:"0"})]}),a("div",{className:"space-y-2",children:[e(i,{children:n("ap_time_spent")}),e(r,{value:v,onChange:e=>x(e.target.value),onBlur:()=>x(ye(v)||""),placeholder:"00:00"})]})]}),a("div",{className:"space-y-2",children:[e(i,{children:n("ap_comments")}),e(p,{value:y,onChange:e=>C(e.target.value),rows:3,maxLength:4e3,placeholder:n("ap_progress_comment_placeholder")})]}),a("div",{className:"flex gap-2 justify-end",children:[e(N,{variant:"outline",size:"sm",onClick:()=>{f(""),x(""),C("")},disabled:D||c,children:"Limpar"}),e(N,{size:"sm",onClick:async()=>{const e=Number(g);(e||0===e)&&(await m({percentProgress:e,timeProgress:ye(v)||"00:00",comments:y}),f(""),x(""),C(""))},disabled:_||c,children:c?"Reportando...":"Reportar"})]})]}),s.reports.length>0&&a("div",{className:"space-y-3",children:[e("h4",{className:"text-sm font-medium",children:n("ap_reports_history")}),e("div",{className:"space-y-2",children:s.reports.map(a=>e(Se,{report:a,onEdit:()=>o(a),onDelete:()=>h(a.id),disabled:!l},a.id))})]}),e(_e,{open:!!d,onOpenChange:e=>!e&&o(null),report:d,onSave:u,isSubmitting:c})]})}function Se({report:t,onEdit:n,onDelete:i,disabled:s}){const r=t.date?new Date(t.date):null,l=we(t.percentProgress);return a("div",{className:"flex items-start gap-3 rounded-lg border bg-card p-3",children:[e("div",{className:"flex-shrink-0 h-8 w-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground",children:t.userName?.charAt(0)?.toUpperCase()||"?"}),a("div",{className:"flex-1 min-w-0 space-y-1",children:[a("div",{className:"flex items-center gap-2 text-sm",children:[e("span",{className:"font-medium truncate",children:t.userName}),r&&e("span",{className:"text-xs text-muted-foreground",children:r.toLocaleDateString("pt-BR")})]}),a("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[a("span",{style:{color:l||void 0},className:"font-semibold",children:[t.percentProgress,"%"]}),t.timeProgress&&a("span",{children:["Tempo: ",Ce(t.timeProgress)]})]}),t.comments&&e("p",{className:"text-xs text-muted-foreground mt-1",children:t.comments})]}),!s&&a(y,{children:[e(C,{asChild:!0,children:e(w,{})}),a(_,{align:"end",children:[e(D,{onClick:n,children:H.t("edit")}),e(D,{className:"text-destructive",onClick:i,children:H.t("ap_delete")})]})]})]})}function ke({predecessors:t=[],availablePredecessors:n=[],onAdd:s,onRemove:r,disabled:u=!1}){const{t:p}=Y(),[h,g]=G.useState(""),f=n.filter(e=>!t.some(a=>a.predecessorId===e.id));return a("div",{className:"space-y-6 p-1",children:[!u&&f.length>0&&a("div",{className:"flex items-end gap-3",children:[a("div",{className:"flex-1 space-y-2",children:[e(i,{children:p("ap_add_predecessor")}),a(l,{value:h,onValueChange:g,children:[e(c,{children:e(d,{placeholder:p("ap_select_action")})}),e(o,{children:f.map(a=>e(m,{value:a.id,children:a.label},a.id))})]})]}),a(N,{size:"sm",onClick:()=>{h&&s&&(s(h),g(""))},disabled:!h,children:[e($,{className:"h-4 w-4 mr-1"}),"Adicionar"]})]}),t.length>0?e("div",{className:"space-y-2",children:t.map(t=>a("div",{className:"flex items-center justify-between rounded-lg border bg-card p-3",children:[a("div",{className:"flex items-center gap-3",children:[t.predecessorCode&&e("span",{className:"text-xs text-muted-foreground font-mono",children:t.predecessorCode}),e("span",{className:"text-sm font-medium",children:t.predecessorName}),null!=t.predecessorStatus&&e(ve,{status:t.predecessorStatus})]}),!u&&r&&a(y,{children:[e(C,{asChild:!0,children:e(w,{})}),e(_,{align:"end",children:e(D,{className:"text-destructive",onClick:()=>r(t.predecessorId),children:"Remover"})})]})]},t.id))}):e("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"Nenhum predecessor adicionado"})]})}function Pe({costs:t=[],onAdd:n,onEdit:s,onDelete:l,disabled:c=!1}){const{t:d}=Y(),[o,m]=K(""),[u,p]=K(""),h=t.reduce((e,a)=>e+(a.value||0),0);return a("div",{className:"space-y-6 p-1",children:[a("div",{className:"rounded-lg border bg-card p-4 flex items-center justify-between",children:[e("span",{className:"text-sm font-medium",children:d("ap_total_cost")}),a("span",{className:"text-lg font-semibold text-foreground",children:["R$ ",h.toLocaleString("pt-BR",{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),!c&&n&&a("div",{className:"rounded-lg border bg-card p-4 space-y-4",children:[e("h4",{className:"text-sm font-medium",children:d("ap_add_cost")}),a("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a("div",{className:"space-y-2",children:[e(i,{children:"Descrição"}),e(r,{value:o,onChange:e=>m(e.target.value),placeholder:d("ap_cost_description")})]}),a("div",{className:"space-y-2",children:[e(i,{children:"Valor (R$)"}),e(r,{type:"number",min:0,step:.01,value:u,onChange:e=>p(e.target.value),placeholder:"0,00"})]})]}),e("div",{className:"flex justify-end",children:a(N,{size:"sm",onClick:()=>{o&&u&&n&&(n({description:o,value:Number(u),date:(new Date).toISOString()}),m(""),p(""))},disabled:!o||!u,children:[e($,{className:"h-4 w-4 mr-1"}),"Adicionar"]})})]}),t.length>0?e("div",{className:"space-y-2",children:t.map(t=>a("div",{className:"flex items-center justify-between rounded-lg border bg-card p-3",children:[a("div",{className:"flex-1 min-w-0",children:[e("p",{className:"text-sm font-medium truncate",children:t.description}),t.date&&e("p",{className:"text-xs text-muted-foreground",children:new Date(t.date).toLocaleDateString("pt-BR")})]}),a("div",{className:"flex items-center gap-3",children:[a("span",{className:"text-sm font-semibold whitespace-nowrap",children:["R$ ",t.value.toLocaleString("pt-BR",{minimumFractionDigits:2,maximumFractionDigits:2})]}),!c&&(s||l)&&a(y,{children:[e(C,{asChild:!0,children:e(w,{})}),a(_,{align:"end",children:[s&&e(D,{onClick:()=>s(t),children:d("edit")}),l&&e(D,{className:"text-destructive",onClick:()=>l(t.id),children:d("ap_delete")})]})]})]})]},t.id))}):e("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"Nenhum custo registrado"})]})}function Ae({comments:t=[],currentUserId:n,onAdd:i,onEdit:s,onDelete:r,disabled:l=!1,maxLength:c=4e3}){const{t:d}=Y(),[o,m]=K(""),[u,h]=K(!1),[g,f]=K(null),[v,x]=K(""),b=()=>{f(null),x("")};return a("div",{className:"space-y-6 p-1",children:[!l&&i&&a("div",{className:"space-y-3",children:[e(p,{value:o,onChange:e=>m(e.target.value),placeholder:d("ap_add_comment_placeholder"),maxLength:c,rows:3}),a("div",{className:"flex items-center justify-between",children:[c&&a("span",{className:"text-xs text-muted-foreground",children:[o.length,"/",c]}),a("div",{className:"flex gap-2 ml-auto",children:[e(N,{variant:"outline",size:"sm",onClick:()=>m(""),disabled:!o||u,children:"Limpar"}),e(N,{size:"sm",onClick:async()=>{if(o.trim()&&i){h(!0);try{await i(o),m("")}finally{h(!1)}}},disabled:!o.trim()||u,children:u?"Enviando...":"Comentar"})]})]})]}),a("div",{className:"space-y-1",children:[t.length>0?a("div",{className:"flex items-center gap-2 mb-3",children:[e("span",{className:"text-sm font-medium",children:d("ap_comments")}),e(S,{variant:"info",className:"text-[10px] px-1.5 py-0",children:t.length})]}):a("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e(V,{className:"h-8 w-8 mb-2 opacity-50"}),e("p",{className:"text-sm",children:"Nenhum comentário adicionado"})]}),t.map(t=>a("div",{className:"flex gap-3 rounded-lg border bg-card p-3",children:[e("div",{className:"flex-shrink-0 h-8 w-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground overflow-hidden",children:t.userPhotoUrl?e("img",{src:t.userPhotoUrl,alt:t.userName,className:"h-full w-full object-cover"}):t.userName?.charAt(0)?.toUpperCase()||"?"}),a("div",{className:"flex-1 min-w-0 space-y-1",children:[a("div",{className:"flex items-center gap-2 text-sm",children:[e("span",{className:"font-medium truncate",children:t.userName}),t.userEmail&&e("span",{className:"text-xs text-muted-foreground truncate",children:t.userEmail}),e("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:Fe(t.dateEdited||t.dateCreation)}),t.dateEdited&&e("span",{className:"text-xs text-muted-foreground italic",children:"editado"})]}),g===t.id?a("div",{className:"space-y-2",children:[e(p,{value:v,onChange:e=>x(e.target.value),maxLength:c,rows:3}),a("div",{className:"flex gap-2 justify-end",children:[e(N,{variant:"outline",size:"sm",onClick:b,disabled:u,children:"Cancelar"}),e(N,{size:"sm",onClick:()=>(async e=>{if(v.trim()&&s){h(!0);try{await s({...e,text:v,stringText:v}),f(null),x("")}finally{h(!1)}}})(t),disabled:!v.trim()||u,children:u?"Salvando...":"Salvar"})]})]}):e("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:t.stringText||t.text})]}),!l&&n===t.userId&&g!==t.id&&a(y,{children:[e(C,{asChild:!0,children:e(w,{})}),a(_,{align:"end",children:[s&&e(D,{onClick:()=>(e=>{f(e.id),x(e.stringText||e.text)})(t),children:d("edit")}),r&&e(D,{className:"text-destructive",onClick:()=>(async e=>{if(r){h(!0);try{await r(e)}finally{h(!1)}}})(t.id),children:"Excluir"})]})]})]},t.id))]})]})}function Fe(e){const{t:a}=Y();if(!e)return"";const t=new Date(e);return`${t.toLocaleDateString("pt-BR")} ${t.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}`}function Ie({history:t=[],isLoading:n=!1}){const{t:i}=Y();return n?e("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:"Carregando histórico..."}):0===t.length?a("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e(T,{className:"h-8 w-8 mb-2 opacity-50"}),e("p",{className:"text-sm",children:i("ap_no_history")})]}):e("div",{className:"p-1",children:a("div",{className:"relative",children:[e("div",{className:"absolute left-4 top-0 bottom-0 w-px bg-border"}),e("div",{className:"space-y-0",children:t.map((t,n)=>a("div",{className:"relative flex gap-4 pb-6 last:pb-0",children:[e("div",{className:"relative z-10 flex-shrink-0 h-8 w-8 rounded-full bg-primary/10 border-2 border-primary/30 flex items-center justify-center",children:t.icon?e("span",{className:"text-xs text-primary",children:t.icon}):e("div",{className:"h-2 w-2 rounded-full bg-primary"})}),a("div",{className:"flex-1 min-w-0 rounded-lg border bg-card p-3 space-y-2",children:[a("div",{children:[e("h4",{className:"text-sm font-medium",children:t.translateEvent||t.eventName}),t.eventDescription&&e("p",{className:"text-xs text-muted-foreground",children:t.eventDescription})]}),a("div",{className:"flex items-center gap-2",children:[e("div",{className:"flex-shrink-0 h-6 w-6 rounded-full bg-muted overflow-hidden flex items-center justify-center text-[10px] font-medium text-muted-foreground",children:t.userPhotoUrl?e("img",{src:t.userPhotoUrl,alt:t.userName,className:"h-full w-full object-cover"}):t.userName?.charAt(0)?.toUpperCase()||"?"}),a("div",{className:"min-w-0",children:[e("span",{className:"text-xs font-medium truncate block",children:t.userName}),t.userEmail&&e("span",{className:"text-[10px] text-muted-foreground truncate block",children:t.userEmail})]})]}),a("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[a("div",{className:"flex items-center gap-1",children:[e(M,{className:"h-3 w-3"}),e("span",{children:Ee(t.date)})]}),a("div",{className:"flex items-center gap-1",children:[e(T,{className:"h-3 w-3"}),e("span",{children:Le(t.date)})]}),t.isMobileRequest&&a("div",{className:"flex items-center gap-1",children:[e(U,{className:"h-3 w-3"}),e("span",{children:i("ap_via_app")})]})]})]})]},t.id))})]})})}function Ee(e){const{t:a}=Y();return new Date(e).toLocaleDateString("pt-BR")}function Le(e){const{t:a}=Y();return new Date(e).toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}function Re({attachments:n=[],onUpload:i,onDelete:r,onRename:l,onDownload:c,onView:d,disabled:o=!1}){const{t:m}=Y(),u=X(null),[p,h]=K(null),[g,f]=K(""),v=async e=>{g.trim()&&l&&(await l(e.id,g),h(null),f(""))},x=()=>{h(null),f("")};return a("div",{className:"space-y-4 p-1",children:[!o&&i&&a(t,{children:[e("input",{ref:u,type:"file",multiple:!0,className:"hidden",onChange:e=>{const a=e.target.files;if(a&&i){for(let e=0;e<a.length;e++){const t=a.item(e);t&&i(t)}u.current&&(u.current.value="")}}}),a(N,{size:"sm",onClick:()=>u.current?.click(),children:[e($,{className:"h-4 w-4 mr-1"}),"Adicionar anexo"]})]}),n.length>0?e("div",{className:"space-y-2",children:n.map(n=>a("div",{className:s("flex items-center gap-3 rounded-lg border bg-card p-3",n.status===ne.error&&"border-destructive/50 bg-destructive/5",n.status===ne.canceled&&"opacity-50"),children:[e("div",{className:"flex-shrink-0 h-9 w-9 rounded bg-muted flex items-center justify-center",children:e("span",{className:"text-[10px] font-bold uppercase text-muted-foreground",children:n.extension.replace(".","").substring(0,4)})}),a("div",{className:"flex-1 min-w-0 space-y-1",children:[p===n.id?a("div",{className:"flex items-center gap-2",children:[e("input",{className:"flex-1 text-sm border rounded px-2 py-1 bg-background",value:g,onChange:e=>f(e.target.value),onKeyDown:e=>{"Enter"===e.key&&v(n),"Escape"===e.key&&x()},autoFocus:!0}),e(N,{size:"sm",variant:"outline",onClick:x,children:m("cancel")}),e(N,{size:"sm",onClick:()=>v(n),children:m("save")})]}):e("button",{type:"button",className:"text-sm font-medium truncate block text-left hover:underline cursor-pointer",onClick:()=>d?.(n.id),children:n.name}),(n.status===ne.uploading||n.status===ne.waiting)&&e(b,{value:n.progress||0,className:"h-1.5"}),n.status===ne.error&&e("p",{className:"text-xs text-destructive",children:"Erro ao enviar arquivo"}),n.status===ne.duplicateItem&&e("p",{className:"text-xs text-warning",children:"Arquivo duplicado"}),n.status===ne.canceled&&e("p",{className:"text-xs text-muted-foreground",children:"Upload cancelado"})]}),a("div",{className:"flex items-center gap-2",children:[n.status===ne.done&&a(t,{children:[e("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:je(n.size)}),a(y,{children:[e(C,{asChild:!0,children:e(w,{})}),a(_,{align:"end",children:[l&&!o&&e(D,{onClick:()=>(e=>{const a=e.name.replace(e.extension,"");h(e.id),f(a)})(n),children:"Renomear"}),d&&e(D,{onClick:()=>d(n.id),children:"Visualizar"}),c&&e(D,{onClick:()=>c(n.id),children:"Download"}),r&&!o&&a(t,{children:[e(k,{}),e(D,{className:"text-destructive",onClick:()=>r(n.id),children:"Excluir"})]})]})]})]}),n.status===ne.uploading&&e(N,{variant:"outline",size:"sm",onClick:()=>r?.(n.id),children:"Cancelar"})]})]},n.id))}):a("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e(O,{className:"h-8 w-8 mb-2 opacity-50"}),e("p",{className:"text-sm",children:"Nenhum anexo adicionado"})]})]})}function je(e){const{t:a}=Y();if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,t)).toFixed(1))} ${["B","KB","MB","GB"][t]}`}function Be(t){const{formData:n,isLoading:i,isSaving:s,activeTab:r,isFormDisabled:l,updateField:c,setActiveTab:d,save:o,changeStatus:m,remove:u,cancel:p}=ge(t),{t:h}=Y(),{isNew:g=!1,config:f,users:v,places:x,actionTypes:b,causes:w,parentActions:S,progress:k,predecessors:L,availablePredecessors:R,costs:j,comments:B,history:z,attachments:T,attachmentsSlot:$,commentsSlot:V,historySlot:M,onAddPredecessor:U,onRemovePredecessor:O,onAddCost:H,onEditCost:G,onDeleteCost:K,onAddComment:J,onEditComment:Q,onDeleteComment:X,onUploadAttachment:ee,onDeleteAttachment:ae,onRenameAttachment:te,onDownloadAttachment:ne,onViewAttachment:ie}=t;if(i&&!n.id)return e(P,{isLoading:!0,children:e("div",{})});const se=function(e){const{t:a}=Y();if(!e)return[];return{[Z.waitingStart]:[Z.running,Z.suspended,Z.canceled],[Z.running]:[Z.effectivenessCheck,Z.done,Z.suspended,Z.canceled],[Z.effectivenessCheck]:[Z.running,Z.done,Z.suspended,Z.canceled],[Z.done]:[Z.running],[Z.suspended]:[Z.running,Z.canceled],[Z.canceled]:[Z.waitingStart]}[e]||[]}(n.statusId);return a("div",{className:"flex flex-col h-full",children:[a("div",{className:"flex items-center justify-between border-b bg-card px-6 py-4",children:[a("div",{className:"flex items-center gap-4",children:[p&&e(N,{variant:"ghost",size:"icon",onClick:p,children:e(q,{className:"h-4 w-4"})}),a("div",{className:"space-y-1",children:[a("div",{className:"flex items-center gap-3",children:[e("h1",{className:"text-lg font-semibold",children:g?h("ap_new_action"):n.name||h("ap_action_plan")}),!g&&n.statusId&&e(ve,{status:n.statusId})]}),n.code&&e("p",{className:"text-xs text-muted-foreground font-mono",children:n.code})]})]}),a("div",{className:"flex items-center gap-2",children:[!g&&se.length>0&&!l&&a(y,{children:[e(C,{asChild:!0,children:e(N,{variant:"outline",size:"sm",children:"Alterar Status"})}),e(_,{align:"end",children:se.map(a=>e(D,{onClick:()=>m(a),children:ce[a]},a))})]}),!g&&t.onDelete&&a(y,{children:[e(C,{asChild:!0,children:e(N,{variant:"ghost",size:"icon",children:e(W,{className:"h-4 w-4"})})}),e(_,{align:"end",children:e(D,{className:"text-destructive",onClick:u,children:"Excluir"})})]})]})]}),e("div",{className:"flex-1 min-h-0 overflow-y-auto",children:e("div",{className:"max-w-4xl mx-auto px-6 py-6",children:a(A,{value:r,onValueChange:d,children:[a(F,{className:"mb-6",children:[e(I,{value:"general",children:"Geral"}),!g&&e(I,{value:"progress",children:"Progresso"}),!g&&f?.enablePredecessors&&e(I,{value:"predecessors",children:h("ap_predecessors")}),!g&&f?.enableCosts&&e(I,{value:"costs",children:"Custos"}),!g&&f?.enableAttachments&&e(I,{value:"attachments",children:h("ap_attachments")}),!g&&f?.enableComments&&e(I,{value:"comments",children:h("ap_comments")}),!g&&f?.enableHistory&&e(I,{value:"history",children:"Histórico"})]}),e(E,{value:"general",children:e(xe,{formData:n,updateField:c,disabled:l,users:v,places:x,actionTypes:b,causes:w,parentActions:S,config:f})}),!g&&e(E,{value:"progress",children:e(De,{...t})}),!g&&f?.enablePredecessors&&e(E,{value:"predecessors",children:e(ke,{predecessors:L,availablePredecessors:R,onAdd:U,onRemove:O,disabled:l})}),!g&&f?.enableCosts&&e(E,{value:"costs",children:e(Pe,{costs:j,onAdd:H,onEdit:G,onDelete:K,disabled:l})}),!g&&f?.enableAttachments&&e(E,{value:"attachments",children:$||e(Re,{attachments:T,onUpload:ee,onDelete:ae,onRename:te,onDownload:ne,onView:ie,disabled:l})}),!g&&f?.enableComments&&e(E,{value:"comments",children:V||e(Ae,{comments:B,onAdd:J,onEdit:Q,onDelete:X,disabled:l})}),!g&&f?.enableHistory&&e(E,{value:"history",children:M||e(Ie,{history:z})})]})})}),a("div",{className:"flex items-center justify-end gap-3 border-t bg-card px-6 py-4",children:[p&&e(N,{variant:"outline",onClick:p,disabled:s,children:"Cancelar"}),e(N,{onClick:o,disabled:s||l,children:s?"Salvando...":"Salvar"})]})]})}export{Re as ActionPlanAttachmentsTab,Ae as ActionPlanCommentsTab,Pe as ActionPlanCostTab,xe as ActionPlanGeneralTab,Ie as ActionPlanHistoryTab,Be as ActionPlanPage,ke as ActionPlanPredecessorsTab,_e as ActionPlanProgressDialog,De as ActionPlanProgressTab,ve as ActionPlanStatusBadge,pe as CLOSED_STATUSES,oe as DEFAULT_ACTION_TYPES,ne as EAttachmentItemStatus,ae as ETaskPlanAssociationType,ee as ETaskPlanPriority,Z as ETaskPlanStatus,te as ETaskPlanTypeProgress,ue as PRIORITIES,he as PROGRESS_ALLOWED_STATUSES,ie as STATUS_COLORS,ce as STATUS_LABELS,re as STATUS_MAP,se as STATUS_TEXT_COLORS,Ce as formatTime,ye as formatTimeProgress,de as getActionTypes,me as getPriorities,we as getProgressColor,le as getStatusLabels,ge as useActionPlan,be as useActionPlanProgress};
|