1import{j as e}from"./ui-vendor-DSl4G1OJ.js";import{a as P}from"./react-vendor-JYAUlju1.js";import{_ as x,q as g,r as b,w as v,x as y,B as f,T as S}from"./index-iv8p4bGb.js";import{T as H,a as E,b as R,c as a}from"./tabs-Fwe9v5pI.js";import{A as k}from"./adminUi-C-PNoBx1.js";import{B as q}from"./badge-BmcgN26q.js";import{c as B,l as O,b as L,d as Q,i as D,a as K}from"./wellbeingPlusApi--nQFeeE6.js";import{H as w}from"./heart-pulse-DDyL749i.js";import{P as M}from"./phone-call-CMPKmMxo.js";import{F as $}from"./frown-_ej7pYQ1.js";import{F as U}from"./footprints-BcW-OrnB.js";import{U as V}from"./users-DbO-ebqj.js";import{M as G}from"./megaphone-eKmCVPjV.js";import{A as z}from"./arrow-right-CpQyeIWr.js";import{C as Y}from"./calendar-clock-C-Thri2i.js";import{C as J}from"./clipboard-list-UebIQ0GV.js";import{L as X}from"./life-buoy-gqvf2NHR.js";import{C as Z}from"./circle-help-ms_ZceeK.js";import{AdminCheckinPanel as I}from"./AdminCheckinPanel-C2LIRvNK.js";import{AdminGoalsPanel as ee}from"./AdminGoalsPanel-xtmaDt5K.js";import ie from"./AdminWellnessProvidersPanel-Dkz_GOJ2.js";import{AdminWellbeingAlertsPanel as re}from"./AdminWellbeingAlertsPanel-DsJccyyI.js";import{AdminWellbeingResourcesPanel as se}from"./AdminWellbeingResourcesPanel-Cbqf6zVx.js";import{AdminWellbeingTopicsPanel as te}from"./AdminWellbeingTopicsPanel-C3XZ0mZf.js";import{AdminWellbeingCampaignsPanel as oe}from"./AdminWellbeingCampaignsPanel-CcENzWBk.js";import{W as ae}from"./WellbeingSetupNotice-B7j6r4gs.js";import"./inbox-DIy2Ab5G.js";import"./useMutation-CCxofYKg.js";import"./input-Cbpm_RuX.js";import"./table-Dfj6cfpN.js";import"./OperatorAdmin-Bd_05hEd.js";import"./lazyPortalView-D_lJRNm_.js";import"./PortalConfigurationNotice-Dgvk_vzZ.js";import"./target-BhiqlrDH.js";import"./book-open-DtepqIpV.js";import"./file-text-BAux0Bto.js";import"./calendar-days-BVXeHu32.js";import"./arrow-up-right-COe01Lj2.js";import"./usePortalConfigurationRefresh-BEQDNkJS.js";import"./supabaseFunctions-Xsh4_ii9.js";import"./operatorWorkflowApi-DwMjzjiG.js";import"./PortalShell-dTjF68xL.js";import"./PortalTopBar-Crdrgefk.js";import"./AssistantVisibilityToggle-DixiZzHv.js";import"./sparkles-B69mEhZg.js";import"./portalBackdrops-DNQCo-tU.js";import"./darkmodebg-C8gitIld.js";import"./LiveClock-DZcBc8i5.js";import"./dropdown-menu-CtK-pbB0.js";import"./circle-CYVKuV9a.js";import"./user-round-B4bN6HjC.js";import"./key-round-BlddUsqF.js";import"./PortalImage-BbpNRxd9.js";import"./popover-DEdUl_IA.js";import"./separator-B5XvKDXG.js";import"./bell-C5vVma6p.js";import"./circle-alert-sczy6Uk5.js";import"./formatDistanceToNow-BS9ia_--.js";import"./endOfMonth-dNhDrsSH.js";import"./settlersBranding-B5KDJ3fO.js";import"./rocket-Caxl3fhV.js";import"./tv-minimal-D4A3PPFB.js";import"./portalNavConfig-C4GEqJnP.js";import"./house-wtkLENOb.js";import"./wallet-DvcdSpiq.js";import"./door-open-C5_rd61i.js";import"./utensils-crossed-DN5plLEW.js";import"./newspaper-CNavWVwr.js";import"./heart-BPFyKUkJ.js";import"./flower-2-tVIDRMED.js";import"./message-circle-CJrNXJUk.js";import"./building-2-Nk2huxI0.js";import"./coffee-rTdsowb4.js";import"./shopping-basket-BNCr6aoj.js";import"./users-round-DZsl1kUg.js";import"./map-pin-DEg-YZMi.js";import"./handshake-CAGXZ2Vx.js";import"./circle-user-BKU7QE1X.js";import"./sticky-note-CCKGNJaT.js";import"./trophy-CetmQQEo.js";import"./clock-5zm-oHtJ.js";import"./mail-C6tfkY_l.js";import"./wrench-Bw5Exsal.js";import"./activity-DXsghgOT.js";import"./settings-2-CGmnlkBo.js";import"./bus-CZoRz5sV.js";import"./chart-column-Lvf8PWcm.js";import"./audio-lines-CLwpQQld.js";import"./portalAnalytics-DjFkLM7J.js";import"./search-T0VyIefC.js";import"./star-qjwcq55i.js";import"./agentDisplay-BbF1tvch.js";import"./pen-line-Bicku_l7.js";import"./prototypePortalAssets-DRKpqVfj.js";import"./car-8wW68Fif.js";import"./shopping-cart-9WYIsMA4.js";import"./gamepad-2-hmChFUOi.js";import"./palette-CbfG7AQ6.js";import"./circle-check-CkPJ4dRt.js";import"./file-question-DXaLJCB1.js";import"./VillageHelper-B9c_GwAn.js";import"./volume-2-BnUTl3at.js";import"./volume-x-SfaEfpUl.js";import"./compass-CDFQcs-U.js";import"./wand-sparkles-BYJCovUC.js";import"./eye-BYyEwTRq.js";import"./portalSectionHint-CmqkpozB.js";import"./square-pen-D6d6ez1J.js";import"./index-BOBh4OZm.js";import"./send-BQLfd1fb.js";import"./message-circle-question-CcWIATFu.js";
1import"./usePreloadBackgrounds-1AMK6OqS.js";import"./usePortalView-BLPwjql5.js";import"./useOperatorAdminAuth-rTm5JdCw.js";import"./AdminConfirmProvider-DQiZ5_dx.js";import"./user-plus-D6130qlo.js";import"./plus-CUoCthEr.js";import"./checkbox-DrqWENIb.js";import"./textarea-BRROE69Y.js";import"./queryFreshness-c8gK6bGm.js";import"./grip-vertical-D4sIRi2E.js";import"./adminTabVisibility-RKGFqpNq.js";import"./command-48v0Dcu0.js";import"./aucklandTime-Dkk2oYjF.js";import"./timer-CryMX378.js";import"./BarChart-BmndfUYp.js";import"./generateCategoricalChart-CbE748q6.js";import"./familyNotes-8D9vtaWk.js";import"./residentPropertyOptions-V46V2aUh.js";import"./phone-3sP_NsCN.js";import"./pencil-CNiM8VJV.js";import"./paw-print-C-RpNn8r.js";import"./accessibility-BhcpKZbd.js";import"./wifi-C2O1bQc1.js";import"./pin-xngoi13m.js";import"./calendar-BmfUhhm2.js";import"./calendar-check-_eoiXHa_.js";import"./shield-check-DdfSfcbh.js";import"./globe-Bj0lOFSW.js";import"./ellipsis-zwecaC52.js";import"./link-2-D4CoXOf2.js";import"./partnerAdminUrls-B8hM0sol.js";import"./layout-grid-B4uhkAVg.js";import"./list-D-SJaLGd.js";import"./circle-check-big-DHjNQ8m4.js";import"./circle-x-B0v3n1Tf.js";import"./isPast-CS82aBut.js";import"./FlyerCard-B5QDl4n1.js";import"./flyerTypes-9hssLjTL.js";import"./image-off-C7aXBmsc.js";import"./ContentEditorDialogs-D_M5sumg.js";import"./villageAdminApi-DOJto46D.js";import"./adminImageUpload-CiF90r15.js";import"./FlyerTemplatePicker-DORFj8LR.js";import"./ImageFocalPointPicker-CY8hNTzh.js";import"./move-DfXcQZfB.js";import"./ContentBuilderWizard-OFtUYcpy.js";import"./ContentPreviewModal-CjXpsRn-.js";import"./lightbulb-C1BwJnva.js";import"./arrow-left-CB-rKhHH.js";import"./image-up-BpSN1vfT.js";import"./book-open-text-Cyu0_dwP.js";import"./cake-cNdzcpqp.js";import"./heart-handshake-y3moal3U.js";import"./badge-check-6143vj-R.js";import"./FlyerDesignStep-BR4PX04T.js";import"./KanbanBoard-BrpvtdGY.js";import"./core.esm-B6W7VHjL.js";import"./calendar-range-BpmxMddK.js";import"./mouse-pointer-click-gXAhjGf5.js";import"./database-CpAunM-2.js";const j={support_request:"text-amber-600",fall_or_near_fall:"text-rose-600",low_mood:"text-rose-600",lonely_or_company_request:"text-sky-600"};function le({portalId:r,authToken:s,onNavigate:l,embedded:d=!1}){const c=x({queryKey:["wellbeing-plus",r,"alerts","admin","open"],queryFn:()=>B(s,"open"),enabled:!!r&&!!s,staleTime:6e4}),o=x({queryKey:["wellbeing-plus",r,"campaigns","admin"],queryFn:()=>O(s),enabled:!!r&&!!s,staleTime:5*6e4}),m=x({queryKey:["wellbeing-plus",r,"visits","admin"],queryFn:()=>L(s),enabled:!!r&&!!s,staleTime:5*6e4}),n=x({queryKey:["wellbeing-plus",r,"tasks","admin"],queryFn:()=>Q(s),enabled:!!r&&!!s,staleTime:6e4}),h=c.data?.items||[],t=new Date;t.setHours(0,0,0,0);const p=i=>h.filter(u=>u.alert_type===i&&new Date(u.created_at)>=t).length,F=[{key:"checkins",label:"Checked in today",value:c.data?.checkins_today??0,icon:w,tone:"text-emerald-600"},{key:"support",label:"Support requested",value:p("support_request"),icon:M,tone:j.support_request},{key:"mood",label:"Low mood signals",value:p("low_mood"),icon:$,tone:j.low_mood},{key:"falls",label:"Fall / near-fall today",value:p("fall_or_near_fall"),icon:U,tone:j.fall_or_near_fall},{key:"lonely",label:"Company requested",value:p("lonely_or_company_request"),icon:V,tone:j.lonely_or_company_request}],_=(o.data?.items||[]).filter(i=>i.is_active),N=m.data?.items||[],C=(n.data?.items||[]).slice(0,8),A=new Date().toISOString().slice(0,10);return e.jsxs("div",{className:"space-y-4",children:[!d&&e.jsx(k,{title:"Wellbeing+",description:"Village-wide wellbeing signals, alerts, resources, and campaigns.",icon:w}),e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-5",children:F.map(i=>e.jsx(g,{children:e.jsxs(b,{className:"p-4",children:[e.jsx(i.icon,{className:`h-5 w-5 mb-2 ${i.tone}`}),e.jsx("div",{className:"text-2xl font-semibold tabular-nums",children:i.value}),e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:i.label})]})},i.key))}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-2",children:[e.jsxs(g,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4 text-primary"})," Active campaigns"]})}),e.jsxs(b,{className:"space-y-2",children:[_.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No active campaigns."}):_.map(i=>e.jsxs("div",{className:"flex items-center justify-between text-sm border-b last:border-b-0 pb-2 last:pb-0",children:[e.jsx("span",{children:i.title}),(i.start_date||i.end_date)&&e.jsxs(q,{variant:"outline",children:[i.start_date||"â",i.end_date?` â ${i.end_date}`:""]})]},i.id)),e.jsxs(f,{size:"sm",variant:"outline",className:"w-full gap-1 mt-1",onClick:()=>
1l?.("admin-wellbeing-campaigns"),children:["Manage campaigns ",e.jsx(z,{className:"h-3.5 w-3.5"})]})]})]}),e.jsxs(g,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(Y,{className:"h-4 w-4 text-primary"})," Upcoming provider visits"]})}),e.jsx(b,{className:"space-y-2",children:N.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No provider visits scheduled."}):N.map(i=>e.jsxs("div",{className:"flex items-center justify-between text-sm border-b last:border-b-0 pb-2 last:pb-0",children:[e.jsx("span",{children:i.provider_name}),e.jsx("span",{className:"text-muted-foreground",children:i.visit_date||"TBC"})]},i.id))})]})]}),e.jsxs(g,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx(J,{className:"h-4 w-4 text-primary"})," Resident reminders due soon"]})}),e.jsxs(b,{className:"space-y-2",children:[C.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No resident reminders due in the next 7 days."}):C.map(i=>{const u=!!i.due_date&&i.due_date<A,T=i.portal_residents?`${i.portal_residents.first_name||""} ${i.portal_residents.last_initial||""}`.trim():"Resident";return e.jsxs("div",{className:"flex items-center justify-between text-sm border-b last:border-b-0 pb-2 last:pb-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"font-medium",children:T}),e.jsxs("span",{className:"text-muted-foreground",children:[" â ",i.title]})]}),e.jsx(q,{variant:"outline",className:u?"border-rose-300 text-rose-700 bg-rose-50 shrink-0":"shrink-0",children:u?"Overdue":i.due_date===A?"Due today":i.due_date})]},i.id)}),e.jsx("p",{className:"text-xs text-muted-foreground pt-1",children:"A gentle reminder to mention these during a visit or welfare check â residents manage them from their own Health To-Do list."})]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs(f,{variant:"outline",className:"group justify-start gap-2 h-auto py-3",onClick:()=>l?.("admin-wellbeing-alerts"),children:[e.jsx(S,{className:"h-4 w-4 text-primary transition-colors group-hover:text-accent-foreground"})," Open wellbeing alerts"]}),e.jsxs(f,{variant:"outline",className:"group justify-start gap-2 h-auto py-3",onClick:()=>l?.("admin-wellbeing-resources"),children:[e.jsx(X,{className:"h-4 w-4 text-primary transition-colors group-hover:text-accent-foreground"})," Manage resources"]}),e.jsxs(f,{variant:"outline",className:"group justify-start gap-2 h-auto py-3",onClick:()=>l?.("admin-wellbeing-topics"),children:[e.jsx(Z,{className:"h-4 w-4 text-primary transition-colors group-hover:text-accent-foreground"})," Manage self-care topics"]})]})]})}const W=[{id:"overview",label:"Overview"},{id:"welfare",label:"Welfare Checks"},{id:"goals",label:"Goals & Outcomes"},{id:"providers",label:"Providers"},{id:"alerts",label:"Alerts"},{id:"resources",label:"Resources"},{id:"topics",label:"Topics"},{id:"campaigns",label:"Campaigns"}];function fs({portalId:r,authToken:s,onNavigate:l}){const[d,c]=P.useState("overview"),o=x({queryKey:["wellbeing-plus",r,"schema-status","admin"],queryFn:()=>K(s),enabled:!!r&&!!s,staleTime:1/0,retry:!1}),m=o.data?.configured===!0,n=o.isError?W.filter(t=>["welfare","goals","providers"].includes(t.id)):W;P.useEffect(()=>{!n.some(t=>t.id===d)&&n[0]&&c(n[0].id)},[d,n]);const h=t=>{const p={"s-checkins":"welfare","s-goals":"goals","r-wellness-providers":"providers","admin-wellbeing-alerts":"alerts","admin-wellbeing-resources":"resources","admin-wellbeing-topics":"topics","admin-wellbeing-campaigns":"campaigns"};p[t]?c(p[t]):l?.(t)};return e.jsxs("div",{className:"space-y-5",children:[e.jsx(k,{title:"Wellbeing Plus",description:"One workspace for welfare checks, resident goals, providers, alerts, resources, topics, and campaigns.",icon:w}),o.isPending&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Checking Wellbeing Plus availabilityâ¦"}),o.isError&&e.jsx(ae,{audience:"admin",lookupFailed:!D(o.error)}),!o.isPending&&e.jsxs(H,{value:d,onValueChange:t=>c(t),children:[e.jsx(E,{className:"h-auto w-full flex-wrap justify-start gap-1 p-1.5",children:n.map(t=>e.jsx(R,{value:t.id,children:t.label},t.id))}),m&&e.jsx(a,{value:"overview",children:e.jsx(le,{portalId:r,authToken:s,onNavigate:h,embedded:!0})}),e.jsx(a,{value:"welfare",children:e.jsx(I,{portalId:r,authToken:s,onNavigate:l})}),e.jsx(a,{value:"goals",children:e.jsx(ee,{portalId:r,authToken:s})}),e.jsx(a,{value:"providers",children:e.jsx(ie,{portalId:r,authToken:s})}),m&&e.jsx(a,{value:"alerts",children:e.jsx(re,{portalId:r,authToken:s})}),m&&e.jsx(a,{value:"resources",children:e.jsx(se,{portalId:r,authToken:s})}),m&&e.jsx(a,{value:"topics",children:e.jsx(te,{portalId:r,authToken:s})}),m&&e.jsx(a,{value:"campaigns",children:e.jsx(oe,{portalId:r,authToken:s})})]})]})}export{fs as AdminWellbeingPlusHub};
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.