PageSourceSearch

https://dgac.gob.gt/assets/ProjectToDo-e7XgCvxe.js

js dgac.gob.gt collected 2026-09-24 23:02:43 UTC 53,849 bytes, 1 lines download raw bytes

1import{j as e,ay as Mt,b5 as Ut,cj as ks,ab as zt,M as Lt,r as j,b2 as G,bQ as $t,aA as Rs,Y as Bs,F as Vs,bb as Ws,cX as Hs,ao as qs,cY as Gs,cV as Ks,cZ as Ot,T as Qs,c_ as Rt,bN as Bt,d as Vt,m as Xs,bH as Wt,h as Ht,bu as qt,bt as Gt,b7 as Kt,bV as Qt,bj as Re,U as Ue,a9 as ze,X as Be,bZ as Je,as as Ye,bg as Js,a as Xt,Z as As,L as Ve,o as Ms,az as Jt,bF as Yt}from"./ui-vendor-Nh77zFHh.js";import{A as E,o as We,w as Zt,x as ea,M as Ze,a1 as es,O as ss,P as ts,C as ye,D as Ys,F as we,e as W,B as C,t as Zs,bu as _,h as w,aX as sa,bm as ta,s as aa,y as ra,u as na,c as la,d as oa,v as k,I as Ee,S as He,i as qe,j as Ge,k as Ke,l as le,f as B,g as V,Q as ia,L as X,a3 as ca,R as da,aR as ua,ag as Us,G as ma,H as xa,J as ha,K as zs,an as pa,ao as ga,ap as fa,aq as ja}from"./index-BCakBLyb.js";import{T as ba}from"./TourButton-DHeq7_zB.js";import{b as va,a as Na,K as ya}from"./KanbanDnd-C444d7lb.js";import{T as wa}from"./textarea-D6pIDA_a.js";import{C as ce,d as de,a as Ca,b as Ia,c as Sa}from"./card-IGpSy_k-.js";import{T as Ta,a as _a,b as ke}from"./tabs-cH_BY3xJ.js";import{T as Fa,a as Pa,b as Qe,c as oe,d as Da,e as J}from"./table-Bqba16zq.js";import{P as Ls}from"./projectService-BuOVXAFE.js";import{e as Xe}from"./offlineHelper-93YyoVkQ.js";import{t as Ea}from"./todoStatusService-DBscRYhK.js";import{u as ka}from"./index-BgqyOkW0.js";import{F as et}from"./FileViewer-BOjOE3Z6.js";import{i as Ce}from"./isToday-sMmidBXo.js";import{i as as}from"./isPast-C-3IyCHi.js";import{u as Aa,S as Ma}from"./useRealtimeQuery-C5TKHl3O.js";import{M as Ua,a as za,b as La,c as $a,d as Ae,e as Oa}from"./mobile-data-list-BeXO9sTp.js";import{P as je,a as be,b as ve}from"./popover-DJHTinoQ.js";import{C as Me}from"./calendar-4Z4AZZ6D.js";import{u as Ra}from"./userService-Dj3A-iRm.js";import{u as Ba}from"./useTableFilterPersistence-ChrkWk-T.js";import{d as Va}from"./differenceInDays-avd41rT0.js";import{d as Wa,a as Ha}from"./react-vendor-B-TOzi2X.js";import"./radix-vendor-8V-X-v15.js";import"./chart-vendor-BHC9f-XT.js";import"./table-vendor-CmSNR_WU.js";import"./duplicateGuardService-BYo_d16M.js";import"./UniversalDocumentViewer-DBuAh6WR.js";import"./xlsx-D_0l8YDs.js";import"./pdf.worker.min-CSQ7O7oQ.js";import"./isSameDay-BlZNyPtT.js";import"./swipeable-card-ogpDVAcd.js";import"./addMonths-BqrwOp2K.js";import"./addWeeks-D6Xhasud.js";import"./normalizeInterval-BP9mDrfM.js";import"./endOfWeek-DbvE6QsU.js";import"./endOfYear-DuokerOX.js";import"./getYear-D_4B_AxS.js";import"./isBefore-M4Mvi6qe.js";import"./isSameMonth-B5Qb1w1q.js";import"./startOfMonth-DcSdy4ch.js";const qa=[{element:'[data-tour="todo-header"]',popover:{title:"✅ Tareas del Proyecto",description:"Gestiona las tareas pendientes de este proyecto. Asigna, prioriza y da seguimiento al progreso.",side:"bottom",align:"start"}},{element:'[data-tour="todo-search"]',popover:{title:"🔍 Búsqueda",description:"Encuentra tareas por título o descripción.",side:"bottom",align:"start"}},{element:'[data-tour="todo-filters"]',popover:{title:"🎯 Filtros",description:"Filtra tareas por estado: Pendiente, En Progreso o Completada.",side:"bottom",align:"start"}},{element:'[data-tour="todo-create"]',popover:{title:"➕ Nueva Tarea",description:"Crea tareas con título, descripción, prioridad y fecha límite.",side:"left",align:"start"}},{element:'[data-tour="todo-list"]',popover:{title:"📋 Lista de Tareas",description:"Visualiza todas las tareas con indicadores de estado y prioridad. Las tareas atrasadas se destacan.",side:"top",align:"center"}},{element:'[data-tour="todo-status"]',popover:{title:"🔄 Cambiar Estado",description:"Haz clic en el checkbox o usa el menú de acciones para cambiar el estado de una tarea.",side:"left",align:"start"}}],ue=Zt.create({baseURL:E.BASE_URL,timeout:E.TIMEOUT});ue.interceptors.request.use(a=>{const i=localStorage.getItem(E.STORAGE_KEYS.AUTH_TOKEN)||E.AUTH_TOKEN;return i&&(a.headers.Authorization=`Bearer ${i}`),a.headers["Cache-Control"]="no-store",a.headers.Pragma="no-cache",a.headers.Expires="0",(a.method||"get").toLowerCase()==="get"&&(a.params={...a.params||{},_ts:Date.now()}),a},a=>Promise.reject(a));ue.interceptors.response.use(a=>a,a=>(navigator.onLine&&ea(a),Promise.reject(a)));const $s=a=>
1{if(!a)return null;if(typeof a=="string"||typeof a=="number")return a;if(typeof a=="object"){if(typeof a.documentId=="string"&&a.documentId)return a.documentId;if(typeof a.id=="number")return a.id}return null},Ne={async getByProject(a,i={}){var o,h,d,g;try{const{page:u=1,pageSize:b=500}=i,f=new URLSearchParams;f.append("filters[proyecto][documentId][$eq]",a),f.append("populate[0]","files"),f.append("populate[1]","todo_statu"),f.append("populate[2]","users"),f.append("populate[3]","proyecto"),f.append("pagination[page]",String(u)),f.append("pagination[pageSize]",String(b)),f.append("sort","createdAt:desc");const m=await ue.get(`/${E.API_PREFIX}/project-todos?${f.toString()}`);return{success:!0,data:m.data.data||[],meta:m.data.meta}}catch(u){return console.error("❌ Error fetching project todos:",((o=u==null?void 0:u.response)==null?void 0:o.data)||u),{success:!1,data:[],error:((g=(d=(h=u==null?void 0:u.response)==null?void 0:h.data)==null?void 0:d.error)==null?void 0:g.message)||"Error al obtener tareas del proyecto"}}},async create(a,i){var o,h,d,g;try{const u={title:i.title,content:i.content||"",files:i.files||[],date_init:i.date_init??null,date_end:i.date_end??null,publishedAt:new Date().toISOString(),proyecto:{connect:[{documentId:a}]}},b=$s(i.todo_statu);b&&(u.todo_statu=b),Array.isArray(i.users)&&(u.users={set:i.users});const f=await Xe(async()=>({success:!0,data:(await ue.post(`/${E.API_PREFIX}/project-todos`,{data:u})).data.data}),{url:`${E.BASE_URL}/${E.API_PREFIX}/project-todos`,method:"POST",body:{data:u},entityType:"todo_proyecto",action:"create",description:`Crear tarea de proyecto: ${i.title}`,optimisticData:u});if(f.success&&f.data){const m=f.data;We({moduleName:"Tarea",action:"created",record:m,recordId:m.documentId||m.id,route:`/crm/projects/${a}/todos/${m.documentId||m.id}`,payload:i})}return f}catch(u){return console.error("❌ Error creating project todo:",((o=u==null?void 0:u.response)==null?void 0:o.data)||u),{success:!1,error:((g=(d=(h=u==null?void 0:u.response)==null?void 0:h.data)==null?void 0:d.error)==null?void 0:g.message)||"Error al crear tarea"}}},async update(a,i){var o,h,d,g,u;try{const b={...i.title!==void 0?{title:i.title}:{},...i.content!==void 0?{content:i.content}:{},...i.files!==void 0?{files:i.files}:{},...i.date_init!==void 0?{date_init:i.date_init}:{},...i.date_end!==void 0?{date_end:i.date_end}:{},...i.orden!==void 0?{orden:i.orden}:{}},f=$s(i.todo_statu);f!==null&&(b.todo_statu=f),Array.isArray(i.users)&&(b.users={set:i.users});const m=await Xe(async()=>({success:!0,data:(await ue.put(`/${E.API_PREFIX}/project-todos/${a}`,{data:b})).data.data}),{url:`${E.BASE_URL}/${E.API_PREFIX}/project-todos/${a}`,method:"PUT",body:{data:b},entityType:"todo_proyecto",entityId:a,action:"update",description:"Actualizar tarea de proyecto",optimisticData:b});if(m.success&&m.data){const v=m.data;We({moduleName:"Tarea",action:"updated",record:v,recordId:v.documentId||v.id,route:`/crm/projects/${((o=v.proyecto)==null?void 0:o.documentId)||""}/todos/${v.documentId||v.id}`,payload:i})}return m}catch(b){return console.error("❌ Error updating project todo:",((h=b==null?void 0:b.response)==null?void 0:h.data)||b),{success:!1,error:((u=(g=(d=b==null?void 0:b.response)==null?void 0:d.data)==null?void 0:g.error)==null?void 0:u.message)||"Error al actualizar tarea"}}},async delete(a){var i,o,h,d;try{const g=await Xe(async()=>(await ue.delete(`/${E.API_PREFIX}/project-todos/${a}`),{success:!0}),{url:`${E.BASE_URL}/${E.API_PREFIX}/project-todos/${a}`,method:"DELETE",entityType:"todo_proyecto",entityId:a,action:"delete",description:"Eliminar tarea de proyecto"});return g.success&&We({moduleName:"Tarea",action:"deleted",record:{documentId:a},recordId:a,payload:{eliminado:!0}}),g}catch(g){return console.error("❌ Error deleting project todo:",((i=g==null?void 0:g.response)==null?void 0:i.data)||g),{success:!1,error:((d=(h=(o=g==null?void 0:g.response)==null?void 0:o.data)==null?void 0:h.error)==null?void 0:d.message)||"Error al eliminar tarea"}}}};function Ga({isOpen:a,onClose:i,user:o}){var m,v;if(!o)return null;const h=typeof o.avatar=="string"?o.avatar:(m=o.avatar)!=null&&m.url?o.avatar.url.
1startsWith("http")?o.avatar.url:`${E.BASE_URL}${o.avatar.url}`:null,d=o.telefono||o.phone,g=(o.username||o.email||"U").slice(0,2).toUpperCase(),u=()=>{d&&window.open(`tel:${d}`,"_self")},b=()=>{if(d){const A=d.replace(/\D/g,"");window.open(`https://wa.me/${A}`,"_blank")}},f=()=>{o.email&&window.open(`mailto:${o.email}`,"_self")};return e.jsx(Ze,{open:a,onOpenChange:i,children:e.jsxs(es,{size:"sm",children:[e.jsx(ss,{children:e.jsx(ts,{className:"sr-only",children:"Información del usuario"})}),e.jsxs("div",{className:"flex flex-col items-center text-center py-4",children:[e.jsxs(ye,{className:"h-20 w-20 mb-4 ring-4 ring-primary/20",children:[h?e.jsx(Ys,{src:h,alt:o.username||"Usuario"}):null,e.jsx(we,{className:"text-2xl bg-primary text-primary-foreground",children:g})]}),e.jsx("h3",{className:"text-xl font-semibold",children:o.username||o.email}),o.email&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:o.email}),((v=o.role)==null?void 0:v.name)&&e.jsx(W,{variant:"secondary",className:"mt-2",children:o.role.name}),e.jsxs("div",{className:"flex flex-wrap gap-2 justify-center mt-3",children:[o.departamento&&e.jsxs(W,{variant:"outline",className:"gap-1",children:[e.jsx(Mt,{className:"h-3 w-3"}),o.departamento]}),o.cargo&&e.jsxs(W,{variant:"outline",className:"gap-1",children:[e.jsx(Ut,{className:"h-3 w-3"}),o.cargo]})]}),d&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-3 flex items-center gap-2",children:[e.jsx(ks,{className:"h-4 w-4"}),d]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 pt-4 border-t",children:[e.jsxs(C,{variant:"outline",className:"flex flex-col h-auto py-3 gap-1",onClick:u,disabled:!d,children:[e.jsx(ks,{className:"h-5 w-5 text-green-600"}),e.jsx("span",{className:"text-xs",children:"Llamar"})]}),e.jsxs(C,{variant:"outline",className:"flex flex-col h-auto py-3 gap-1",onClick:b,disabled:!d,children:[e.jsx(zt,{className:"h-5 w-5 text-green-500"}),e.jsx("span",{className:"text-xs",children:"WhatsApp"})]}),e.jsxs(C,{variant:"outline",className:"flex flex-col h-auto py-3 gap-1",onClick:f,disabled:!o.email,children:[e.jsx(Lt,{className:"h-5 w-5 text-blue-500"}),e.jsx("span",{className:"text-xs",children:"Email"})]})]})]})})}function Ka({isOpen:a,onClose:i,files:o,todoTitle:h}){const[d,g]=j.useState(null),[u,b]=j.useState(!1),f=r=>r?r.startsWith("http")?r:`${E.BASE_URL}${r}`:"",m=(r,F)=>r!=null&&r.startsWith("image/")?Bs:r!=null&&r.includes("pdf")?Vs:r!=null&&r.includes("excel")||r!=null&&r.includes("spreadsheet")||F===".xlsx"||F===".xls"?Ws:r!=null&&r.includes("powerpoint")||r!=null&&r.includes("presentation")||F===".pptx"||F===".ppt"?Hs:r!=null&&r.startsWith("video/")?qs:r!=null&&r.startsWith("audio/")?Gs:Ks,v=r=>r?r<1024?r+" B":r<1024*1024?(r/1024).toFixed(1)+" KB":(r/(1024*1024)).toFixed(1)+" MB":"0 B",A=r=>{g(r),b(!0)};return e.jsxs(e.Fragment,{children:[e.jsx(Ze,{open:a,onOpenChange:i,children:e.jsxs(es,{size:"sm",children:[e.jsxs(ss,{children:[e.jsxs(ts,{className:"flex items-center gap-2",children:[e.jsx(G,{className:"h-5 w-5 text-primary"}),"Archivos de la tarea"]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:h})]}),e.jsx(Zs,{className:"max-h-[400px]",children:o.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(G,{className:"h-12 w-12 mb-4 opacity-50"}),e.jsx("p",{children:"No hay archivos adjuntos"})]}):e.jsx("div",{className:"space-y-2 pr-4",children:o.map(r=>{var S;const F=m(r.mime,r.ext),I=(S=r.mime)==null?void 0:S.startsWith("image/");return e.jsxs("div",{className:"group flex items-center gap-3 p-3 rounded-lg border bg-card hover:bg-accent/50 transition-colors",children:[e.jsx("div",{className:"shrink-0 w-12 h-12 rounded-lg bg-muted flex items-center justify-center overflow-hidden",children:I?e.jsx("img",{src:f(r.url),alt:r.name,className:"w-full h-full object-cover"}):e.jsx(F,{className:"h-6 w-6 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",title:r.name,children:r.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:v(r.size)})]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(C,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>A(r),title:"Ver archivo",children:e.jsx($t,{className:"h-4 w-4"})}),e.jsx(C,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>window.open(f(r.url),"_blank"),title:"Descargar",children:e.jsx(Rs,{className:"h-4 w-4"})})]})]},r.id)})})})]})}),e.jsx(et,{isOpen:u,onClose:()=>b(!1),file:d})]})}const Qa={hidden:{opacity:0,y:20,scale:.95},visible:a=>({opacity:1,y:0,scale:1,transition:{delay:a*.1,duration:.4,ease:[.25,.46,.45,.94]}})};function Xa({todos:a,completedStatusNames:i=["completado","completada","done","hecho","terminado","finalizado"]}){const o=j.useMemo(()=>{let d=0,g=0,u=0,b=0;return a.forEach(f=>{const m=f.estado||f.todo_statu,v=((m==null?void 0:m.name)||(m==null?void 0:m.Nombre)||"").toLowerCase();if(i.some(r=>v.includes(r.toLowerCase())))u++;else if(b++,f.date_end){const r=_(f.date_end);Ce(r)?g++:as(r)&&d++}}),{total:a.length,overdue:d,dueToday:g,completedThisWeek:u,inProgress:b}},[a,i]),h=[{label:"Total Tareas",value:o.total,icon:Ot,color:"bg-blue-500/20",iconColor:"text-blue-500",borderColor:"border-blue-500/30",bgGlow:"shadow-blue-500/10"},{label:"Vencidas",value:o.overdue,icon:Qs,color:"bg-rose-500/20",iconColor:"text-rose-500",borderColor:"border-rose-500/30",bgGlow:"shadow-rose-500/10",urgent:o.overdue>0}
1,{label:"Vencen Hoy",value:o.dueToday,icon:Rt,color:"bg-amber-500/20",iconColor:"text-amber-500",borderColor:"border-amber-500/30",bgGlow:"shadow-amber-500/10",warning:o.dueToday>0},{label:"En Progreso",value:o.inProgress,icon:Bt,color:"bg-violet-500/20",iconColor:"text-violet-500",borderColor:"border-violet-500/30",bgGlow:"shadow-violet-500/10"},{label:"Completadas",value:o.completedThisWeek,icon:Vt,color:"bg-emerald-500/20",iconColor:"text-emerald-500",borderColor:"border-emerald-500/30",bgGlow:"shadow-emerald-500/10"}];return e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3",children:h.map((d,g)=>{const u=d.icon;return e.jsxs(Xs.div,{custom:g,variants:Qa,initial:"hidden",animate:"visible",className:w("relative overflow-hidden rounded-lg border p-4","","transition-all duration-300 hover:scale-[1.02] hover:shadow-lg",d.color,d.borderColor,d.bgGlow,d.urgent&&"ring-2 ring-rose-500/50 animate-pulse",d.warning&&"ring-1 ring-amber-500/40"),children:[e.jsx("div",{className:"absolute inset-0 opacity-5",children:e.jsx("div",{className:"absolute -right-4 -top-4 h-24 w-24 rounded-full bg-current blur-2xl"})}),e.jsxs("div",{className:"relative flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:d.label}),e.jsx("p",{className:w("text-2xl font-bold tracking-tight",d.urgent&&"text-rose-500",d.warning&&"text-amber-500"),children:d.value})]}
1),e.jsx("div",{className:w("rounded-lg p-2 bg-background/50",d.iconColor),children:e.jsx(u,{className:"h-5 w-5"})})]}),(d.urgent||d.warning)&&d.value>0&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-1",children:e.jsx("div",{className:w("h-full rounded-full",d.urgent?"bg-rose-500":"bg-amber-500","animate-pulse")})})]},d.label)})})}const ie=[{bg:"bg-blue-500/15",text:"text-blue-600 dark:text-blue-400",border:"border-blue-500/40",accent:"bg-blue-500"},{bg:"bg-emerald-500/15",text:"text-emerald-600 dark:text-emerald-400",border:"border-emerald-500/40",accent:"bg-emerald-500"},{bg:"bg-amber-500/15",text:"text-amber-600 dark:text-amber-400",border:"border-amber-500/40",accent:"bg-amber-500"},{bg:"bg-rose-500/15",text:"text-rose-600 dark:text-rose-400",border:"border-rose-500/40",accent:"bg-rose-500"},{bg:"bg-violet-500/15",text:"text-violet-600 dark:text-violet-400",border:"border-violet-500/40",accent:"bg-violet-500"},{bg:"bg-pink-500/15",text:"text-pink-600 dark:text-pink-400",border:"border-pink-500/40",accent:"bg-pink-500"},{bg:"bg-indigo-500/15",text:"text-indigo-600 dark:text-indigo-400",border:"border-indigo-500/40",accent:"bg-indigo-500"},{bg:"bg-orange-500/15",text:"text-orange-600 dark:text-orange-400",border:"border-orange-500/40",accent:"bg-orange-500"}],Y=(a,i)=>String((a==null?void 0:a.documentId)??(a==null?void 0:a.id)??`pos-${i}`);function Ja({todo:a,index:i,onEdit:o,onDelete:h,statusColors:d,onUserClick:g,onFilesClick:u,canEdit:b,canDelete:f,canReorder:m}){const v=a.estado||a.todo_statu,A=v!=null&&v.documentId?d[v.documentId]:null,r=a.date_end&&as(_(a.date_end))&&!Ce(_(a.date_end)),F=a.date_end&&Ce(_(a.date_end));return a.date_end&&Va(_(a.date_end),new Date),e.jsx(ya,{id:Y(a,i),disabled:!m,children:()=>e.jsxs(ce,{className:w("group relative overflow-hidden transition-all duration-200",m&&"cursor-grab active:cursor-grabbing","hover:shadow-lg hover:shadow-primary/5 hover:-translate-y-0.5","bg-card/80 border",r&&"border-rose-500/50 bg-rose-500/5",F&&"border-amber-500/50 bg-amber-500/5"),children:[A&&e.jsx("div",{className:w("absolute top-0 left-0 right-0 h-1",A.accent)}),e.jsx(de,{className:"p-4 pt-5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:w("mt-0.5 opacity-40 hover:opacity-100 transition-opacity",m?"cursor-grab active:cursor-grabbing":"cursor-not-allowed"),children:e.jsx(Js,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-semibold text-sm leading-tight truncate",children:a.title||"Sin título"}),a.content&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1",children:a.content})]}),(b||f)&&e.jsx("div",{onClick:I=>I.stopPropagation(),onPointerDown:I=>I.stopPropagation(),children:e.jsxs(ma,{children:[e.jsx(xa,{asChild:!0,children:e.jsx(C,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Yt,{className:"h-4 w-4"})})}),e.jsxs(ha,{align:"end",children:[b&&e.jsxs(zs,{onClick:()=>o(i,a),children:[e.jsx(Je,{className:"mr-2 h-4 w-4"}),"Editar"]}),f&&e.jsxs(zs,{onClick:()=>h(i),className:"text-destructive",children:[e.jsx(Ye,{className:"mr-2 h-4 w-4"}),"Eliminar"]})]})]})})]}),v&&A&&e.jsx(W,{variant:"secondary",className:w("text-[10px] font-medium px-2 py-0.5",A.bg,A.text),children:v.name||v.Nombre}),(a.date_init||a.date_end)&&e.jsxs("div",{className:w("flex items-center gap-2 text-xs rounded-md px-2 py-1.5",r?"bg-rose-500/10 text-rose-600 dar
1k:text-rose-400":F?"bg-amber-500/10 text-amber-600 dark:text-amber-400":"bg-muted/50 text-muted-foreground"),children:[r?e.jsx(Qs,{className:"h-3 w-3"}):e.jsx(ze,{className:"h-3 w-3"}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[a.date_init&&e.jsx("span",{children:B(_(a.date_init),"dd/MM/yyyy",{locale:V})}),a.date_init&&a.date_end&&e.jsx("span",{children:"→"}),a.date_end&&e.jsx("span",{className:"font-medium",children:B(_(a.date_end),"dd/MM/yyyy",{locale:V})}),r&&e.jsx("span",{className:"text-[10px]",children:"(Vencida)"}),F&&e.jsx("span",{className:"text-[10px]",children:"(Hoy)"})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[a.users&&a.users.length>0?e.jsx(pa,{children:e.jsxs("div",{className:"flex -space-x-2",children:[a.users.slice(0,4).map(I=>{const S=(I.username||I.email||"U").slice(0,2).toUpperCase();return e.jsxs(ga,{children:[e.jsx(fa,{asChild:!0,children:e.jsx("button",{onClick:()=>g(I),onPointerDown:K=>K.stopPropagation(),className:"relative rounded-full ring-2 ring-background hover:ring-primary transition-all hover:z-10 hover:scale-110",children:e.jsx(ye,{className:"h-7 w-7",children:e.jsx(we,{className:"text-[10px] bg-primary/80 text-primary-foreground",children:S})})})}),e.jsxs(ja,{side:"bottom",className:"text-xs",children:[e.jsx("p",{className:"font-medium",children:I.username||I.email}),e.jsx("p",{className:"text-muted-foreground",children:I.email})]})]},I.id)}),a.users.length>4&&e.jsx("div",{className:"relative rounded-full ring-2 ring-background",children:e.jsx(ye,{className:"h-7 w-7",children:e.jsxs(we,{className:"text-[10px] bg-muted text-muted-foreground",children:["+",a.users.length-4]})})})]})}):e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Ue,{className:"h-3 w-3"}),e.jsx("span",{children:"Sin asignar"})]}),a.files&&a.files.length>0&&e.jsxs(C,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs gap-1.5 text-muted-foreground hover:text-foreground",onClick:()=>u(a),onPointerDown:I=>I.stopPropagation(),children:[e.jsx(G,{className:"h-3.5 w-3.5"}),a.files.length]})]})]})]})})]})})}function Os({status:a,todos:i,todosPorId:o,onEdit:h,onDelete:d,statusColors:g,colorStyle:u,onUserClick:b,onFilesClick:f,canEdit:m,canDelete:v,canReorder:A}){const r=(a==null?void 0:a.documentId)||"no-status";return e.jsx(Na,{id:r,itemIds:i.map(({todo:F,index:I})=>Y(F,I)),className:"flex-1 min-w-[300px] max-w-[360px]",children:({isOver:F,itemIds:I})=>e.jsxs("div",{className:w("h-full rounded-lg p-4 transition-all duration-200",u.bg,"border-2",F?"border-primary ring-2 ring-primary/20":u.border),children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:w("w-2.5 h-2.5 rounded-full",u.accent)}),e.jsx("h3",{className:w("font-semibold",u.text),children:(a==null?void 0:a.name)||(a==null?void 0:a.Nombre)||"Sin estado"})]}
1),e.jsx(W,{variant:"secondary",className:w("rounded-full font-semibold",u.bg,u.text),children:I.length})]}),e.jsxs("div",{className:"space-y-3 min-h-[120px]",children:[I.map(S=>{const K=o.get(S);return K?e.jsx(Ja,{todo:K.todo,index:K.index,onEdit:h,onDelete:d,statusColors:g,onUserClick:b,onFilesClick:f,canEdit:m,canDelete:v,canReorder:A},S):null}),I.length===0&&e.jsx("div",{className:w("text-center py-10 text-muted-foreground text-sm rounded-lg transition-colors border-2 border-dashed",F?"bg-primary/10 border-primary/40":"border-transparent"),children:F?"Soltar aquí":"Sin tareas"})]})]})})}function $r({embedded:a=!1,projectDocumentId:i}){var Fs,Ps,Ds;const{documentId:o}=Wa(),h=i||sa(o),d=ta(h),g=Ha(),{hasPermission:u}=aa(),b=ra(),f=u("api::project-todo.project-todo.create"),m=u("api::project-todo.project-todo.update"),v=u("api::project-todo.project-todo.delete"),{user:A}=na(),{getRoleType:r}=la(),{startTour:F,hasSeenTour:I}=oa("project-todo-tour",qa),[S,K]=j.useState(null),[st,rs]=j.useState(!0),[ns,Ie]=j.useState(!1),[M,tt]=j.useState([]),{filters:Z,setFilters:ee}=Ba(`project-todos:${h||"unknown"}`,{viewMode:"kanban",searchQuery:"",statusFilter:"all",userFilter:"all",fileSearchQuery:"",fileTypeFilter:"all"}),se=Z.viewMode,at=s=>ee(t=>({...t,viewMode:s})),H=Z.searchQuery,ls=s=>ee(t=>({...t,searchQuery:s})),z=Z.statusFilter,os=s=>ee(t=>({...t,statusFilter:s})),Q=Z.userFilter,is=s=>ee(t=>({...t,userFilter:s})),[L,cs]=j.useState(void 0),[$,ds]=j.useState(void 0),me=Z.fileSearchQuery,rt=s=>ee(t=>({...t,fileSearchQuery:s})),te=Z.fileTypeFilter,nt=s=>ee(t=>({...t,fileTypeFilter:s})),[lt,xe]=j.useState(!1),[O,us]=j.useState(null),[p,R]=j.useState({title:"",content:"",files:[],estado:void 0,date_init:void 0,date_end:void 0,users:[]}),[he,Se]=j.useState([]),[ms,xs]=j.useState(!1),[Te,ot]=j.useState([]),[it,hs]=j.useState(!1),[_e,Le]=j.useState(""),[ps,ct]=j.useState(!1),[dt,ut]=j.useState(null),[mt,gs]=j.useState(!1),[xt,ht]=j.useState(null),[pt,fs]=j.useState(!1),[ae,gt]=j.useState(null),[ft,js]=j.useState(!1);r();const{data:pe,isLoading:jt,refetch:ge,optimisticCreate:bt,optimisticUpdate:bs,optimisticDelete:vt}=Aa(["project-todos",h],()=>Ne.getByProject(h,{pageSize:500}),Ma.PROJECT_TODO,{enabled:!!h}),T=j.useMemo(()=>pe!=null&&pe.data?pe.data.map(s=>({...s,estado:s.todo_statu||s.estado})):[],[pe]),fe=j.useMemo(()=>{const s={};return M.forEach((t,n)=>{s[t.documentId]=ie[n%ie.length]}),s},[M]);j.useEffect(()=>{wt(),Ct(),Nt()},[h]);const Nt=async()=>{hs(!0);try{const s=await Ra.getUsers({pageSize:500});s.success&&ot(s.data.map(t=>({id:t.id,username:t.username||t.email,email:t.email,telefono:t.telefono,phone:t.phone,avatar:t.avatar,role:t.role})))}catch(s){console.error("Error loading users:",s)}finally{hs(!1)}},vs=j.useMemo(()=>{if(!_e)return Te;const s=_e.toLowerCase();return Te.filter(t=>t.username.toLowerCase().includes(s)||t.email.toLowerCase().includes(s))},[Te,_e]),yt=j.useMemo(()=>(p.users||[]).map(s=>s.id),[p.users]),Ns=s=>{R(t=>{const n=t.users||[];return n.some(c=>c.id===s.id)?{...t,users:n.filter(c=>c.id!==s.id)}:{...t,users:[...n,s]}})},wt=async()=>{if(h){rs(!0);try{const s=await Ls.getProject(h);s.success&&s.data?K(s.data):(k.error(s.error||"Error al cargar proyecto"),a||g("/crm/project"))}catch(s){console.error("Error loading project:",s),k.error("Error al cargar proyecto"),a||g("/crm/project")}finally{rs(!1)}}},Ct=async()=>{try{const s=await Ea.getTodoStatuses({pageSize:100});s.success&&tt(s.data)}catch(s){console.error("Error loading todo statuses:",s)}},re=j.useMemo(()=>T.filter(s=>{const t=H.toLowerCase(),n=(s.title||"").toLowerCase().includes(t),l=(s.content||"").toLowerCase().includes(t),c=n||l;let x=!0;if(z!=="all"){const P=s.estado||s.todo_statu;z==="no-status"?x=!P:x=(P==null?void 0:P.documentId)===z}let N=!0;Q!=="all"&&(N=(s.users||[]).some(P=>String(P.id)===Q));let y=!0;if(L||$){const P=s.date_init?_(s.date_init):null,D=s.date_end?_(s.date_end):null;if(L){const U=new Date(L);U.setHours(0,0,0,0),D?y=y&&D>=U:P?y=y&&P>=U:y=!1}if($){const U=new Date($);U.setHours(23,59,59,999),P?y=y&&P<=U:D?y=y&&D<=U:y=!1}}return c&&x&&N&&y}),[T,H,z,Q,L,$]),ys=j.useMemo(()=>{const s=[];return T.forEach((t,n)=>
1{(t.files||[]).forEach(l=>{s.push({file:l,todoTitle:t.title||"Sin título",todoIndex:n})})}),s},[T]),ws=j.useMemo(()=>ys.filter(({file:s,todoTitle:t})=>{const n=me.toLowerCase(),l=s.name.toLowerCase().includes(n),c=t.toLowerCase().includes(n);let x=!0;if(te!=="all"){const N=s.mime||"",y=s.ext||"";switch(te){case"images":x=N.startsWith("image/");break;case"documents":x=N.includes("pdf")||N.includes("word")||N.includes("document")||y===".pdf"||y===".doc"||y===".docx";break;case"spreadsheets":x=N.includes("excel")||N.includes("spreadsheet")||y===".xlsx"||y===".xls";break;case"presentations":x=N.includes("powerpoint")||N.includes("presentation")||y===".pptx"||y===".ppt";break;case"videos":x=N.startsWith("video/");break;case"audio":x=N.startsWith("audio/");break;default:x=!0}}return(l||c)&&x}),[ys,me,te]),Cs=s=>{if(!s)return null;if(typeof s=="string"||typeof s=="number")return s;if(typeof s=="object"){if(typeof s.documentId=="string"&&s.documentId)return s.documentId;if(typeof s.id=="number")return s.id}return null},ne=s=>typeof(s==null?void 0:s.documentId)=="string"&&s.documentId?s.documentId:null,It=()=>{us(null),R({title:"",content:"",files:[],estado:void 0,date_init:void 0,date_end:void 0,users:[]}),Se([]),Le(""),xe(!0)},Fe=(s,t)=>{us({index:s,data:t}),R({title:t.title||"",content:t.content||"",files:t.files||[],estado:t.estado||t.todo_statu,date_init:t.date_init,date_end:t.date_end,users:t.users||[]}),Se(t.files||[]),Le(""),xe(!0)},Pe=async s=>{if(!(await ua.fire({title:"¿Estás seguro?",text:"¿Deseas eliminar esta tarea?",icon:"warning",showCancelButton:!0,confirmButtonColor:"#d33",cancelButtonColor:"#3085d6",confirmButtonText:"Sí, eliminar",cancelButtonText:"Cancelar"})).isConfirmed||!S||!h)return;const n=T[s],l=ne(n);if(!l){k.error("No se pudo identificar la tarea (documentId faltante)");return}const c=n.title||"Sin título";vt(l),Ie(!0);try{const x=await Ne.delete(l);if(x.success){k.success("Tarea eliminada exitosamente");const N=JSON.parse(localStorage.getItem("user")||"{}");if(N.id&&S){const y=Array.isArray(S.Asesor)?S.Asesor.map(P=>P.id):[];Us.notifyToDoChange("deleted",h,S.Nombre,c,N.id,y).catch(console.error)}}else k.error(x.error||"Error al eliminar tarea"),ge()}catch{k.error("Error al eliminar tarea"),ge()}finally{Ie(!1)}},St=j.useCallback(async s=>{if(s.length!==0){xs(!0);try{const t=s.map(c=>Ls.uploadFile(c)),l=(await Promise.all(t)).filter(c=>c.success).map(c=>c.data);Se(c=>[...c,...l]),R(c=>({...c,files:[...c.files||[],...l]})),k.success(`${l.length} archivo(s) subido(s) exitosamente`)}catch(t){console.error("Error uploading files:",t),k.error("Error al subir archivos")}finally{xs(!1)}}},[]),{getRootProps:Tt,getInputProps:_t,isDragActive:Ft}=ka({onDrop:St,disabled:ms}),Pt=s=>{Se(t=>t.filter(n=>n.id!==s)),R(t=>({...t,files:(t.files||[]).filter(n=>(typeof n=="number"?n:n.id)!==s)}))},Dt=async()=>{if(!p.title.trim()){k.error("El título es requerido");return}if(p.date_init&&p.date_end){const t=_(p.date_init);if(_(p.date_end)<t){k.error("La fecha de fin no puede ser anterior a la fecha de inicio");return}}if(!S||!h)return;const s={title:p.title,content:p.content,files:he.map(t=>t.id),todo_statu:Cs(p.estado),date_init:p.date_init||null,date_end:p.date_end||null,users:(p.users||[]).map(t=>t.id)};Ie(!0);try{let t;if(O){const n=T[O.index],l=ne(n);if(!l){k.error("No se pudo identificar la tarea (documentId faltante)");return}bs(l,{...s,files:he,todo_statu:p.estado,users:p.users}),t=await Ne.update(l,s)}else t=await Ne.create(h,s),t.success&&t.data&&bt({...t.data,files:he,todo_statu:p.estado,users:p.users});if(t.success){k.success(O?"Tarea actualizada":"Tarea agregada"),xe(!1);const n=JSON.parse(localStorage.getItem("user")||"{}");if(n.id&&S){const l=Array.isArray(S.Asesor)?S.Asesor.map(c=>c.id):[];Us.notifyToDoChange(O?"updated":"created",h,S.Nombre,p.title,n.id,l).catch(console.error)}}else k.error(t.error||"Error al guardar tarea"),ge()}catch{k.error("Error al guardar tarea"),ge()}finally{Ie(!1)}},Et=async({itemId:s,fromColumnId:t,toColumnId:n,toIndex:l})=>{if(!m||!S||!h)return;const c=T==null?void 0:T.find((D,U)=>Y(D,U)===s);if(!c)return;const x=n==="no-status"?null:M.find(D=>D.documentId===n)??null,N=ne(c);if(!N)return;const y=t!==n,P=q(n==="no-status"?null:n).map(({todo:D})=>D).filter(D=>ne(D)!==N);P.splice(Math.max(0,Math.min(l,P.length)),0,c),bs(N,{estado:x||void 0,todo_statu:x||void 0,orden:(P.findIndex(D=>ne(D)===N)+1)*10});try{await Promise.all(P.map((D,U)=>{const Oe=ne(D);if(!Oe)return Promise.resolve();const Es={orden:(U+1)*10};return Oe===N&&y&&(Es.todo_statu=Cs(x)),Ne.update(Oe,Es)})),k.success(y?"Estado actualizado":"Orden actualizado")}catch(D){console.error("Error moviendo la tarea:",D),ge()}},Is=s=>s?s.startsWith("http")?s:`${E.BASE_URL}${s}`:"",Ss=(s,t)=>s!=null&&s.startsWith("image/")?Bs:s!=null&&s.includes("pdf")?Vs:s!=null&&s.includes("excel")||s!=null&&s.includes("spreadsheet")||t===".xlsx"||t===".xls"?Ws:s!=null&&s.includes("powerpoint")||s!=null&&s.includes("presentation")||t===".pptx"||t===".ppt"?Hs:s!=null&&s.startsWith("video/")?qs:s!=null&&s.startsWith("audio/")?Gs:Ks,kt=s=>{ut(s),gs(!0)},Ts=s=>s<1024?s+" B":s<1024*1024?(s/1024).toFixed(1)+" KB":(s/(1024*1024)).toFixed(1)+" MB",$e=s=>{ht(s),fs(!0)},De=s=>{gt(s),js(!0)},q=s=>(H||z!=="all"||Q!=="all"||L||$?re:T).map(l=>
1({todo:l,index:T.findIndex(c=>c.documentId&&l.documentId&&c.documentId===l.documentId||c.id===l.id)})).filter(({todo:l})=>{const c=l.estado||l.todo_statu;return s===null?!c:(c==null?void 0:c.documentId)===s}).sort((l,c)=>(Number(l.todo.orden)||0)-(Number(c.todo.orden)||0)),_s=j.useMemo(()=>new Map((T||[]).map((s,t)=>[Y(s,t),{todo:s,index:t}])),[T]);if(st||jt)return e.jsx("div",{className:"w-full h-full min-h-[16rem] bg-background"});if(!S)return null;const At=s=>(T==null?void 0:T.find((t,n)=>Y(t,n)===s))??null;return e.jsxs("div",{className:w(a?"space-y-4":"container mx-auto py-6 space-y-6"),children:[!a&&e.jsx(ba,{onClick:F,hasSeenTour:I}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4","data-tour":"todo-header",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[!a&&e.jsx(C,{variant:"ghost",size:"icon",onClick:()=>g(`/crm/project/${d}`),children:e.jsx(Wt,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-3xl font-bold flex items-center gap-2",children:[e.jsx(Ht,{className:"h-8 w-8 text-primary"}),"To-Do"]}),e.jsx("p",{className:"text-muted-foreground",children:S.Nombre})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ta,{value:se,onValueChange:s=>at(s),children:e.jsxs(_a,{children:[e.jsxs(ke,{value:"table",className:"gap-2",children:[e.jsx(qt,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Tabla"})]}),e.jsxs(ke,{value:"kanban",className:"gap-2",children:[e.jsx(Gt,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Kanban"})]}),e.jsxs(ke,{value:"diagram",className:"gap-2",children:[e.jsx(Kt,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Diagrama"})]}),e.jsxs(ke,{value:"files",className:"gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Archivos"})]})]})}),f&&e.jsxs(C,{onClick:It,"data-tour":"todo-create",children:[e.jsx(Qt,{className:"mr-2 h-4 w-4"}),"Nueva Tarea"]})]})]}),se!=="files"&&e.jsxs("div",{className:"flex flex-col gap-4","data-tour":"todo-search",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(Re,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Ee,{placeholder:"Buscar tareas por título o contenido...",value:H,onChange:s=>ls(s.target.value),className:"pl-10"})]}),e.jsxs(He,{value:z,onValueChange:os,children:[e.jsx(qe,{className:"w-[180px]",children:e.jsx(Ge,{placeholder:"Filtrar por estado"})}),e.jsxs(Ke,{className:"bg-popover z-50",children:[e.jsx(le,{value:"all",children:"Todos los estados"}),e.jsx(le,{value:"no-status",children:"Sin estado"}),M.map(s=>e.jsx(le,{value:s.documentId,children:s.name||s.Nombre},s.documentId))]})]}),e.jsxs(He,{value:Q,onValueChange:is,children:[e.jsxs(qe,{className:"w-[180px]",children:[e.jsx(Ue,{className:"h-4 w-4 mr-2"}),e.jsx(Ge,{placeholder:"Filtrar por usuario"})]}),e.jsxs(Ke,{className:"bg-popover z-50 max-h-[300px]",children:[e.jsx(le,{value:"all",children:"Todos los usuarios"}),Te.map(s=>e.jsx(le,{value:String(s.id),children:s.username||s.email},s.id))]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsxs(je,{children:[e.jsx(be,{asChild:!0,children:e.jsxs(C,{variant:"outline",className:"w-[180px] justify-start text-left font-normal",children:[e.jsx(ze,{className:"mr-2 h-4 w-4"}),L?B(L,"dd/MM/yyyy",{locale:V}):"Desde fecha"]})}),e.jsx(ve,{className:"w-auto p-0 bg-popover z-50",align:"start",children:e.jsx(Me,{mode:"single",selected:L,onSelect:cs,locale:V,initialFocus:!0})})]}),e.jsxs(je,{children:[e.jsx(be,{asChild:!0,children:e.jsxs(C,{variant:"outline",className:"w-[180px] justify-start text-left font-normal",children:[e.jsx(ze,{className:"mr-2 h-4 w-4"}),$?B($,"dd/MM/yyyy",{locale:V}):"Hasta fecha"]})}),e.jsx(ve,{className:"w-auto p-0 bg-popover z-50",align:"start",children:e.jsx(Me,{mode:"single",selected:$,onSelect:ds,locale:V,initialFocus:!0})})]}),(H||z!=="all"||Q!=="all"||L||$)&&e.jsxs(C,{variant:"ghost",size:"sm",onClick:()=>{ls(""),os("all"),is("all"),cs(void 0),ds(void 0)},children:[e.jsx(Be,{className:"h-4 w-4 mr-1"}),"Limpiar filtros"]}),(H||z!=="all"||Q!=="all"||L||$)&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:[re.length," de ",T.length||0," tareas"]})]})]}),se==="files"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(Re,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Ee,{placeholder:"Buscar archivos por nombre o tarea...",value:me,onChange:s=>rt(s.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:[{value:"all",label:"Todos"},{value:"images",label:"Imágenes"},{value:"documents",label:"Documentos"},{value:"spreadsheets",label:"Hojas de cálculo"},{value:"presentations",label:"Presentaciones"},{value:"videos",label:"Videos"},{value:"audio",label:"Audio"}].map(s=>e.jsx(C,{variant:te===s.value?"default":"outline",size:"sm",onClick:()=>
1nt(s.value),children:s.label},s.value))})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:ws.length>0?ws.map(({file:s,todoTitle:t},n)=>{var x;const l=Ss(s.mime,s.ext),c=(x=s.mime)==null?void 0:x.startsWith("image/");return e.jsx(Xs.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},transition:{delay:n*.03},children:e.jsx(ce,{className:"hover:shadow-lg transition-all cursor-pointer group",onClick:()=>kt(s),children:e.jsxs(de,{className:"p-4",children:[e.jsx("div",{className:"aspect-square bg-muted rounded-lg mb-3 flex items-center justify-center overflow-hidden",children:c?e.jsx("img",{src:Is(s.url),alt:s.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform"}):e.jsx(l,{className:"h-16 w-16 text-muted-foreground"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",title:s.name,children:s.name}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",title:t,children:["Tarea: ",t]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:Ts(s.size)}),e.jsx(C,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity",onClick:N=>{N.stopPropagation(),window.open(Is(s.url),"_blank")},children:e.jsx(Rs,{className:"h-3 w-3"})})]})]})]})})},`${s.id}-${n}`)}):e.jsx("div",{className:"col-span-full",children:e.jsx(ce,{className:"border-dashed",children:e.jsxs(de,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(G,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:me||te!=="all"?"No se encontraron archivos":"No hay archivos"}),e.jsx("p",{className:"text-muted-foreground text-center",children:me||te!=="all"?"Intenta con otros filtros o términos de búsqueda":"Agrega archivos a tus tareas para verlos aquí"})]})})})})]}),se==="table"&&e.jsx(ce,{children:e.jsx(de,{className:"p-0",children:b?e.jsx(Ua,{children:re.length>0?re.map(s=>{const t=T.findIndex(x=>x.documentId&&s.documentId&&x.documentId===s.documentId||x.id===s.id),n=t>=0?t:0,l=s.estado||s.todo_statu,c=l!=null&&l.documentId?fe[l.documentId]:null;return e.jsxs(za,{children:[e.jsx(La,{children:e.jsx("span",{className:"font-medium",children:s.title||"Sin título"})}),e.jsxs($a,{columns:1,children:[e.jsx(Ae,{label:"Contenido",children:s.content||"-"}),e.jsx(Ae,{label:"Estado",children:l&&c?e.jsx(W,{className:w(c.bg,c.text),children:l.name||l.Nombre}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(Ae,{label:"Usuarios",children:s.users&&s.users.length>0?`${s.users.length}`:"-"}),e.jsx(Ae,{label:"Archivos",children:s.files&&s.files.length>0?`${s.files.length}`:"-"})]}),e.jsxs(Oa,{children:[s.files&&s.files.length>0&&e.jsxs(C,{size:"sm",variant:"outline",onClick:()=>De(s),children:[e.jsx(G,{className:"h-4 w-4 mr-1"}),"Archivos"]}),m&&e.jsxs(C,{size:"sm",variant:"outline",onClick:()=>Fe(n,s),children:[e.jsx(Je,{className:"h-4 w-4 mr-1"}),"Editar"]}),v&&e.jsx(C,{size:"sm",variant:"destructive",onClick:()=>Pe(n),children:e.jsx(Ye,{className:"h-4 w-4"})})]})]},n)}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:H||z!=="all"?"No se encontraron tareas":"No hay tareas. Crea tu primera tarea."})}):e.jsxs(Fa,{children:[e.jsx(Pa,{children:e.jsxs(Qe,{children:[e.jsx(oe,{children:"Título"}),e.jsx(oe,{children:"Contenido"}),e.jsx(oe,{children:"Estado"}),e.jsx(oe,{children:"Usuarios"}),e.jsx(oe,{children:"Archivos"}),e.jsx(oe,{className:"text-right",children:"Acciones"})]})}),e.jsx(Da,{children:re.length>0?re.map(s=>{const t=T.findIndex(x=>x.documentId&&s.documentId&&x.documentId===s.documentId||x.id===s.id),n=t>=0?t:0,l=s.estado||s.todo_statu,c=l!=null&&l.documentId?fe[l.documentId]:null;return e.jsxs(Qe,{children:[e.jsx(J,{className:"font-medium",children:s.title||"Sin título"}),e.jsx(J,{className:"max-w-[200px] truncate",children:s.content||"-"}),e.jsx(J,{children:l&&c?e.jsx(W,{className:w(c.bg,c.text),children:l.name||l.Nombre}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(J,{children:s.users&&s.users.length>
10?e.jsxs("div",{className:"flex -space-x-1",children:[s.users.slice(0,3).map(x=>e.jsx("button",{onClick:()=>$e(x),className:"relative rounded-full ring-2 ring-background hover:ring-primary transition-all hover:z-10",children:e.jsx(ye,{className:"h-6 w-6",children:e.jsx(we,{className:"text-[9px] bg-primary/80 text-primary-foreground",children:(x.username||x.email||"U").slice(0,2).toUpperCase()})})},x.id)),s.users.length>3&&e.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["+",s.users.length-3]})]}):"-"}),e.jsx(J,{children:s.files&&s.files.length>0?e.jsxs(C,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs gap-1",onClick:()=>De(s),children:[e.jsx(G,{className:"h-3 w-3"}),s.files.length]}):"-"}),e.jsx(J,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[m&&e.jsx(C,{variant:"ghost",size:"icon",onClick:()=>Fe(n,s),children:e.jsx(Je,{className:"h-4 w-4"})}),v&&e.jsx(C,{variant:"ghost",size:"icon",onClick:()=>Pe(n),className:"text-destructive",children:e.jsx(Ye,{className:"h-4 w-4"})})]})})]},n)}):e.jsx(Qe,{children:e.jsx(J,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:H||z!=="all"?"No se encontraron tareas":"No hay tareas. Crea tu primera tarea."})})})]})})}),se==="kanban"&&e.jsxs(e.Fragment,{children:[e.jsx(Xa,{todos:T}),e.jsxs(va,{columns:[{id:"no-status",itemIds:q(null).map(({todo:s,index:t})=>Y(s,t))},...M.map(s=>({id:s.documentId,itemIds:q(s.documentId).map(({todo:t,index:n})=>Y(t,n))}))],onDrop:Et,disabled:!m,renderOverlay:s=>{const t=At(s);if(!t)return null;const n=t.estado||t.todo_statu,l=n!=null&&n.documentId?fe[n.documentId]:null,c=t.date_end&&as(_(t.date_end))&&!Ce(_(t.date_end)),x=t.date_end&&Ce(_(t.date_end));return e.jsx("div",{className:"w-full pointer-events-none select-none",children:e.jsxs(ce,{className:w("relative overflow-hidden shadow-2xl ring-2 ring-primary/60 rotate-1 scale-[1.02] bg-card border",c&&"border-rose-500/50 bg-rose-500/10",x&&"border-amber-500/50 bg-amber-500/10"),children:[l&&e.jsx("div",{className:w("absolute top-0 left-0 right-0 h-1",l.accent)}),e.jsx(de,{className:"p-4 pt-5 space-y-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 opacity-70",children:e.jsx(Js,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-3",children:[e.jsx("div",{className:"flex items-start justify-between gap-2",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-semibold text-sm leading-tight truncate",children:t.title||"Sin título"}),t.content&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1",children:t.content})]})}),n&&l&&e.jsx(W,{variant:"secondary",className:w("text-[10px] font-medium px-2 py-0.5",l.bg,l.text),children:n.name||n.Nombre}),(t.date_init||t.date_end)&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(ze,{className:"h-3 w-3"}),t.date_init&&e.jsx("span",{children:B(_(t.date_init),"dd/MM/yyyy",{locale:V})}),t.date_init&&t.date_end&&e.jsx("span",{children:"→"}),t.date_end&&e.jsx("span",{children:B(_(t.date_end),"dd/MM/yyyy",{locale:V})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.users&&t.users.length>0?e.jsx("div",{className:"flex -space-x-2",children:t.users.slice(0,4).map(N=>{var y;return e.jsxs(ye,{className:"h-6 w-6 border-2 border-background",children:[e.jsx(Ys,{src:(y=N.avatar)==null?void 0:y.url}),e.jsx(we,{className:"text-[10px]",children:(N.username||N.email||"U").substring(0,2).toUpperCase()})]},N.id)})}):e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Ue,{className:"h-3 w-3"}),e.jsx("span",{children:"Sin asignar"})]}),t.files&&t.files.length>0&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(G,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:t.files.length})]})]})]})]})})]})})},className:"flex gap-4 overflow-x-auto pb-4 items-stretch",children:[e.jsx(Os,{status:null,todos:q(null),todosPorId:_s,onEdit:Fe,onDelete:Pe,statusColors:fe,colorStyle:{bg:"bg-muted/50",text:"text-muted-foreground",border:"border-muted",accent:"bg-muted-foreground"},onUserClick:$e,onFilesClick:De,canEdit:m,canDelete:v,canReorder:m}),M.map((s,t)=>e.jsx(Os,{status:s,todos:q(s.documentId),todosPorId:_s,onEdit:Fe,onDelete:Pe,statusColors:fe,colorStyle:ie[t%ie.length],onUserClick:$e,onFilesClick:De,canEdit:m,canDelete:v,canReorder:m},s.documentId))]})]}),se==="diagram"&&e.jsxs(ce,{children:[e.jsxs(Ca,{children:[e.jsx(Ia,{children:"Vista de Diagrama"}),e.jsx(Sa,{children:"Visualización del flujo de tareas"})]}),e.jsxs(de,{children:[e.jsx("div",{className:"flex items-center justify-center gap-4 flex-wrap py-8",children:M.map((s,t)=>{const n=q(s.documentId),l=ie[t%ie.length];return e.jsxs(Xt.Fragment,{children:[e.jsxs("div",{className:w("relative rounded-lg p-4 min-w-[150px] text-center border-2",l.bg,l.border),children:[e.jsx("h4",{className:w("font-semibold mb-2",l.text),children:s.name||s.Nombre}),e.jsx("div",{className:w("text-3xl font-bold",l.text),children:n.length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"tareas"})]}),t<M.length-1&&e.jsx("div",{className:"text-muted-foreground text-2xl",children:"→"})]},s.documentId)})}),e.jsx("div",{className:"mt-6 pt-6 border-t",children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:T.length||0}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total de tareas"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:q(null).length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Sin estado"})]}),M.slice(0,2).map(s=>e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:q(s.documentId).length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.name||s.Nombre})]},s.documentId))]})})]})]}),e.jsx(Ze,{open:lt,onOpenChange:xe,children:e.jsxs(es,{size:"lg",children:[e.jsxs(ss,{children:[e.jsx(ts,{children:O?"Editar Tarea":"Nueva Tarea"}),e.jsx(ia,{children:O?"Modifica los datos de la tarea":"Crea una nueva tarea para el proyecto"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(X,{htmlFor:"title",children:"Título *"}),e.jsx(Ee,{id:"title",value:p.title,onChange:s=>R(t=>({...t,title:s.target.value})),placeholder:"Título de la tarea"})]}),e.jsxs("div",{children:[e.jsx(X,{htmlFor:"estado",children:"Estado"}
1),e.jsxs(He,{value:((Fs=p.estado)==null?void 0:Fs.documentId)||(typeof p.estado=="string"?p.estado:""),onValueChange:s=>{const t=M.find(n=>n.documentId===s);R(n=>({...n,estado:t}))},children:[e.jsx(qe,{children:e.jsx(Ge,{placeholder:"Seleccionar estado"})}),e.jsx(Ke,{children:M.map(s=>e.jsx(le,{value:s.documentId,children:s.name||s.Nombre},s.documentId))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(X,{children:"Fecha de inicio"}),e.jsxs(je,{children:[e.jsx(be,{asChild:!0,children:e.jsxs(C,{variant:"outline",className:w("w-full justify-start text-left font-normal mt-1",!p.date_init&&"text-muted-foreground"),children:[e.jsx(As,{className:"mr-2 h-4 w-4"}),p.date_init?B(_(p.date_init),"PPP",{locale:V}):"Seleccionar fecha"]})}),e.jsx(ve,{className:"w-auto p-0 z-50",align:"start",children:e.jsx(Me,{mode:"single",selected:p.date_init?_(p.date_init):void 0,onSelect:s=>R(t=>({...t,date_init:s?B(s,"yyyy-MM-dd"):void 0})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),e.jsxs("div",{children:[e.jsx(X,{children:"Fecha de fin"}),e.jsxs(je,{children:[e.jsx(be,{asChild:!0,children:e.jsxs(C,{variant:"outline",className:w("w-full justify-start text-left font-normal mt-1",!p.date_end&&"text-muted-foreground"),children:[e.jsx(As,{className:"mr-2 h-4 w-4"}),p.date_end?B(_(p.date_end),"PPP",{locale:V}):"Seleccionar fecha"]})}),e.jsx(ve,{className:"w-auto p-0 z-50",align:"start",children:e.jsx(Me,{mode:"single",selected:p.date_end?_(p.date_end):void 0,onSelect:s=>R(t=>({...t,date_end:s?B(s,"yyyy-MM-dd"):void 0})),initialFocus:!0,className:"pointer-events-auto"})})]})]})]}),e.jsxs("div",{children:[e.jsx(X,{children:"Usuarios asignados"}),e.jsxs(je,{open:ps,onOpenChange:ct,children:[e.jsx(be,{asChild:!0,children:e.jsx(C,{variant:"outline",role:"combobox","aria-expanded":ps,className:"w-full justify-between mt-1",children:e.jsxs("div",{className:"flex items-center gap-2 truncate",children:[e.jsx(Ue,{className:"h-4 w-4 shrink-0"}),(((Ps=p.users)==null?void 0:Ps.length)||0)>0?`${p.users.length} usuario(s) seleccionado(s)`:"Seleccionar usuarios"]})})}),e.jsxs(ve,{className:"w-[400px] p-0 z-50",align:"start",children:[e.jsx("div",{className:"p-3 border-b",children:e.jsxs("div",{className:"relative",children:[e.jsx(Re,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Ee,{placeholder:"Buscar usuario...",value:_e,onChange:s=>Le(s.target.value),className:"pl-9"})]})}),e.jsx(Zs,{className:"h-[250px]",children:e.jsx("div",{className:"p-2",children:it?e.jsxs("div",{className:"flex items-center justify-center py-6",children:[e.jsx(Ve,{className:"h-5 w-5 animate-spin mr-2"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Cargando usuarios..."})]}):vs.length===0?e.jsx("p",{className:"text-center text-sm text-muted-foreground py-6",children:"No se encontraron usuarios"}):vs.map(s=>{const t=yt.includes(s.id);return e.jsxs("div",{onClick:()=>Ns(s),className:w("flex items-center gap-3 p-2 rounded-md cursor-pointer transition-colors",t?"bg-primary/10 border border-primary/30":"hover:bg-muted"),children:[e.jsx(ca,{checked:t,className:"pointer-events-none"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s.username}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.email})]}),t&&e.jsx(Ms,{className:"h-4 w-4 text-primary shrink-0"})]},s.id)})})}),(((Ds=p.users)==null?void 0:Ds.length)||0)>0&&e.jsx("div",{className:"p-3 border-t",children:e.jsx("div",{className:"flex flex-wrap gap-1",children:p.users.map(s=>e.jsxs(W,{variant:"secondary",className:"cursor-pointer hover:bg-destructive/20",onClick:()=>Ns(s),children:[s.username,e.jsx(Be,{className:"h-3 w-3 ml-1"})]},s.id))})})]})]})]}),e.jsxs("div",{children:[e.jsx(X,{htmlFor:"content",children:"Contenido"}),e.jsx(wa,{id:"content",value:p.content,onChange:s=>R(t=>({...t,content:s.target.value})),placeholder:"Describe la tarea...",className:"min-h-[100px]"})]}),e.jsxs("div",{children:[e.jsx(X,{children:"Archivos adjuntos"}),e.jsxs("div",{...Tt(),className:w("mt-2 border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors",Ft?"border-primary bg-primary/5":"border-muted-foreground
1/25 hover:border-primary/50"),children:[e.jsx("input",{..._t()}),ms?e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(Ve,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Subiendo archivos..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(Jt,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Arrastra archivos aquí o haz clic para seleccionar"})]})]}),he.length>0&&e.jsx("div",{className:"mt-4 space-y-2",children:he.map(s=>{const t=Ss(s.mime);return e.jsxs("div",{className:"flex items-center justify-between p-2 bg-muted rounded",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm truncate max-w-[200px]",children:s.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Ts(s.size)})]}),(O&&m||!O&&f)&&e.jsx(C,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Pt(s.id),children:e.jsx(Be,{className:"h-4 w-4"})})]},s.id)})})]})]}),e.jsxs(da,{children:[e.jsx(C,{variant:"outline",onClick:()=>xe(!1),children:"Cancelar"}),(O&&m||!O&&f)&&e.jsx(C,{onClick:Dt,disabled:ns,children:ns?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"mr-2 h-4 w-4 animate-spin"}),"Guardando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ms,{className:"mr-2 h-4 w-4"}),"Guardar"]})})]})]})}),e.jsx(et,{isOpen:mt,onClose:()=>gs(!1),file:dt}),e.jsx(Ga,{isOpen:pt,onClose:()=>fs(!1),user:xt}),e.jsx(Ka,{isOpen:ft,onClose:()=>js(!1),files:(ae==null?void 0:ae.files)||[],todoTitle:(ae==null?void 0:ae.title)||"Sin título"})]})}export{$r as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.