forlogic-core 2.3.3 → 2.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/action-plans/index.d.ts +14 -103
  2. package/dist/action-plans/index.esm.js +1 -1
  3. package/dist/action-plans/index.js +1 -1
  4. package/dist/action-plans/types.d.ts +361 -551
  5. package/dist/assets/index.d.ts +31 -0
  6. package/dist/audit-trail/index.d.ts +8 -103
  7. package/dist/audit-trail/types.d.ts +173 -567
  8. package/dist/auth/services/TokenService.d.ts +1 -0
  9. package/dist/auth/services/userPhotoApi.d.ts +5 -0
  10. package/dist/auth/services/userProfileApi.d.ts +18 -0
  11. package/dist/auth/utils/authDebug.d.ts +18 -0
  12. package/dist/components/ui/combobox.d.ts +2 -1
  13. package/dist/exports/integrations.d.ts +2 -0
  14. package/dist/index.css +1 -1
  15. package/dist/index.css.map +1 -1
  16. package/dist/index.d.ts +1 -0
  17. package/dist/index.esm.js +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/leadership/index.d.ts +12 -103
  20. package/dist/leadership/types.d.ts +13 -593
  21. package/dist/places/index.d.ts +8 -104
  22. package/dist/places/types.d.ts +6 -599
  23. package/dist/qualiex/hooks/useQualiexReady.d.ts +15 -0
  24. package/dist/qualiex/services/qualiexApiService.d.ts +18 -0
  25. package/dist/sign/index.d.ts +8 -104
  26. package/dist/sign/index.esm.js +1 -1
  27. package/dist/sign/index.js +1 -1
  28. package/dist/sign/types.d.ts +46 -596
  29. package/dist/updates/components/UpdatesBar.d.ts +10 -0
  30. package/dist/updates/components/UpdatesDialog.d.ts +10 -0
  31. package/dist/updates/components/UserUpdatesViewer.d.ts +5 -0
  32. package/dist/updates/hooks/useUserUpdates.d.ts +5 -0
  33. package/dist/updates/index.d.ts +9 -0
  34. package/dist/updates/services/userUpdatesApi.d.ts +3 -0
  35. package/dist/updates/types.d.ts +24 -0
  36. package/dist/updates/utils/dismissedStore.d.ts +4 -0
  37. package/package.json +2 -2
@@ -1,104 +1,15 @@
1
- import './index.css';
2
- import './setup/favicon';
3
- export { Button } from './components/ui/button';
4
- export { ActionButton } from './components/ui/action-button';
5
- export { Input } from './components/ui/input';
6
- export { Label } from './components/ui/label';
7
- export { Card, CardContent, CardHeader, CardTitle, CardDescription } from './components/ui/card';
8
- export { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger, DialogFooter } from './components/ui/dialog';
9
- export { Form, FormField, FormItem, FormLabel, FormControl, FormMessage } from './components/ui/form';
10
- export { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './components/ui/select';
11
- export { Checkbox } from './components/ui/checkbox';
12
- export { Textarea } from './components/ui/textarea';
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 './types/sidebar';
92
- export * from './config';
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};
@@ -1 +1 @@
1
- "use strict";var e,s,t,a,n,r=require("react/jsx-runtime"),i=require("forlogic-core"),l=require("lucide-react"),c=require("i18next"),o=require("react"),d=require("react-i18next");exports.ETaskPlanStatus=void 0,(e=exports.ETaskPlanStatus||(exports.ETaskPlanStatus={}))[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",exports.ETaskPlanPriority=void 0,(s=exports.ETaskPlanPriority||(exports.ETaskPlanPriority={}))[s.low=0]="low",s[s.medium=1]="medium",s[s.high=2]="high",exports.ETaskPlanAssociationType=void 0,(t=exports.ETaskPlanAssociationType||(exports.ETaskPlanAssociationType={}))[t.plan=2]="plan",t[t.occurrence=3]="occurrence",t[t.risk=4]="risk",t[t.decisions=5]="decisions",t[t.audit=6]="audit",t[t.strategyExtension=7]="strategyExtension",t[t.standardization=8]="standardization",t[t.supplier=9]="supplier",t[t.auditItems=10]="auditItems",exports.ETaskPlanTypeProgress=void 0,(a=exports.ETaskPlanTypeProgress||(exports.ETaskPlanTypeProgress={}))[a.currentProgress=1]="currentProgress",a[a.cumulativeProgress=2]="cumulativeProgress",exports.EAttachmentItemStatus=void 0,(n=exports.EAttachmentItemStatus||(exports.EAttachmentItemStatus={})).uploading="uploading",n.waiting="waiting",n.done="done",n.error="error",n.canceled="canceled",n.duplicateItem="duplicateItem";const u={[exports.ETaskPlanStatus.waitingStart]:"#D6D6D6",[exports.ETaskPlanStatus.running]:"#DAE9F4",[exports.ETaskPlanStatus.effectivenessCheck]:"#1B75BB29",[exports.ETaskPlanStatus.done]:"#DDEECA",[exports.ETaskPlanStatus.suspended]:"#FFF2D6",[exports.ETaskPlanStatus.canceled]:"#F4433629"},x={[exports.ETaskPlanStatus.waitingStart]:"#666666",[exports.ETaskPlanStatus.running]:"#1B75BB",[exports.ETaskPlanStatus.effectivenessCheck]:"#1B75BB",[exports.ETaskPlanStatus.done]:"#4CAF50",[exports.ETaskPlanStatus.suspended]:"#FF9800",[exports.ETaskPlanStatus.canceled]:"#F44336"},m={[exports.ETaskPlanStatus.waitingStart]:"waiting-start",[exports.ETaskPlanStatus.running]:"running",[exports.ETaskPlanStatus.effectivenessCheck]:"effectiveness-check",[exports.ETaskPlanStatus.done]:"done",[exports.ETaskPlanStatus.suspended]:"suspended",[exports.ETaskPlanStatus.canceled]:"canceled"};function p(){return{[exports.ETaskPlanStatus.waitingStart]:c.t("ap_status_waiting_start"),[exports.ETaskPlanStatus.running]:c.t("ap_status_running"),[exports.ETaskPlanStatus.effectivenessCheck]:c.t("ap_status_effectiveness_check"),[exports.ETaskPlanStatus.done]:c.t("ap_status_done"),[exports.ETaskPlanStatus.suspended]:c.t("ap_status_suspended"),[exports.ETaskPlanStatus.canceled]:c.t("ap_status_canceled")}}const h=new Proxy({},{get:(e,s)=>{if("symbol"==typeof s)return;return p()[s]}});const g=[{id:"immediate",label:"Imediata"},{id:"corrective",label:"Corretiva"},{id:"preventive",label:"Preventiva"},{id:"improvement",label:"Oportunidade de Melhoria"},{id:"standardization",label:"Padronização"}];const j=[{id:exports.ETaskPlanPriority.low,label:"Baixa",color:"#4CAF50"},{id:exports.ETaskPlanPriority.medium,label:"Média",color:"#FF9800"},{id:exports.ETaskPlanPriority.high,label:"Alta",color:"#F44336"}],f=[exports.ETaskPlanStatus.done,exports.ETaskPlanStatus.canceled],v=[exports.ETaskPlanStatus.waitingStart,exports.ETaskPlanStatus.running,exports.ETaskPlanStatus.effectivenessCheck,exports.ETaskPlanStatus.suspended];function b(e){const{actionPlan:s,isNew:t=!1,config:a,onSave:n,onCancel:r,onDelete:i,onChangeStatus:l}=e,[c,d]=o.useState({formData:s||{},isLoading:e.isLoading||!1,isSaving:!1,activeTab:"general",isFormDisabled:!1});o.useEffect(()=>{s&&d(e=>({...e,formData:s,isFormDisabled:a?.disableFields||f.includes(s.statusId)}))},[s,a?.disableFields]),o.useEffect(()=>{d(s=>({...s,isLoading:e.isLoading||!1}))},[e.isLoading]);const u=o.useCallback((e,s)=>{d(t=>({...t,formData:{...t.formData,[e]:s}}))},[]),x=o.useCallback(e=>{d(s=>({...s,activeTab:e}))},[]),m=o.useCallback(async()=>{if(n){d(e=>({...e,isSaving:!0}));try{await n(c.formData)}finally{d(e=>({...e,isSaving:!1}))}}},[n,c.formData]),p=o.useCallback(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=o.useCallback(async()=>{if(i&&c.formData.id){d(e=>({...e,isLoading:!0}));try{await i(c.formData.id)}finally{d(e=>({...e,isLoading:!1}))}}},[i,c.formData.id]);return{formData:c.formData,isLoading:c.isLoading,isSaving:c.isSaving,activeTab:c.activeTab,isFormDisabled:c.isFormDisabled,updateField:u,setActiveTab:x,save:m,changeStatus:p,remove:h,cancel:r}}const S={[exports.ETaskPlanStatus.waitingStart]:{label:"",color:"#8B7355",icon:l.Clock},[exports.ETaskPlanStatus.running]:{label:"",color:"#2E7D5B",icon:l.Play},[exports.ETaskPlanStatus.effectivenessCheck]:{label:"",color:"#4A6FA5",icon:l.ShieldCheck},[exports.ETaskPlanStatus.done]:{label:"",color:"#3D7A40",icon:l.CheckCircle2},[exports.ETaskPlanStatus.suspended]:{label:"",color:"#6B7280",icon:l.Pause},[exports.ETaskPlanStatus.canceled]:{label:"",color:"#B44A4A",icon:l.X}};function N({status:e,labels:s,className:t,size:a,showIcon:n,variant:l}){const c=p(),o=S[e];if(!o)return null;const d=s?.[e]||c[e]||"";return r.jsx(i.StatusBadge,{label:d,color:o.color,icon:o.icon,size:a,showIcon:n,variant:l,className:t})}function T({formData:e,updateField:s,disabled:t=!1,users:a=[],places:n=[],actionTypes:l,causes:c=[],parentActions:u=[],config:x}){const{t:m}=d.useTranslation(),p=x?.requiredFields,h=l||g,f=e=>{if(x?.hiddenFields?.includes(e))return!1;if(x?.visibleFields&&x.visibleFields.length>0)return x.visibleFields.includes(e);const s=`${e}Visible`;return!p||!(s in p)||!1!==p[s]},v=e=>p?!!p[e]:"name"===e,b=o.useMemo(()=>{if(e.startDate&&e.endDate){const s=new Date(e.startDate),t=new Date(e.endDate).getTime()-s.getTime();return Math.max(0,Math.ceil(t/864e5))}return e.duration||0},[e.startDate,e.endDate,e.duration]);return r.jsxs("div",{className:"space-y-6 p-1",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(i.Label,{className:i.cn(v("name")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Nome"}),r.jsx(i.Input,{value:e.name||"",onChange:e=>s("name",e.target.value),maxLength:500,disabled:t,placeholder:m("ap_plan_name_placeholder")})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[f("responsibleWho")&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(i.Label,{className:i.cn(v("responsibleWho")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Responsável"}),r.jsxs(i.Select,{value:e.responsibleId||"",onValueChange:e=>s("responsibleId",e),disabled:t,children:[r.jsx(i.SelectTrigger,{children:r.jsx(i.SelectValue,{placeholder:m("ap_select_responsible")})}),r.jsx(i.SelectContent,{children:a.map(e=>r.jsx(i.SelectItem,{value:e.id,children:e.name},e.id))})]})]}),f("checkerWho")&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(i.Label,{className:i.cn(v("checkerWho")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Verificador"}),r.jsxs(i.Select,{value:e.checkerId||"",onValueChange:e=>s("checkerId",e),disabled:t,children:[r.jsx(i.SelectTrigger,{children:r.jsx(i.SelectValue,{placeholder:m("ap_select_checker")})}),r.jsx(i.SelectContent,{children:a.map(e=>r.jsx(i.SelectItem,{value:e.id,children:e.name},e.id))})]})]})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[f("place")&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(i.Label,{className:i.cn(v("place")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Local"}),r.jsxs(i.Select,{value:e.placeId||"",onValueChange:e=>s("placeId",e),disabled:t,children:[r.jsx(i.SelectTrigger,{children:r.jsx(i.SelectValue,{placeholder:m("ap_select_place")})}),r.jsx(i.SelectContent,{children:y(n).map(e=>r.jsx(i.SelectItem,{value:e.id,children:e.name},e.id))})]})]}),f("planType")&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(i.Label,{className:i.cn(v("planType")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Tipo de Ação"}),r.jsxs(i.Select,{value:e.typeId||"",onValueChange:e=>s("typeId",e),disabled:t,children:[r.jsx(i.SelectTrigger,{children:r.jsx(i.SelectValue,{placeholder:m("ap_select_type")})}),r.jsx(i.SelectContent,{children:h.map(e=>r.jsx(i.SelectItem,{value:e.id,children:e.label},e.id))})]})]})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[f("priority")&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(i.Label,{className:i.cn(v("priority")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Prioridade"}),r.jsxs(i.Select,{value:e.priorityType?.toString()||"",onValueChange:e=>s("priorityType",Number(e)),disabled:t,children:[r.jsx(i.SelectTrigger,{children:r.jsx(i.SelectValue,{placeholder:m("ap_select_priority")})}),r.jsx(i.SelectContent,{children:j.map(e=>r.jsx(i.SelectItem,{value:e.id.toString(),children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:e.color}}),e.label]})},e.id))})]})]}),u.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(i.Label,{children:m("ap_belongs_to")}),r.jsxs(i.Select,{value:e.parentId||"",onValueChange:e=>s("parentId",e),disabled:t,children:[r.jsx(i.SelectTrigger,{children:r.jsx(i.SelectValue,{placeholder:m("ap_select_parent")})}),r.jsx(i.SelectContent,{children:u.map(e=>r.jsx(i.SelectItem,{value:e.id,children:e.label},e.id))})]})]})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[f("startDate")&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(i.Label,{className:i.cn(v("startDate")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Data de Início"}),r.jsx(i.DatePicker,{date:e.startDate?new Date(e.startDate):void 0,onDateChange:e=>s("startDate",e||null),disabled:t,placeholder:m("ap_select_date")})]}),f("endDate")&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(i.Label,{className:i.cn(v("endDate")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Data de Término"}),r.jsx(i.DatePicker,{date:e.endDate?new Date(e.endDate):void 0,onDateChange:e=>s("endDate",e||null),disabled:t,placeholder:m("ap_select_date"),disabledDates:e.startDate?s=>s<new Date(e.startDate):void 0})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(i.Label,{children:m("ap_duration_days")}),r.jsx(i.Input,{type:"number",value:b,disabled:!0,className:"bg-muted"})]})]}),f("estimatedCost")&&r.jsxs("div",{className:"space-y-2 max-w-xs",children:[r.jsx(i.Label,{className:i.cn(v("estimatedCost")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Custo Estimado"}),r.jsxs("div",{className:"relative",children:[r.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"R$"}),r.jsx(i.Input,{type:"number",min:0,step:.01,value:e.estimatedCost||"",onChange:e=>s("estimatedCost",Number(e.target.value)),disabled:t,className:"pl-9",placeholder:"0,00"})]})]}),f("cause")&&c.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(i.Label,{children:"Causa"}),r.jsxs(i.Select,{value:e.causeId||"",onValueChange:e=>s("causeId",e),disabled:t,children:[r.jsx(i.SelectTrigger,{children:r.jsx(i.SelectValue,{placeholder:m("ap_select_cause")})}),r.jsx(i.SelectContent,{children:c.map(e=>r.jsx(i.SelectItem,{value:e.id,children:e.label},e.id))})]})]}),f("description")&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(i.Label,{className:i.cn(v("description")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Descrição"}),r.jsx(i.Textarea,{value:e.description||"",onChange:e=>s("description",e.target.value),maxLength:4e3,disabled:t,rows:4,placeholder:m("ap_description_placeholder")})]}),f("justification")&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(i.Label,{className:i.cn(v("justification")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Justificativa"}),r.jsx(i.Textarea,{value:e.justification||"",onChange:e=>s("justification",e.target.value),maxLength:4e3,disabled:t,rows:4,placeholder:m("ap_justification_placeholder")})]})]})}function y(e,s=0){const t=[];for(const a of e)t.push({...a,depth:s}),a.children?.length&&t.push(...y(a.children,s+1));return t}function P(e){const{progress:s,onReportProgress:t,onEditProgress:a,onDeleteProgress:n}=e,[r,i]=o.useState(!1),[l,c]=o.useState(null),d=!!s&&v.includes(s.status),u=o.useCallback(async e=>{if(t&&s){i(!0);try{const a=100===e.percentProgress;await t({id:s.id,...e,conclude:a})}finally{i(!1)}}},[t,s]),x=o.useCallback(async e=>{if(a){i(!0);try{await a(e)}finally{i(!1),c(null)}}},[a]),m=o.useCallback(async e=>{if(n){i(!0);try{await n(e)}finally{i(!1)}}},[n]);return{progress:s,canReportProgress:d,isSubmitting:r,editingReport:l,setEditingReport:c,reportProgress:u,editProgress:x,deleteProgress:m}}function C(e){if(!e)return"";let s=(e||"").trim();if(!s)return"00:00";if(s.includes(":")){const e=s.split(":");if(e.length>=2){const s=e[0].replace(/\D/g,""),t=e[1].replace(/\D/g,"");let a=parseInt(s)||0,n=parseInt(t)||0;return a+=Math.floor(n/60),n%=60,`${a.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`}}if(s=s.replace(/\D/g,""),!s)return"00:00";let t=0,a=0;return 4===s.length?(t=parseInt(s.substring(0,2))||0,a=parseInt(s.substring(2,4))||0,t+=Math.floor(a/60),a%=60):(t=parseInt(s)||0,a=0),`${t.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`}function k(e){if(null==e)return"00:00";const s=String(e).replace(/\D/g,"");if(s.length<3){let e=parseInt(s)||0;const t=Math.floor(e/60);return e%=60,`${t.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`}{const e=s.slice(-2),t=s.slice(0,-2);let a=parseInt(t)||0,n=parseInt(e)||0;return a+=Math.floor(n/60),n%=60,`${a.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`}}function w(e){return 100===e?"#84c148":e>0?"#1b75bb":""}function D({open:e,onOpenChange:s,report:t,onSave:a,isSubmitting:n=!1}){const{t:l}=d.useTranslation(),[c,u]=o.useState(t?.percentProgress||0),[x,m]=o.useState(t?.timeProgress||""),[p,h]=o.useState(t?.comments||""),g=c!==(t?.percentProgress??0)||x!==(t?.timeProgress??"")||p!==(t?.comments??"");o.useEffect(()=>{t&&(u(t.percentProgress),m(t.timeProgress||""),h(t.comments||""))},[t]);return r.jsx(i.Dialog,{open:e,onOpenChange:s,children:r.jsxs(i.DialogContent,{className:"sm:max-w-md",variant:"form",isDirty:g,children:[r.jsx(i.DialogHeader,{children:r.jsx(i.DialogTitle,{children:l("ap_edit_progress")})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(i.Label,{children:l("ap_progress_percent")}),r.jsx(i.Input,{type:"number",min:0,max:100,value:c,onChange:e=>u(Number(e.target.value))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(i.Label,{children:l("ap_time_spent")}),r.jsx(i.Input,{value:x,onChange:e=>m(e.target.value),onBlur:()=>m(C(x)||""),placeholder:"00:00"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(i.Label,{children:l("ap_comments")}),r.jsx(i.Textarea,{value:p,onChange:e=>h(e.target.value),rows:3,maxLength:4e3})]})]}),r.jsxs(i.DialogFooter,{children:[r.jsx(i.Button,{variant:"outline",onClick:()=>s(!1),disabled:n,children:"Cancelar"}),r.jsx(i.Button,{onClick:()=>{t&&a({...t,percentProgress:c,timeProgress:C(x)||"00:00",comments:p})},disabled:n,children:n?"Salvando...":"Salvar"})]})]})})}function E(e){const{t:s}=d.useTranslation(),{progress:t,canReportProgress:a,isSubmitting:n,editingReport:l,setEditingReport:c,reportProgress:u,editProgress:x,deleteProgress:m}=P(e),[p,h]=o.useState(""),[g,j]=o.useState(""),[f,v]=o.useState("");if(!t)return r.jsx("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:"Sem dados de progresso disponíveis"});const b=w(t.percentProgress),S=!p,N=!p&&!g&&!f;return r.jsxs("div",{className:"space-y-6 p-1",children:[r.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"font-medium",children:s("ap_overall_progress")}),r.jsxs("span",{className:"font-semibold",style:{color:b||void 0},children:[t.percentProgress,"%"]})]}),r.jsx(i.Progress,{value:t.percentProgress,className:"h-3"}),t.timeProgress&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:["Tempo total: ",k(t.timeProgress)]})]}),a&&r.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-4",children:[r.jsx("h4",{className:"text-sm font-medium",children:s("ap_report_progress")}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(i.Label,{children:s("ap_progress_percent")}),r.jsx(i.Input,{type:"number",min:0,max:100,value:p,onChange:e=>h(e.target.value),placeholder:"0"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(i.Label,{children:s("ap_time_spent")}),r.jsx(i.Input,{value:g,onChange:e=>j(e.target.value),onBlur:()=>j(C(g)||""),placeholder:"00:00"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(i.Label,{children:s("ap_comments")}),r.jsx(i.Textarea,{value:f,onChange:e=>v(e.target.value),rows:3,maxLength:4e3,placeholder:s("ap_progress_comment_placeholder")})]}),r.jsxs("div",{className:"flex gap-2 justify-end",children:[r.jsx(i.Button,{variant:"outline",size:"sm",onClick:()=>{h(""),j(""),v("")},disabled:N||n,children:"Limpar"}),r.jsx(i.Button,{size:"sm",onClick:async()=>{const e=Number(p);(e||0===e)&&(await u({percentProgress:e,timeProgress:C(g)||"00:00",comments:f}),h(""),j(""),v(""))},disabled:S||n,children:n?"Reportando...":"Reportar"})]})]}),t.reports.length>0&&r.jsxs("div",{className:"space-y-3",children:[r.jsx("h4",{className:"text-sm font-medium",children:s("ap_reports_history")}),r.jsx("div",{className:"space-y-2",children:t.reports.map(e=>r.jsx(_,{report:e,onEdit:()=>c(e),onDelete:()=>m(e.id),disabled:!a},e.id))})]}),r.jsx(D,{open:!!l,onOpenChange:e=>!e&&c(null),report:l,onSave:x,isSubmitting:n})]})}function _({report:e,onEdit:s,onDelete:t,disabled:a}){const n=e.date?new Date(e.date):null,l=w(e.percentProgress);return r.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-card p-3",children:[r.jsx("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:e.userName?.charAt(0)?.toUpperCase()||"?"}),r.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx("span",{className:"font-medium truncate",children:e.userName}),n&&r.jsx("span",{className:"text-xs text-muted-foreground",children:n.toLocaleDateString("pt-BR")})]}),r.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[r.jsxs("span",{style:{color:l||void 0},className:"font-semibold",children:[e.percentProgress,"%"]}),e.timeProgress&&r.jsxs("span",{children:["Tempo: ",k(e.timeProgress)]})]}),e.comments&&r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:e.comments})]}),!a&&r.jsxs(i.DropdownMenu,{children:[r.jsx(i.DropdownMenuTrigger,{asChild:!0,children:r.jsx(i.ActionButton,{})}),r.jsxs(i.DropdownMenuContent,{align:"end",children:[r.jsx(i.DropdownMenuItem,{onClick:s,children:c.t("edit")}),r.jsx(i.DropdownMenuItem,{className:"text-destructive",onClick:t,children:c.t("ap_delete")})]})]})]})}function A({predecessors:e=[],availablePredecessors:s=[],onAdd:t,onRemove:a,disabled:n=!1}){const{t:c}=d.useTranslation(),[u,x]=o.useState(""),m=s.filter(s=>!e.some(e=>e.predecessorId===s.id));return r.jsxs("div",{className:"space-y-6 p-1",children:[!n&&m.length>0&&r.jsxs("div",{className:"flex items-end gap-3",children:[r.jsxs("div",{className:"flex-1 space-y-2",children:[r.jsx(i.Label,{children:c("ap_add_predecessor")}),r.jsxs(i.Select,{value:u,onValueChange:x,children:[r.jsx(i.SelectTrigger,{children:r.jsx(i.SelectValue,{placeholder:c("ap_select_action")})}),r.jsx(i.SelectContent,{children:m.map(e=>r.jsx(i.SelectItem,{value:e.id,children:e.label},e.id))})]})]}),r.jsxs(i.Button,{size:"sm",onClick:()=>{u&&t&&(t(u),x(""))},disabled:!u,children:[r.jsx(l.Plus,{className:"h-4 w-4 mr-1"}),"Adicionar"]})]}),e.length>0?r.jsx("div",{className:"space-y-2",children:e.map(e=>r.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-card p-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[e.predecessorCode&&r.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:e.predecessorCode}),r.jsx("span",{className:"text-sm font-medium",children:e.predecessorName}),null!=e.predecessorStatus&&r.jsx(N,{status:e.predecessorStatus})]}),!n&&a&&r.jsxs(i.DropdownMenu,{children:[r.jsx(i.DropdownMenuTrigger,{asChild:!0,children:r.jsx(i.ActionButton,{})}),r.jsx(i.DropdownMenuContent,{align:"end",children:r.jsx(i.DropdownMenuItem,{className:"text-destructive",onClick:()=>a(e.predecessorId),children:"Remover"})})]})]},e.id))}):r.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"Nenhum predecessor adicionado"})]})}function I({costs:e=[],onAdd:s,onEdit:t,onDelete:a,disabled:n=!1}){const{t:c}=d.useTranslation(),[u,x]=o.useState(""),[m,p]=o.useState(""),h=e.reduce((e,s)=>e+(s.value||0),0);return r.jsxs("div",{className:"space-y-6 p-1",children:[r.jsxs("div",{className:"rounded-lg border bg-card p-4 flex items-center justify-between",children:[r.jsx("span",{className:"text-sm font-medium",children:c("ap_total_cost")}),r.jsxs("span",{className:"text-lg font-semibold text-foreground",children:["R$ ",h.toLocaleString("pt-BR",{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),!n&&s&&r.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-4",children:[r.jsx("h4",{className:"text-sm font-medium",children:c("ap_add_cost")}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(i.Label,{children:"Descrição"}),r.jsx(i.Input,{value:u,onChange:e=>x(e.target.value),placeholder:c("ap_cost_description")})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(i.Label,{children:"Valor (R$)"}),r.jsx(i.Input,{type:"number",min:0,step:.01,value:m,onChange:e=>p(e.target.value),placeholder:"0,00"})]})]}),r.jsx("div",{className:"flex justify-end",children:r.jsxs(i.Button,{size:"sm",onClick:()=>{u&&m&&s&&(s({description:u,value:Number(m),date:(new Date).toISOString()}),x(""),p(""))},disabled:!u||!m,children:[r.jsx(l.Plus,{className:"h-4 w-4 mr-1"}),"Adicionar"]})})]}),e.length>0?r.jsx("div",{className:"space-y-2",children:e.map(e=>r.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-card p-3",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:e.description}),e.date&&r.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(e.date).toLocaleDateString("pt-BR")})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("span",{className:"text-sm font-semibold whitespace-nowrap",children:["R$ ",e.value.toLocaleString("pt-BR",{minimumFractionDigits:2,maximumFractionDigits:2})]}),!n&&(t||a)&&r.jsxs(i.DropdownMenu,{children:[r.jsx(i.DropdownMenuTrigger,{asChild:!0,children:r.jsx(i.ActionButton,{})}),r.jsxs(i.DropdownMenuContent,{align:"end",children:[t&&r.jsx(i.DropdownMenuItem,{onClick:()=>t(e),children:c("edit")}),a&&r.jsx(i.DropdownMenuItem,{className:"text-destructive",onClick:()=>a(e.id),children:c("ap_delete")})]})]})]})]},e.id))}):r.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"Nenhum custo registrado"})]})}function L({comments:e=[],currentUserId:s,onAdd:t,onEdit:a,onDelete:n,disabled:c=!1,maxLength:u=4e3}){const{t:x}=d.useTranslation(),[m,p]=o.useState(""),[h,g]=o.useState(!1),[j,f]=o.useState(null),[v,b]=o.useState(""),S=()=>{f(null),b("")};return r.jsxs("div",{className:"space-y-6 p-1",children:[!c&&t&&r.jsxs("div",{className:"space-y-3",children:[r.jsx(i.Textarea,{value:m,onChange:e=>p(e.target.value),placeholder:x("ap_add_comment_placeholder"),maxLength:u,rows:3}),r.jsxs("div",{className:"flex items-center justify-between",children:[u&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:[m.length,"/",u]}),r.jsxs("div",{className:"flex gap-2 ml-auto",children:[r.jsx(i.Button,{variant:"outline",size:"sm",onClick:()=>p(""),disabled:!m||h,children:"Limpar"}),r.jsx(i.Button,{size:"sm",onClick:async()=>{if(m.trim()&&t){g(!0);try{await t(m),p("")}finally{g(!1)}}},disabled:!m.trim()||h,children:h?"Enviando...":"Comentar"})]})]})]}),r.jsxs("div",{className:"space-y-1",children:[e.length>0?r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx("span",{className:"text-sm font-medium",children:x("ap_comments")}),r.jsx(i.Badge,{variant:"info",className:"text-[10px] px-1.5 py-0",children:e.length})]}):r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[r.jsx(l.MessageSquare,{className:"h-8 w-8 mb-2 opacity-50"}),r.jsx("p",{className:"text-sm",children:"Nenhum comentário adicionado"})]}),e.map(e=>r.jsxs("div",{className:"flex gap-3 rounded-lg border bg-card p-3",children:[r.jsx("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:e.userPhotoUrl?r.jsx("img",{src:e.userPhotoUrl,alt:e.userName,className:"h-full w-full object-cover"}):e.userName?.charAt(0)?.toUpperCase()||"?"}),r.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx("span",{className:"font-medium truncate",children:e.userName}),e.userEmail&&r.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.userEmail}),r.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:B(e.dateEdited||e.dateCreation)}),e.dateEdited&&r.jsx("span",{className:"text-xs text-muted-foreground italic",children:"editado"})]}),j===e.id?r.jsxs("div",{className:"space-y-2",children:[r.jsx(i.Textarea,{value:v,onChange:e=>b(e.target.value),maxLength:u,rows:3}),r.jsxs("div",{className:"flex gap-2 justify-end",children:[r.jsx(i.Button,{variant:"outline",size:"sm",onClick:S,disabled:h,children:"Cancelar"}),r.jsx(i.Button,{size:"sm",onClick:()=>(async e=>{if(v.trim()&&a){g(!0);try{await a({...e,text:v,stringText:v}),f(null),b("")}finally{g(!1)}}})(e),disabled:!v.trim()||h,children:h?"Salvando...":"Salvar"})]})]}):r.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:e.stringText||e.text})]}),!c&&s===e.userId&&j!==e.id&&r.jsxs(i.DropdownMenu,{children:[r.jsx(i.DropdownMenuTrigger,{asChild:!0,children:r.jsx(i.ActionButton,{})}),r.jsxs(i.DropdownMenuContent,{align:"end",children:[a&&r.jsx(i.DropdownMenuItem,{onClick:()=>(e=>{f(e.id),b(e.stringText||e.text)})(e),children:x("edit")}),n&&r.jsx(i.DropdownMenuItem,{className:"text-destructive",onClick:()=>(async e=>{if(n){g(!0);try{await n(e)}finally{g(!1)}}})(e.id),children:"Excluir"})]})]})]},e.id))]})]})}function B(e){const{t:s}=d.useTranslation();if(!e)return"";const t=new Date(e);return`${t.toLocaleDateString("pt-BR")} ${t.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}`}function M({history:e=[],isLoading:s=!1}){const{t:t}=d.useTranslation();return s?r.jsx("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:"Carregando histórico..."}):0===e.length?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[r.jsx(l.Clock,{className:"h-8 w-8 mb-2 opacity-50"}),r.jsx("p",{className:"text-sm",children:t("ap_no_history")})]}):r.jsx("div",{className:"p-1",children:r.jsxs("div",{className:"relative",children:[r.jsx("div",{className:"absolute left-4 top-0 bottom-0 w-px bg-border"}),r.jsx("div",{className:"space-y-0",children:e.map((e,s)=>r.jsxs("div",{className:"relative flex gap-4 pb-6 last:pb-0",children:[r.jsx("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:e.icon?r.jsx("span",{className:"text-xs text-primary",children:e.icon}):r.jsx("div",{className:"h-2 w-2 rounded-full bg-primary"})}),r.jsxs("div",{className:"flex-1 min-w-0 rounded-lg border bg-card p-3 space-y-2",children:[r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium",children:e.translateEvent||e.eventName}),e.eventDescription&&r.jsx("p",{className:"text-xs text-muted-foreground",children:e.eventDescription})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("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:e.userPhotoUrl?r.jsx("img",{src:e.userPhotoUrl,alt:e.userName,className:"h-full w-full object-cover"}):e.userName?.charAt(0)?.toUpperCase()||"?"}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("span",{className:"text-xs font-medium truncate block",children:e.userName}),e.userEmail&&r.jsx("span",{className:"text-[10px] text-muted-foreground truncate block",children:e.userEmail})]})]}),r.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(l.Calendar,{className:"h-3 w-3"}),r.jsx("span",{children:F(e.date)})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(l.Clock,{className:"h-3 w-3"}),r.jsx("span",{children:R(e.date)})]}),e.isMobileRequest&&r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(l.Smartphone,{className:"h-3 w-3"}),r.jsx("span",{children:t("ap_via_app")})]})]})]})]},e.id))})]})})}function F(e){const{t:s}=d.useTranslation();return new Date(e).toLocaleDateString("pt-BR")}function R(e){const{t:s}=d.useTranslation();return new Date(e).toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}function z({attachments:e=[],onUpload:s,onDelete:t,onRename:a,onDownload:n,onView:c,disabled:u=!1}){const{t:x}=d.useTranslation(),m=o.useRef(null),[p,h]=o.useState(null),[g,j]=o.useState(""),f=async e=>{g.trim()&&a&&(await a(e.id,g),h(null),j(""))},v=()=>{h(null),j("")};return r.jsxs("div",{className:"space-y-4 p-1",children:[!u&&s&&r.jsxs(r.Fragment,{children:[r.jsx("input",{ref:m,type:"file",multiple:!0,className:"hidden",onChange:e=>{const t=e.target.files;if(t&&s){for(let e=0;e<t.length;e++){const a=t.item(e);a&&s(a)}m.current&&(m.current.value="")}}}),r.jsxs(i.Button,{size:"sm",onClick:()=>m.current?.click(),children:[r.jsx(l.Plus,{className:"h-4 w-4 mr-1"}),"Adicionar anexo"]})]}),e.length>0?r.jsx("div",{className:"space-y-2",children:e.map(e=>r.jsxs("div",{className:i.cn("flex items-center gap-3 rounded-lg border bg-card p-3",e.status===exports.EAttachmentItemStatus.error&&"border-destructive/50 bg-destructive/5",e.status===exports.EAttachmentItemStatus.canceled&&"opacity-50"),children:[r.jsx("div",{className:"flex-shrink-0 h-9 w-9 rounded bg-muted flex items-center justify-center",children:r.jsx("span",{className:"text-[10px] font-bold uppercase text-muted-foreground",children:e.extension.replace(".","").substring(0,4)})}),r.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[p===e.id?r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{className:"flex-1 text-sm border rounded px-2 py-1 bg-background",value:g,onChange:e=>j(e.target.value),onKeyDown:s=>{"Enter"===s.key&&f(e),"Escape"===s.key&&v()},autoFocus:!0}),r.jsx(i.Button,{size:"sm",variant:"outline",onClick:v,children:x("cancel")}),r.jsx(i.Button,{size:"sm",onClick:()=>f(e),children:x("save")})]}):r.jsx("button",{type:"button",className:"text-sm font-medium truncate block text-left hover:underline cursor-pointer",onClick:()=>c?.(e.id),children:e.name}),(e.status===exports.EAttachmentItemStatus.uploading||e.status===exports.EAttachmentItemStatus.waiting)&&r.jsx(i.Progress,{value:e.progress||0,className:"h-1.5"}),e.status===exports.EAttachmentItemStatus.error&&r.jsx("p",{className:"text-xs text-destructive",children:"Erro ao enviar arquivo"}),e.status===exports.EAttachmentItemStatus.duplicateItem&&r.jsx("p",{className:"text-xs text-warning",children:"Arquivo duplicado"}),e.status===exports.EAttachmentItemStatus.canceled&&r.jsx("p",{className:"text-xs text-muted-foreground",children:"Upload cancelado"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[e.status===exports.EAttachmentItemStatus.done&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:V(e.size)}),r.jsxs(i.DropdownMenu,{children:[r.jsx(i.DropdownMenuTrigger,{asChild:!0,children:r.jsx(i.ActionButton,{})}),r.jsxs(i.DropdownMenuContent,{align:"end",children:[a&&!u&&r.jsx(i.DropdownMenuItem,{onClick:()=>(e=>{const s=e.name.replace(e.extension,"");h(e.id),j(s)})(e),children:"Renomear"}),c&&r.jsx(i.DropdownMenuItem,{onClick:()=>c(e.id),children:"Visualizar"}),n&&r.jsx(i.DropdownMenuItem,{onClick:()=>n(e.id),children:"Download"}),t&&!u&&r.jsxs(r.Fragment,{children:[r.jsx(i.DropdownMenuSeparator,{}),r.jsx(i.DropdownMenuItem,{className:"text-destructive",onClick:()=>t(e.id),children:"Excluir"})]})]})]})]}),e.status===exports.EAttachmentItemStatus.uploading&&r.jsx(i.Button,{variant:"outline",size:"sm",onClick:()=>t?.(e.id),children:"Cancelar"})]})]},e.id))}):r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[r.jsx(l.Paperclip,{className:"h-8 w-8 mb-2 opacity-50"}),r.jsx("p",{className:"text-sm",children:"Nenhum anexo adicionado"})]})]})}function V(e){const{t:s}=d.useTranslation();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]}`}exports.ActionPlanAttachmentsTab=z,exports.ActionPlanCommentsTab=L,exports.ActionPlanCostTab=I,exports.ActionPlanGeneralTab=T,exports.ActionPlanHistoryTab=M,exports.ActionPlanPage=function(e){const{formData:s,isLoading:t,isSaving:a,activeTab:n,isFormDisabled:c,updateField:o,setActiveTab:u,save:x,changeStatus:m,remove:p,cancel:g}=b(e),{t:j}=d.useTranslation(),{isNew:f=!1,config:v,users:S,places:y,actionTypes:P,causes:C,parentActions:k,progress:w,predecessors:D,availablePredecessors:_,costs:B,comments:F,history:R,attachments:V,attachmentsSlot:U,commentsSlot:$,historySlot:O,onAddPredecessor:q,onRemovePredecessor:H,onAddCost:W,onEditCost:G,onDeleteCost:K,onAddComment:X,onEditComment:J,onDeleteComment:Y,onUploadAttachment:Q,onDeleteAttachment:Z,onRenameAttachment:ee,onDownloadAttachment:se,onViewAttachment:te}=e;if(t&&!s.id)return r.jsx(i.LoadingState,{isLoading:!0,children:r.jsx("div",{})});const ae=function(e){const{t:s}=d.useTranslation();if(!e)return[];return{[exports.ETaskPlanStatus.waitingStart]:[exports.ETaskPlanStatus.running,exports.ETaskPlanStatus.suspended,exports.ETaskPlanStatus.canceled],[exports.ETaskPlanStatus.running]:[exports.ETaskPlanStatus.effectivenessCheck,exports.ETaskPlanStatus.done,exports.ETaskPlanStatus.suspended,exports.ETaskPlanStatus.canceled],[exports.ETaskPlanStatus.effectivenessCheck]:[exports.ETaskPlanStatus.running,exports.ETaskPlanStatus.done,exports.ETaskPlanStatus.suspended,exports.ETaskPlanStatus.canceled],[exports.ETaskPlanStatus.done]:[exports.ETaskPlanStatus.running],[exports.ETaskPlanStatus.suspended]:[exports.ETaskPlanStatus.running,exports.ETaskPlanStatus.canceled],[exports.ETaskPlanStatus.canceled]:[exports.ETaskPlanStatus.waitingStart]}[e]||[]}(s.statusId);return r.jsxs("div",{className:"flex flex-col h-full",children:[r.jsxs("div",{className:"flex items-center justify-between border-b bg-card px-6 py-4",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[g&&r.jsx(i.Button,{variant:"ghost",size:"icon",onClick:g,children:r.jsx(l.ArrowLeft,{className:"h-4 w-4"})}),r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("h1",{className:"text-lg font-semibold",children:f?j("ap_new_action"):s.name||j("ap_action_plan")}),!f&&s.statusId&&r.jsx(N,{status:s.statusId})]}),s.code&&r.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:s.code})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[!f&&ae.length>0&&!c&&r.jsxs(i.DropdownMenu,{children:[r.jsx(i.DropdownMenuTrigger,{asChild:!0,children:r.jsx(i.Button,{variant:"outline",size:"sm",children:"Alterar Status"})}),r.jsx(i.DropdownMenuContent,{align:"end",children:ae.map(e=>r.jsx(i.DropdownMenuItem,{onClick:()=>m(e),children:h[e]},e))})]}),!f&&e.onDelete&&r.jsxs(i.DropdownMenu,{children:[r.jsx(i.DropdownMenuTrigger,{asChild:!0,children:r.jsx(i.Button,{variant:"ghost",size:"icon",children:r.jsx(l.MoreVertical,{className:"h-4 w-4"})})}),r.jsx(i.DropdownMenuContent,{align:"end",children:r.jsx(i.DropdownMenuItem,{className:"text-destructive",onClick:p,children:"Excluir"})})]})]})]}),r.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:r.jsx("div",{className:"max-w-4xl mx-auto px-6 py-6",children:r.jsxs(i.Tabs,{value:n,onValueChange:u,children:[r.jsxs(i.TabsList,{className:"mb-6",children:[r.jsx(i.TabsTrigger,{value:"general",children:"Geral"}),!f&&r.jsx(i.TabsTrigger,{value:"progress",children:"Progresso"}),!f&&v?.enablePredecessors&&r.jsx(i.TabsTrigger,{value:"predecessors",children:j("ap_predecessors")}),!f&&v?.enableCosts&&r.jsx(i.TabsTrigger,{value:"costs",children:"Custos"}),!f&&v?.enableAttachments&&r.jsx(i.TabsTrigger,{value:"attachments",children:j("ap_attachments")}),!f&&v?.enableComments&&r.jsx(i.TabsTrigger,{value:"comments",children:j("ap_comments")}),!f&&v?.enableHistory&&r.jsx(i.TabsTrigger,{value:"history",children:"Histórico"})]}),r.jsx(i.TabsContent,{value:"general",children:r.jsx(T,{formData:s,updateField:o,disabled:c,users:S,places:y,actionTypes:P,causes:C,parentActions:k,config:v})}),!f&&r.jsx(i.TabsContent,{value:"progress",children:r.jsx(E,{...e})}),!f&&v?.enablePredecessors&&r.jsx(i.TabsContent,{value:"predecessors",children:r.jsx(A,{predecessors:D,availablePredecessors:_,onAdd:q,onRemove:H,disabled:c})}),!f&&v?.enableCosts&&r.jsx(i.TabsContent,{value:"costs",children:r.jsx(I,{costs:B,onAdd:W,onEdit:G,onDelete:K,disabled:c})}),!f&&v?.enableAttachments&&r.jsx(i.TabsContent,{value:"attachments",children:U||r.jsx(z,{attachments:V,onUpload:Q,onDelete:Z,onRename:ee,onDownload:se,onView:te,disabled:c})}),!f&&v?.enableComments&&r.jsx(i.TabsContent,{value:"comments",children:$||r.jsx(L,{comments:F,onAdd:X,onEdit:J,onDelete:Y,disabled:c})}),!f&&v?.enableHistory&&r.jsx(i.TabsContent,{value:"history",children:O||r.jsx(M,{history:R})})]})})}),r.jsxs("div",{className:"flex items-center justify-end gap-3 border-t bg-card px-6 py-4",children:[g&&r.jsx(i.Button,{variant:"outline",onClick:g,disabled:a,children:"Cancelar"}),r.jsx(i.Button,{onClick:x,disabled:a||c,children:a?"Salvando...":"Salvar"})]})]})},exports.ActionPlanPredecessorsTab=A,exports.ActionPlanProgressDialog=D,exports.ActionPlanProgressTab=E,exports.ActionPlanStatusBadge=N,exports.CLOSED_STATUSES=f,exports.DEFAULT_ACTION_TYPES=g,exports.PRIORITIES=j,exports.PROGRESS_ALLOWED_STATUSES=v,exports.STATUS_COLORS=u,exports.STATUS_LABELS=h,exports.STATUS_MAP=m,exports.STATUS_TEXT_COLORS=x,exports.formatTime=k,exports.formatTimeProgress=C,exports.getActionTypes=function(){return[{id:"immediate",label:c.t("ap_type_immediate")},{id:"corrective",label:c.t("ap_type_corrective")},{id:"preventive",label:c.t("ap_type_preventive")},{id:"improvement",label:c.t("ap_type_improvement")},{id:"standardization",label:c.t("ap_type_standardization")}]},exports.getPriorities=function(){return[{id:exports.ETaskPlanPriority.low,label:c.t("ap_priority_low"),color:"#4CAF50"},{id:exports.ETaskPlanPriority.medium,label:c.t("ap_priority_medium"),color:"#FF9800"},{id:exports.ETaskPlanPriority.high,label:c.t("ap_priority_high"),color:"#F44336"}]},exports.getProgressColor=w,exports.getStatusLabels=p,exports.useActionPlan=b,exports.useActionPlanProgress=P;
1
+ "use strict";var e=require("react/jsx-runtime"),s=require("forlogic-core"),t=require("lucide-react"),a=require("i18next"),n=require("react"),r=require("react-i18next"),i=(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))(i||{}),l=(e=>(e[e.low=0]="low",e[e.medium=1]="medium",e[e.high=2]="high",e))(l||{}),c=(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))(c||{}),d=(e=>(e[e.currentProgress=1]="currentProgress",e[e.cumulativeProgress=2]="cumulativeProgress",e))(d||{}),o=(e=>(e.uploading="uploading",e.waiting="waiting",e.done="done",e.error="error",e.canceled="canceled",e.duplicateItem="duplicateItem",e))(o||{});const m={[i.waitingStart]:"#D6D6D6",[i.running]:"#DAE9F4",[i.effectivenessCheck]:"#1B75BB29",[i.done]:"#DDEECA",[i.suspended]:"#FFF2D6",[i.canceled]:"#F4433629"},u={[i.waitingStart]:"#666666",[i.running]:"#1B75BB",[i.effectivenessCheck]:"#1B75BB",[i.done]:"#4CAF50",[i.suspended]:"#FF9800",[i.canceled]:"#F44336"},x={[i.waitingStart]:"waiting-start",[i.running]:"running",[i.effectivenessCheck]:"effectiveness-check",[i.done]:"done",[i.suspended]:"suspended",[i.canceled]:"canceled"};function p(){return{[i.waitingStart]:a.t("ap_status_waiting_start"),[i.running]:a.t("ap_status_running"),[i.effectivenessCheck]:a.t("ap_status_effectiveness_check"),[i.done]:a.t("ap_status_done"),[i.suspended]:a.t("ap_status_suspended"),[i.canceled]:a.t("ap_status_canceled")}}const h=new Proxy({},{get:(e,s)=>{if("symbol"==typeof s)return;return p()[s]}});const g=[{id:"immediate",label:"Imediata"},{id:"corrective",label:"Corretiva"},{id:"preventive",label:"Preventiva"},{id:"improvement",label:"Oportunidade de Melhoria"},{id:"standardization",label:"Padronização"}];const j=[{id:l.low,label:"Baixa",color:"#4CAF50"},{id:l.medium,label:"Média",color:"#FF9800"},{id:l.high,label:"Alta",color:"#F44336"}],f=[i.done,i.canceled],v=[i.waitingStart,i.running,i.effectivenessCheck,i.suspended];function b(e){const{actionPlan:s,isNew:t=!1,config:a,onSave:r,onCancel:i,onDelete:l,onChangeStatus:c}=e,[d,o]=n.useState({formData:s||{},isLoading:e.isLoading||!1,isSaving:!1,activeTab:"general",isFormDisabled:!1});n.useEffect(()=>{s&&o(e=>({...e,formData:s,isFormDisabled:a?.disableFields||f.includes(s.statusId)}))},[s,a?.disableFields]),n.useEffect(()=>{o(s=>({...s,isLoading:e.isLoading||!1}))},[e.isLoading]);const m=n.useCallback((e,s)=>{o(t=>({...t,formData:{...t.formData,[e]:s}}))},[]),u=n.useCallback(e=>{o(s=>({...s,activeTab:e}))},[]),x=n.useCallback(async()=>{if(r){o(e=>({...e,isSaving:!0}));try{await r(d.formData)}finally{o(e=>({...e,isSaving:!1}))}}},[r,d.formData]),p=n.useCallback(async e=>{if(c&&d.formData.id){o(e=>({...e,isLoading:!0}));try{await c(d.formData.id,e)}finally{o(e=>({...e,isLoading:!1}))}}},[c,d.formData.id]),h=n.useCallback(async()=>{if(l&&d.formData.id){o(e=>({...e,isLoading:!0}));try{await l(d.formData.id)}finally{o(e=>({...e,isLoading:!1}))}}},[l,d.formData.id]);return{formData:d.formData,isLoading:d.isLoading,isSaving:d.isSaving,activeTab:d.activeTab,isFormDisabled:d.isFormDisabled,updateField:m,setActiveTab:u,save:x,changeStatus:p,remove:h,cancel:i}}const N={[i.waitingStart]:{label:"",color:"#8B7355",icon:t.Clock},[i.running]:{label:"",color:"#2E7D5B",icon:t.Play},[i.effectivenessCheck]:{label:"",color:"#4A6FA5",icon:t.ShieldCheck},[i.done]:{label:"",color:"#3D7A40",icon:t.CheckCircle2},[i.suspended]:{label:"",color:"#6B7280",icon:t.Pause},[i.canceled]:{label:"",color:"#B44A4A",icon:t.X}};function y({status:t,labels:a,className:n,size:r,showIcon:i,variant:l}){const c=p(),d=N[t];if(!d)return null;const o=a?.[t]||c[t]||"";return e.jsx(s.StatusBadge,{label:o,color:d.color,icon:d.icon,size:r,showIcon:i,variant:l,className:n})}function C({formData:t,updateField:a,disabled:i=!1,users:l=[],places:c=[],actionTypes:d,causes:o=[],parentActions:m=[],config:u}){const{t:x}=r.useTranslation(),p=u?.requiredFields,h=d||g,f=e=>{if(u?.hiddenFields?.includes(e))return!1;if(u?.visibleFields&&u.visibleFields.length>0)return u.visibleFields.includes(e);const s=`${e}Visible`;return!p||!(s in p)||!1!==p[s]},v=e=>p?!!p[e]:"name"===e,b=n.useMemo(()=>{if(t.startDate&&t.endDate){const e=new Date(t.startDate),s=new Date(t.endDate).getTime()-e.getTime();return Math.max(0,Math.ceil(s/864e5))}return t.duration||0},[t.startDate,t.endDate,t.duration]);return e.jsxs("div",{className:"space-y-6 p-1",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{className:s.cn(v("name")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Nome"}),e.jsx(s.Input,{value:t.name||"",onChange:e=>a("name",e.target.value),maxLength:500,disabled:i,placeholder:x("ap_plan_name_placeholder")})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[f("responsibleWho")&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{className:s.cn(v("responsibleWho")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Responsável"}),e.jsxs(s.Select,{value:t.responsibleId||"",onValueChange:e=>a("responsibleId",e),disabled:i,children:[e.jsx(s.SelectTrigger,{children:e.jsx(s.SelectValue,{placeholder:x("ap_select_responsible")})}),e.jsx(s.SelectContent,{children:l.map(t=>e.jsx(s.SelectItem,{value:t.id,children:t.name},t.id))})]})]}),f("checkerWho")&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{className:s.cn(v("checkerWho")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Verificador"}),e.jsxs(s.Select,{value:t.checkerId||"",onValueChange:e=>a("checkerId",e),disabled:i,children:[e.jsx(s.SelectTrigger,{children:e.jsx(s.SelectValue,{placeholder:x("ap_select_checker")})}),e.jsx(s.SelectContent,{children:l.map(t=>e.jsx(s.SelectItem,{value:t.id,children:t.name},t.id))})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[f("place")&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{className:s.cn(v("place")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Local"}),e.jsxs(s.Select,{value:t.placeId||"",onValueChange:e=>a("placeId",e),disabled:i,children:[e.jsx(s.SelectTrigger,{children:e.jsx(s.SelectValue,{placeholder:x("ap_select_place")})}),e.jsx(s.SelectContent,{children:S(c).map(t=>e.jsx(s.SelectItem,{value:t.id,children:t.name},t.id))})]})]}),f("planType")&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{className:s.cn(v("planType")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Tipo de Ação"}),e.jsxs(s.Select,{value:t.typeId||"",onValueChange:e=>a("typeId",e),disabled:i,children:[e.jsx(s.SelectTrigger,{children:e.jsx(s.SelectValue,{placeholder:x("ap_select_type")})}),e.jsx(s.SelectContent,{children:h.map(t=>e.jsx(s.SelectItem,{value:t.id,children:t.label},t.id))})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[f("priority")&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{className:s.cn(v("priority")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Prioridade"}),e.jsxs(s.Select,{value:t.priorityType?.toString()||"",onValueChange:e=>a("priorityType",Number(e)),disabled:i,children:[e.jsx(s.SelectTrigger,{children:e.jsx(s.SelectValue,{placeholder:x("ap_select_priority")})}),e.jsx(s.SelectContent,{children:j.map(t=>e.jsx(s.SelectItem,{value:t.id.toString(),children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:t.color}}),t.label]})},t.id))})]})]}),m.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:x("ap_belongs_to")}),e.jsxs(s.Select,{value:t.parentId||"",onValueChange:e=>a("parentId",e),disabled:i,children:[e.jsx(s.SelectTrigger,{children:e.jsx(s.SelectValue,{placeholder:x("ap_select_parent")})}),e.jsx(s.SelectContent,{children:m.map(t=>e.jsx(s.SelectItem,{value:t.id,children:t.label},t.id))})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[f("startDate")&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{className:s.cn(v("startDate")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Data de Início"}),e.jsx(s.DatePicker,{date:t.startDate?new Date(t.startDate):void 0,onDateChange:e=>a("startDate",e||null),disabled:i,placeholder:x("ap_select_date")})]}),f("endDate")&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{className:s.cn(v("endDate")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Data de Término"}),e.jsx(s.DatePicker,{date:t.endDate?new Date(t.endDate):void 0,onDateChange:e=>a("endDate",e||null),disabled:i,placeholder:x("ap_select_date"),disabledDates:t.startDate?e=>e<new Date(t.startDate):void 0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:x("ap_duration_days")}),e.jsx(s.Input,{type:"number",value:b,disabled:!0,className:"bg-muted"})]})]}),f("estimatedCost")&&e.jsxs("div",{className:"space-y-2 max-w-xs",children:[e.jsx(s.Label,{className:s.cn(v("estimatedCost")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Custo Estimado"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"R$"}),e.jsx(s.Input,{type:"number",min:0,step:.01,value:t.estimatedCost||"",onChange:e=>a("estimatedCost",Number(e.target.value)),disabled:i,className:"pl-9",placeholder:"0,00"})]})]}),f("cause")&&o.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:"Causa"}),e.jsxs(s.Select,{value:t.causeId||"",onValueChange:e=>a("causeId",e),disabled:i,children:[e.jsx(s.SelectTrigger,{children:e.jsx(s.SelectValue,{placeholder:x("ap_select_cause")})}),e.jsx(s.SelectContent,{children:o.map(t=>e.jsx(s.SelectItem,{value:t.id,children:t.label},t.id))})]})]}),f("description")&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{className:s.cn(v("description")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Descrição"}),e.jsx(s.Textarea,{value:t.description||"",onChange:e=>a("description",e.target.value),maxLength:4e3,disabled:i,rows:4,placeholder:x("ap_description_placeholder")})]}),f("justification")&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{className:s.cn(v("justification")&&"after:content-['*'] after:ml-0.5 after:text-destructive"),children:"Justificativa"}),e.jsx(s.Textarea,{value:t.justification||"",onChange:e=>a("justification",e.target.value),maxLength:4e3,disabled:i,rows:4,placeholder:x("ap_justification_placeholder")})]})]})}function S(e,s=0){const t=[];for(const a of e)t.push({...a,depth:s}),a.children?.length&&t.push(...S(a.children,s+1));return t}function w(e){const{progress:s,onReportProgress:t,onEditProgress:a,onDeleteProgress:r}=e,[i,l]=n.useState(!1),[c,d]=n.useState(null),o=!!s&&v.includes(s.status),m=n.useCallback(async e=>{if(t&&s){l(!0);try{const a=100===e.percentProgress;await t({id:s.id,...e,conclude:a})}finally{l(!1)}}},[t,s]),u=n.useCallback(async e=>{if(a){l(!0);try{await a(e)}finally{l(!1),d(null)}}},[a]),x=n.useCallback(async e=>{if(r){l(!0);try{await r(e)}finally{l(!1)}}},[r]);return{progress:s,canReportProgress:o,isSubmitting:i,editingReport:c,setEditingReport:d,reportProgress:m,editProgress:u,deleteProgress:x}}function D(e){if(!e)return"";let s=(e||"").trim();if(!s)return"00:00";if(s.includes(":")){const e=s.split(":");if(e.length>=2){const s=e[0].replace(/\D/g,""),t=e[1].replace(/\D/g,"");let a=parseInt(s)||0,n=parseInt(t)||0;return a+=Math.floor(n/60),n%=60,`${a.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`}}if(s=s.replace(/\D/g,""),!s)return"00:00";let t=0,a=0;return 4===s.length?(t=parseInt(s.substring(0,2))||0,a=parseInt(s.substring(2,4))||0,t+=Math.floor(a/60),a%=60):(t=parseInt(s)||0,a=0),`${t.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`}function T(e){if(null==e)return"00:00";const s=String(e).replace(/\D/g,"");if(s.length<3){let e=parseInt(s)||0;const t=Math.floor(e/60);return e%=60,`${t.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`}{const e=s.slice(-2),t=s.slice(0,-2);let a=parseInt(t)||0,n=parseInt(e)||0;return a+=Math.floor(n/60),n%=60,`${a.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`}}function _(e){return 100===e?"#84c148":e>0?"#1b75bb":""}function P({open:t,onOpenChange:a,report:i,onSave:l,isSubmitting:c=!1}){const{t:d}=r.useTranslation(),[o,m]=n.useState(i?.percentProgress||0),[u,x]=n.useState(i?.timeProgress||""),[p,h]=n.useState(i?.comments||""),g=o!==(i?.percentProgress??0)||u!==(i?.timeProgress??"")||p!==(i?.comments??"");n.useEffect(()=>{i&&(m(i.percentProgress),x(i.timeProgress||""),h(i.comments||""))},[i]);return e.jsx(s.Dialog,{open:t,onOpenChange:a,children:e.jsxs(s.DialogContent,{className:"sm:max-w-md",variant:"form",isDirty:g,children:[e.jsx(s.DialogHeader,{children:e.jsx(s.DialogTitle,{children:d("ap_edit_progress")})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:d("ap_progress_percent")}),e.jsx(s.Input,{type:"number",min:0,max:100,value:o,onChange:e=>m(Number(e.target.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:d("ap_time_spent")}),e.jsx(s.Input,{value:u,onChange:e=>x(e.target.value),onBlur:()=>x(D(u)||""),placeholder:"00:00"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:d("ap_comments")}),e.jsx(s.Textarea,{value:p,onChange:e=>h(e.target.value),rows:3,maxLength:4e3})]})]}),e.jsxs(s.DialogFooter,{children:[e.jsx(s.Button,{variant:"outline",onClick:()=>a(!1),disabled:c,children:"Cancelar"}),e.jsx(s.Button,{onClick:()=>{i&&l({...i,percentProgress:o,timeProgress:D(u)||"00:00",comments:p})},disabled:c,children:c?"Salvando...":"Salvar"})]})]})})}function k(t){const{t:a}=r.useTranslation(),{progress:i,canReportProgress:l,isSubmitting:c,editingReport:d,setEditingReport:o,reportProgress:m,editProgress:u,deleteProgress:x}=w(t),[p,h]=n.useState(""),[g,j]=n.useState(""),[f,v]=n.useState("");if(!i)return e.jsx("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:"Sem dados de progresso disponíveis"});const b=_(i.percentProgress),N=!p,y=!p&&!g&&!f;return e.jsxs("div",{className:"space-y-6 p-1",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"font-medium",children:a("ap_overall_progress")}),e.jsxs("span",{className:"font-semibold",style:{color:b||void 0},children:[i.percentProgress,"%"]})]}),e.jsx(s.Progress,{value:i.percentProgress,className:"h-3"}),i.timeProgress&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Tempo total: ",T(i.timeProgress)]})]}),l&&e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-4",children:[e.jsx("h4",{className:"text-sm font-medium",children:a("ap_report_progress")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:a("ap_progress_percent")}),e.jsx(s.Input,{type:"number",min:0,max:100,value:p,onChange:e=>h(e.target.value),placeholder:"0"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:a("ap_time_spent")}),e.jsx(s.Input,{value:g,onChange:e=>j(e.target.value),onBlur:()=>j(D(g)||""),placeholder:"00:00"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:a("ap_comments")}),e.jsx(s.Textarea,{value:f,onChange:e=>v(e.target.value),rows:3,maxLength:4e3,placeholder:a("ap_progress_comment_placeholder")})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(s.Button,{variant:"outline",size:"sm",onClick:()=>{h(""),j(""),v("")},disabled:y||c,children:"Limpar"}),e.jsx(s.Button,{size:"sm",onClick:async()=>{const e=Number(p);(e||0===e)&&(await m({percentProgress:e,timeProgress:D(g)||"00:00",comments:f}),h(""),j(""),v(""))},disabled:N||c,children:c?"Reportando...":"Reportar"})]})]}),i.reports.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"text-sm font-medium",children:a("ap_reports_history")}),e.jsx("div",{className:"space-y-2",children:i.reports.map(s=>e.jsx(A,{report:s,onEdit:()=>o(s),onDelete:()=>x(s.id),disabled:!l},s.id))})]}),e.jsx(P,{open:!!d,onOpenChange:e=>!e&&o(null),report:d,onSave:u,isSubmitting:c})]})}function A({report:t,onEdit:n,onDelete:r,disabled:i}){const l=t.date?new Date(t.date):null,c=_(t.percentProgress);return e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-card p-3",children:[e.jsx("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()||"?"}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"font-medium truncate",children:t.userName}),l&&e.jsx("span",{className:"text-xs text-muted-foreground",children:l.toLocaleDateString("pt-BR")})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[e.jsxs("span",{style:{color:c||void 0},className:"font-semibold",children:[t.percentProgress,"%"]}),t.timeProgress&&e.jsxs("span",{children:["Tempo: ",T(t.timeProgress)]})]}),t.comments&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t.comments})]}),!i&&e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.ActionButton,{})}),e.jsxs(s.DropdownMenuContent,{align:"end",children:[e.jsx(s.DropdownMenuItem,{onClick:n,children:a.t("edit")}),e.jsx(s.DropdownMenuItem,{className:"text-destructive",onClick:r,children:a.t("ap_delete")})]})]})]})}function I({predecessors:a=[],availablePredecessors:i=[],onAdd:l,onRemove:c,disabled:d=!1}){const{t:o}=r.useTranslation(),[m,u]=n.useState(""),x=i.filter(e=>!a.some(s=>s.predecessorId===e.id));return e.jsxs("div",{className:"space-y-6 p-1",children:[!d&&x.length>0&&e.jsxs("div",{className:"flex items-end gap-3",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(s.Label,{children:o("ap_add_predecessor")}),e.jsxs(s.Select,{value:m,onValueChange:u,children:[e.jsx(s.SelectTrigger,{children:e.jsx(s.SelectValue,{placeholder:o("ap_select_action")})}),e.jsx(s.SelectContent,{children:x.map(t=>e.jsx(s.SelectItem,{value:t.id,children:t.label},t.id))})]})]}),e.jsxs(s.Button,{size:"sm",onClick:()=>{m&&l&&(l(m),u(""))},disabled:!m,children:[e.jsx(t.Plus,{className:"h-4 w-4 mr-1"}),"Adicionar"]})]}),a.length>0?e.jsx("div",{className:"space-y-2",children:a.map(t=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-card p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[t.predecessorCode&&e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:t.predecessorCode}),e.jsx("span",{className:"text-sm font-medium",children:t.predecessorName}),null!=t.predecessorStatus&&e.jsx(y,{status:t.predecessorStatus})]}),!d&&c&&e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.ActionButton,{})}),e.jsx(s.DropdownMenuContent,{align:"end",children:e.jsx(s.DropdownMenuItem,{className:"text-destructive",onClick:()=>c(t.predecessorId),children:"Remover"})})]})]},t.id))}):e.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"Nenhum predecessor adicionado"})]})}function L({costs:a=[],onAdd:i,onEdit:l,onDelete:c,disabled:d=!1}){const{t:o}=r.useTranslation(),[m,u]=n.useState(""),[x,p]=n.useState(""),h=a.reduce((e,s)=>e+(s.value||0),0);return e.jsxs("div",{className:"space-y-6 p-1",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4 flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:o("ap_total_cost")}),e.jsxs("span",{className:"text-lg font-semibold text-foreground",children:["R$ ",h.toLocaleString("pt-BR",{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),!d&&i&&e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-4",children:[e.jsx("h4",{className:"text-sm font-medium",children:o("ap_add_cost")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:"Descrição"}),e.jsx(s.Input,{value:m,onChange:e=>u(e.target.value),placeholder:o("ap_cost_description")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:"Valor (R$)"}),e.jsx(s.Input,{type:"number",min:0,step:.01,value:x,onChange:e=>p(e.target.value),placeholder:"0,00"})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(s.Button,{size:"sm",onClick:()=>{m&&x&&i&&(i({description:m,value:Number(x),date:(new Date).toISOString()}),u(""),p(""))},disabled:!m||!x,children:[e.jsx(t.Plus,{className:"h-4 w-4 mr-1"}),"Adicionar"]})})]}),a.length>0?e.jsx("div",{className:"space-y-2",children:a.map(t=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-card p-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:t.description}),t.date&&e.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(t.date).toLocaleDateString("pt-BR")})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm font-semibold whitespace-nowrap",children:["R$ ",t.value.toLocaleString("pt-BR",{minimumFractionDigits:2,maximumFractionDigits:2})]}),!d&&(l||c)&&e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.ActionButton,{})}),e.jsxs(s.DropdownMenuContent,{align:"end",children:[l&&e.jsx(s.DropdownMenuItem,{onClick:()=>l(t),children:o("edit")}),c&&e.jsx(s.DropdownMenuItem,{className:"text-destructive",onClick:()=>c(t.id),children:o("ap_delete")})]})]})]})]},t.id))}):e.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"Nenhum custo registrado"})]})}function B({comments:a=[],currentUserId:i,onAdd:l,onEdit:c,onDelete:d,disabled:o=!1,maxLength:m=4e3}){const{t:u}=r.useTranslation(),[x,p]=n.useState(""),[h,g]=n.useState(!1),[j,f]=n.useState(null),[v,b]=n.useState(""),N=()=>{f(null),b("")};return e.jsxs("div",{className:"space-y-6 p-1",children:[!o&&l&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(s.Textarea,{value:x,onChange:e=>p(e.target.value),placeholder:u("ap_add_comment_placeholder"),maxLength:m,rows:3}),e.jsxs("div",{className:"flex items-center justify-between",children:[m&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[x.length,"/",m]}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsx(s.Button,{variant:"outline",size:"sm",onClick:()=>p(""),disabled:!x||h,children:"Limpar"}),e.jsx(s.Button,{size:"sm",onClick:async()=>{if(x.trim()&&l){g(!0);try{await l(x),p("")}finally{g(!1)}}},disabled:!x.trim()||h,children:h?"Enviando...":"Comentar"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[a.length>0?e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"text-sm font-medium",children:u("ap_comments")}),e.jsx(s.Badge,{variant:"info",className:"text-[10px] px-1.5 py-0",children:a.length})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(t.MessageSquare,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"Nenhum comentário adicionado"})]}),a.map(t=>e.jsxs("div",{className:"flex gap-3 rounded-lg border bg-card p-3",children:[e.jsx("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.jsx("img",{src:t.userPhotoUrl,alt:t.userName,className:"h-full w-full object-cover"}):t.userName?.charAt(0)?.toUpperCase()||"?"}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"font-medium truncate",children:t.userName}),t.userEmail&&e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.userEmail}),e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:M(t.dateEdited||t.dateCreation)}),t.dateEdited&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"editado"})]}),j===t.id?e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Textarea,{value:v,onChange:e=>b(e.target.value),maxLength:m,rows:3}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(s.Button,{variant:"outline",size:"sm",onClick:N,disabled:h,children:"Cancelar"}),e.jsx(s.Button,{size:"sm",onClick:()=>(async e=>{if(v.trim()&&c){g(!0);try{await c({...e,text:v,stringText:v}),f(null),b("")}finally{g(!1)}}})(t),disabled:!v.trim()||h,children:h?"Salvando...":"Salvar"})]})]}):e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:t.stringText||t.text})]}),!o&&i===t.userId&&j!==t.id&&e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.ActionButton,{})}),e.jsxs(s.DropdownMenuContent,{align:"end",children:[c&&e.jsx(s.DropdownMenuItem,{onClick:()=>(e=>{f(e.id),b(e.stringText||e.text)})(t),children:u("edit")}),d&&e.jsx(s.DropdownMenuItem,{className:"text-destructive",onClick:()=>(async e=>{if(d){g(!0);try{await d(e)}finally{g(!1)}}})(t.id),children:"Excluir"})]})]})]},t.id))]})]})}function M(e){const{t:s}=r.useTranslation();if(!e)return"";const t=new Date(e);return`${t.toLocaleDateString("pt-BR")} ${t.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}`}function E({history:s=[],isLoading:a=!1}){const{t:n}=r.useTranslation();return a?e.jsx("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:"Carregando histórico..."}):0===s.length?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(t.Clock,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:n("ap_no_history")})]}):e.jsx("div",{className:"p-1",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-4 top-0 bottom-0 w-px bg-border"}),e.jsx("div",{className:"space-y-0",children:s.map((s,a)=>e.jsxs("div",{className:"relative flex gap-4 pb-6 last:pb-0",children:[e.jsx("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:s.icon?e.jsx("span",{className:"text-xs text-primary",children:s.icon}):e.jsx("div",{className:"h-2 w-2 rounded-full bg-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0 rounded-lg border bg-card p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium",children:s.translateEvent||s.eventName}),s.eventDescription&&e.jsx("p",{className:"text-xs text-muted-foreground",children:s.eventDescription})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("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:s.userPhotoUrl?e.jsx("img",{src:s.userPhotoUrl,alt:s.userName,className:"h-full w-full object-cover"}):s.userName?.charAt(0)?.toUpperCase()||"?"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"text-xs font-medium truncate block",children:s.userName}),s.userEmail&&e.jsx("span",{className:"text-[10px] text-muted-foreground truncate block",children:s.userEmail})]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(t.Calendar,{className:"h-3 w-3"}),e.jsx("span",{children:F(s.date)})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(t.Clock,{className:"h-3 w-3"}),e.jsx("span",{children:R(s.date)})]}),s.isMobileRequest&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(t.Smartphone,{className:"h-3 w-3"}),e.jsx("span",{children:n("ap_via_app")})]})]})]})]},s.id))})]})})}function F(e){const{t:s}=r.useTranslation();return new Date(e).toLocaleDateString("pt-BR")}function R(e){const{t:s}=r.useTranslation();return new Date(e).toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}function z({attachments:a=[],onUpload:i,onDelete:l,onRename:c,onDownload:d,onView:m,disabled:u=!1}){const{t:x}=r.useTranslation(),p=n.useRef(null),[h,g]=n.useState(null),[j,f]=n.useState(""),v=async e=>{j.trim()&&c&&(await c(e.id,j),g(null),f(""))},b=()=>{g(null),f("")};return e.jsxs("div",{className:"space-y-4 p-1",children:[!u&&i&&e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:p,type:"file",multiple:!0,className:"hidden",onChange:e=>{const s=e.target.files;if(s&&i){for(let e=0;e<s.length;e++){const t=s.item(e);t&&i(t)}p.current&&(p.current.value="")}}}),e.jsxs(s.Button,{size:"sm",onClick:()=>p.current?.click(),children:[e.jsx(t.Plus,{className:"h-4 w-4 mr-1"}),"Adicionar anexo"]})]}),a.length>0?e.jsx("div",{className:"space-y-2",children:a.map(t=>e.jsxs("div",{className:s.cn("flex items-center gap-3 rounded-lg border bg-card p-3",t.status===o.error&&"border-destructive/50 bg-destructive/5",t.status===o.canceled&&"opacity-50"),children:[e.jsx("div",{className:"flex-shrink-0 h-9 w-9 rounded bg-muted flex items-center justify-center",children:e.jsx("span",{className:"text-[10px] font-bold uppercase text-muted-foreground",children:t.extension.replace(".","").substring(0,4)})}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[h===t.id?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{className:"flex-1 text-sm border rounded px-2 py-1 bg-background",value:j,onChange:e=>f(e.target.value),onKeyDown:e=>{"Enter"===e.key&&v(t),"Escape"===e.key&&b()},autoFocus:!0}),e.jsx(s.Button,{size:"sm",variant:"outline",onClick:b,children:x("cancel")}),e.jsx(s.Button,{size:"sm",onClick:()=>v(t),children:x("save")})]}):e.jsx("button",{type:"button",className:"text-sm font-medium truncate block text-left hover:underline cursor-pointer",onClick:()=>m?.(t.id),children:t.name}),(t.status===o.uploading||t.status===o.waiting)&&e.jsx(s.Progress,{value:t.progress||0,className:"h-1.5"}),t.status===o.error&&e.jsx("p",{className:"text-xs text-destructive",children:"Erro ao enviar arquivo"}),t.status===o.duplicateItem&&e.jsx("p",{className:"text-xs text-warning",children:"Arquivo duplicado"}),t.status===o.canceled&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Upload cancelado"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[t.status===o.done&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:V(t.size)}),e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.ActionButton,{})}),e.jsxs(s.DropdownMenuContent,{align:"end",children:[c&&!u&&e.jsx(s.DropdownMenuItem,{onClick:()=>(e=>{const s=e.name.replace(e.extension,"");g(e.id),f(s)})(t),children:"Renomear"}),m&&e.jsx(s.DropdownMenuItem,{onClick:()=>m(t.id),children:"Visualizar"}),d&&e.jsx(s.DropdownMenuItem,{onClick:()=>d(t.id),children:"Download"}),l&&!u&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuSeparator,{}),e.jsx(s.DropdownMenuItem,{className:"text-destructive",onClick:()=>l(t.id),children:"Excluir"})]})]})]})]}),t.status===o.uploading&&e.jsx(s.Button,{variant:"outline",size:"sm",onClick:()=>l?.(t.id),children:"Cancelar"})]})]},t.id))}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(t.Paperclip,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"Nenhum anexo adicionado"})]})]})}function V(e){const{t:s}=r.useTranslation();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]}`}exports.ActionPlanAttachmentsTab=z,exports.ActionPlanCommentsTab=B,exports.ActionPlanCostTab=L,exports.ActionPlanGeneralTab=C,exports.ActionPlanHistoryTab=E,exports.ActionPlanPage=function(a){const{formData:n,isLoading:l,isSaving:c,activeTab:d,isFormDisabled:o,updateField:m,setActiveTab:u,save:x,changeStatus:p,remove:g,cancel:j}=b(a),{t:f}=r.useTranslation(),{isNew:v=!1,config:N,users:S,places:w,actionTypes:D,causes:T,parentActions:_,progress:P,predecessors:A,availablePredecessors:M,costs:F,comments:R,history:V,attachments:U,attachmentsSlot:$,commentsSlot:O,historySlot:q,onAddPredecessor:H,onRemovePredecessor:W,onAddCost:G,onEditCost:K,onDeleteCost:X,onAddComment:J,onEditComment:Y,onDeleteComment:Q,onUploadAttachment:Z,onDeleteAttachment:ee,onRenameAttachment:se,onDownloadAttachment:te,onViewAttachment:ae}=a;if(l&&!n.id)return e.jsx(s.LoadingState,{isLoading:!0,children:e.jsx("div",{})});const ne=function(e){const{t:s}=r.useTranslation();if(!e)return[];return{[i.waitingStart]:[i.running,i.suspended,i.canceled],[i.running]:[i.effectivenessCheck,i.done,i.suspended,i.canceled],[i.effectivenessCheck]:[i.running,i.done,i.suspended,i.canceled],[i.done]:[i.running],[i.suspended]:[i.running,i.canceled],[i.canceled]:[i.waitingStart]}[e]||[]}(n.statusId);return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center justify-between border-b bg-card px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[j&&e.jsx(s.Button,{variant:"ghost",size:"icon",onClick:j,children:e.jsx(t.ArrowLeft,{className:"h-4 w-4"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-lg font-semibold",children:v?f("ap_new_action"):n.name||f("ap_action_plan")}),!v&&n.statusId&&e.jsx(y,{status:n.statusId})]}),n.code&&e.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:n.code})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!v&&ne.length>0&&!o&&e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"outline",size:"sm",children:"Alterar Status"})}),e.jsx(s.DropdownMenuContent,{align:"end",children:ne.map(t=>e.jsx(s.DropdownMenuItem,{onClick:()=>p(t),children:h[t]},t))})]}),!v&&a.onDelete&&e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"ghost",size:"icon",children:e.jsx(t.MoreVertical,{className:"h-4 w-4"})})}),e.jsx(s.DropdownMenuContent,{align:"end",children:e.jsx(s.DropdownMenuItem,{className:"text-destructive",onClick:g,children:"Excluir"})})]})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:e.jsx("div",{className:"max-w-4xl mx-auto px-6 py-6",children:e.jsxs(s.Tabs,{value:d,onValueChange:u,children:[e.jsxs(s.TabsList,{className:"mb-6",children:[e.jsx(s.TabsTrigger,{value:"general",children:"Geral"}),!v&&e.jsx(s.TabsTrigger,{value:"progress",children:"Progresso"}),!v&&N?.enablePredecessors&&e.jsx(s.TabsTrigger,{value:"predecessors",children:f("ap_predecessors")}),!v&&N?.enableCosts&&e.jsx(s.TabsTrigger,{value:"costs",children:"Custos"}),!v&&N?.enableAttachments&&e.jsx(s.TabsTrigger,{value:"attachments",children:f("ap_attachments")}),!v&&N?.enableComments&&e.jsx(s.TabsTrigger,{value:"comments",children:f("ap_comments")}),!v&&N?.enableHistory&&e.jsx(s.TabsTrigger,{value:"history",children:"Histórico"})]}),e.jsx(s.TabsContent,{value:"general",children:e.jsx(C,{formData:n,updateField:m,disabled:o,users:S,places:w,actionTypes:D,causes:T,parentActions:_,config:N})}),!v&&e.jsx(s.TabsContent,{value:"progress",children:e.jsx(k,{...a})}),!v&&N?.enablePredecessors&&e.jsx(s.TabsContent,{value:"predecessors",children:e.jsx(I,{predecessors:A,availablePredecessors:M,onAdd:H,onRemove:W,disabled:o})}),!v&&N?.enableCosts&&e.jsx(s.TabsContent,{value:"costs",children:e.jsx(L,{costs:F,onAdd:G,onEdit:K,onDelete:X,disabled:o})}),!v&&N?.enableAttachments&&e.jsx(s.TabsContent,{value:"attachments",children:$||e.jsx(z,{attachments:U,onUpload:Z,onDelete:ee,onRename:se,onDownload:te,onView:ae,disabled:o})}),!v&&N?.enableComments&&e.jsx(s.TabsContent,{value:"comments",children:O||e.jsx(B,{comments:R,onAdd:J,onEdit:Y,onDelete:Q,disabled:o})}),!v&&N?.enableHistory&&e.jsx(s.TabsContent,{value:"history",children:q||e.jsx(E,{history:V})})]})})}),e.jsxs("div",{className:"flex items-center justify-end gap-3 border-t bg-card px-6 py-4",children:[j&&e.jsx(s.Button,{variant:"outline",onClick:j,disabled:c,children:"Cancelar"}),e.jsx(s.Button,{onClick:x,disabled:c||o,children:c?"Salvando...":"Salvar"})]})]})},exports.ActionPlanPredecessorsTab=I,exports.ActionPlanProgressDialog=P,exports.ActionPlanProgressTab=k,exports.ActionPlanStatusBadge=y,exports.CLOSED_STATUSES=f,exports.DEFAULT_ACTION_TYPES=g,exports.EAttachmentItemStatus=o,exports.ETaskPlanAssociationType=c,exports.ETaskPlanPriority=l,exports.ETaskPlanStatus=i,exports.ETaskPlanTypeProgress=d,exports.PRIORITIES=j,exports.PROGRESS_ALLOWED_STATUSES=v,exports.STATUS_COLORS=m,exports.STATUS_LABELS=h,exports.STATUS_MAP=x,exports.STATUS_TEXT_COLORS=u,exports.formatTime=T,exports.formatTimeProgress=D,exports.getActionTypes=function(){return[{id:"immediate",label:a.t("ap_type_immediate")},{id:"corrective",label:a.t("ap_type_corrective")},{id:"preventive",label:a.t("ap_type_preventive")},{id:"improvement",label:a.t("ap_type_improvement")},{id:"standardization",label:a.t("ap_type_standardization")}]},exports.getPriorities=function(){return[{id:l.low,label:a.t("ap_priority_low"),color:"#4CAF50"},{id:l.medium,label:a.t("ap_priority_medium"),color:"#FF9800"},{id:l.high,label:a.t("ap_priority_high"),color:"#F44336"}]},exports.getProgressColor=_,exports.getStatusLabels=p,exports.useActionPlan=b,exports.useActionPlanProgress=w;