forlogic-core 2.3.2 → 2.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/action-plans/auth/services/AuthService.d.ts +19 -0
  2. package/dist/action-plans/exports/ui.d.ts +2 -0
  3. package/dist/action-plans/i18n/LanguageBootstrap.d.ts +14 -0
  4. package/dist/action-plans/i18n/index.d.ts +1 -0
  5. package/dist/action-plans/index.d.ts +14 -103
  6. package/dist/action-plans/index.esm.js +1 -1
  7. package/dist/action-plans/index.js +1 -1
  8. package/dist/action-plans/types.d.ts +361 -551
  9. package/dist/audit-trail/auth/services/AuthService.d.ts +19 -0
  10. package/dist/audit-trail/exports/ui.d.ts +2 -0
  11. package/dist/audit-trail/i18n/LanguageBootstrap.d.ts +14 -0
  12. package/dist/audit-trail/i18n/index.d.ts +1 -0
  13. package/dist/audit-trail/index.d.ts +8 -103
  14. package/dist/audit-trail/types.d.ts +173 -567
  15. package/dist/auth/services/AuthService.d.ts +19 -0
  16. package/dist/auth/services/TokenService.d.ts +1 -0
  17. package/dist/auth/utils/authDebug.d.ts +18 -0
  18. package/dist/components/ui/combobox.d.ts +2 -1
  19. package/dist/exports/ui.d.ts +2 -0
  20. package/dist/i18n/LanguageBootstrap.d.ts +14 -0
  21. package/dist/i18n/index.d.ts +1 -0
  22. package/dist/index.css +1 -1
  23. package/dist/index.css.map +1 -1
  24. package/dist/index.d.ts +1 -0
  25. package/dist/index.esm.js +1 -1
  26. package/dist/index.js +1 -1
  27. package/dist/leadership/auth/services/AuthService.d.ts +19 -0
  28. package/dist/leadership/exports/ui.d.ts +2 -0
  29. package/dist/leadership/i18n/LanguageBootstrap.d.ts +14 -0
  30. package/dist/leadership/i18n/index.d.ts +1 -0
  31. package/dist/leadership/index.d.ts +12 -103
  32. package/dist/leadership/types.d.ts +13 -593
  33. package/dist/places/auth/services/AuthService.d.ts +19 -0
  34. package/dist/places/exports/ui.d.ts +2 -0
  35. package/dist/places/i18n/LanguageBootstrap.d.ts +14 -0
  36. package/dist/places/i18n/index.d.ts +1 -0
  37. package/dist/places/index.d.ts +8 -104
  38. package/dist/places/types.d.ts +6 -599
  39. package/dist/qualiex/hooks/useQualiexReady.d.ts +15 -0
  40. package/dist/qualiex/services/qualiexApiService.d.ts +18 -0
  41. package/dist/sign/auth/services/AuthService.d.ts +19 -0
  42. package/dist/sign/exports/ui.d.ts +2 -0
  43. package/dist/sign/i18n/LanguageBootstrap.d.ts +14 -0
  44. package/dist/sign/i18n/index.d.ts +1 -0
  45. package/dist/sign/index.d.ts +8 -104
  46. package/dist/sign/index.esm.js +1 -1
  47. package/dist/sign/index.js +1 -1
  48. package/dist/sign/types.d.ts +46 -596
  49. package/dist/updates/components/UpdatesBar.d.ts +10 -0
  50. package/dist/updates/components/UpdatesDialog.d.ts +10 -0
  51. package/dist/updates/components/UserUpdatesViewer.d.ts +5 -0
  52. package/dist/updates/hooks/useUserUpdates.d.ts +5 -0
  53. package/dist/updates/index.d.ts +9 -0
  54. package/dist/updates/services/userUpdatesApi.d.ts +3 -0
  55. package/dist/updates/types.d.ts +24 -0
  56. package/dist/updates/utils/dismissedStore.d.ts +4 -0
  57. package/package.json +2 -2
@@ -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;