1import{j as e,c9 as T,bc as z,dz as E,L as $,v as B,be as W,u as H}from"./vendor-ui-fc56ca80.js";import{e as K,r as d}from"./vendor-react-f9ccc48d.js";import{h as O,t as f,af as P,B as C,ae as U,ag as q,ah as j,am as F}from"./index-90016d22.js";import{u as R}from"./useCapability-421f7f8b.js";import{b as V}from"./counselingService-1621b37c.js";import{g as N,c as G,t as J}from"./counseling-c919741d.js";import{N as Q}from"./NewCaseDialog-7bd9b25d.js";/* empty css */import{u as X,f as Y,L as Z}from"./vendor-utils-323b9898.js";import"./vendor-firebase-a557f106.js";import"./vendor-charts-9af8b7c0.js";const _=s=>s.split(" ").filter(p=>p.includes("text-")).join(" "),de=()=>{const{t:s,i18n:p}=X("counseling"),b=p.language.startsWith("en"),w=b?Z:F,A=b?"MMM d, yyyy":"d 'de' MMM yyyy",{user:n,userData:o}=O(),{can:y}=R(),m=K(),r=y("counselingAdmin"),x=y("counseling")||r,[u,S]=d.useState([]),[I,h]=d.useState(!0),[l,L]=d.useState("mine"),M=async()=>{if(!(o!=null&&o.churchId)||!(n!=null&&n.uid)||!x){h(!1);return}h(!0);try{S(await V(o.churchId,{id:n.uid,isAdmin:r}))}catch(t){console.error(t),H.error(s("common.loadError"))}finally{h(!1)}};d.useEffect(()=>{M()},[o==null?void 0:o.churchId,n==null?void 0:n.uid,r,x]);const g=d.useMemo(()=>{const t=n==null?void 0:n.uid;let i=u;return l==="closed"?i=u.filter(a=>a.status==="closed"):(i=u.filter(a=>a.status!=="closed"),l==="mine"&&(i=i.filter(a=>a.counselorId===t))),[...i].sort((a,c)=>{const k=N(a.status).priority,v=N(c.status).priority;return k!==v?v-k:c.openedAt.getTime()-a.openedAt.getTime()})},[u,l,n==null?void 0:n.uid]);return x?e.jsxs("div",{className:"p-4 md:p-6 space-y-4",children:[e.jsx(P,{title:s("title"),description:s("subtitle"),icon:e.jsx(T,{className:"h-5 w-5"}),badge:s("casesCount",{count:g.length}),action:o!=null&&o.churchId?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(C,{variant:"ghost",size:"sm",className:"text-muted-foreground gap-1.5",onClick:()=>m("/app/consejeria/guia"),children:[e.jsx(z,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:s("help.short")})]}),r&&e.jsxs(C,{variant:"ghost",size:"sm",className:"text-muted-foreground gap-1.5",onClick:()=>m("/app/consejeria/configuracion"),children:[e.jsx(E,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:s("ministry.short")})]}),e.jsx(Q,{churchId:o.churchId,onCreated:t=>m(`/app/consejeria/${t}`)})]}):void 0}),e.jsx(U,{value:l,onValueChange:t=>L(t),children:e.jsxs(q,{children:[e.jsx(j,{value:"mine",children:s("tabs.mine")}),r&&e.jsx(j,{value:"all",children:s("tabs.all")}),e.jsx(j,{value:"closed",children:s("tabs.closed")})]})}),I?e.jsxs("div",{className:"flex items-center justify-center py-16 text-muted-foreground",children:[e.jsx($,{className:"h-5 w-5 animate-spin mr-2"}),"â¦"]}):g.length===0?e.jsx(f,{className:"p-8 text-center text-muted-foreground",children:s(l==="closed"?"empty.closed":l==="all"?"empty.all":"empty.mine")}):e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4",children:g.map(t=>{var c;const i=N(t.status),a=G(t.openedAt,t.targetDate);return e.jsxs(f,{className:"case-notebook flex flex-col p-4 cursor-pointer",onClick:()=>m(`/app/consejeria/${t.id}`),children:[e.jsx("span",{"aria-hidden":!0,className:`notebook-spine ${_(i.badgeClass)}`}),e.jsx("span",{"aria-hidden":!0,className:"notebook-rules"}),e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium ${i.badgeClass}`,children:s(i.labelKey)}),t.confidential&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full font-medium bg-purple-100 text-purple-800 dark:bg-purple-900/40 dark:text-purple-300",children:[e.jsx(B,{className:"h-3 w-3"}),s("case.confidentialBadge")]})]}),e.jsx("p",{className:"font-medium leading-snug mt-2.5 line-clamp-2",children:(c=t.subjectNames)!=null&&c.length?t.subjectNames.join(" · "):s("case.noSubjects")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s(J(t.topic))}),e.jsxs("div",{className:"mt-auto pt-3 space-y-1",children:[t.status!=="closed"&&e.jsx("p",{className:`text-xs font-medium ${a.overdue?"text-amber-700 dark:text-amber-500":"text-muted-foreground"}`,children:a.totalWeeks?s("case.weekOf",{week:a.week,total:a.totalWeeks}):s("case.week",{week:a.week})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("case.openedAt",{date:Y(t.openedAt,A,{locale:w})})}),t.counselorName&&e.jsxs("p",{className:"text-xs text-muted-foreground inline-flex items-center gap-1",children:[e.jsx(W,{className:"h-3 w-3"}),t.counselorName]})]})]},t.id)})})]}):e.jsx("div",{className:"p-4 md:p-6",children:e.jsx(f,{className:"p-8 text-center text-muted-foreground",children:s("noAccess")})})};export{de as default,_ as statusInk};
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.