1import{a as x,j as e}from"./vendor-query-BxlSJxfF.js";import{E as _}from"./entity-icons-CSBLIDvu.js";import{n as A,be as F,p as T,u as Y,a as L,s as g,r as G,X as M,T as C,P as X}from"./index-DO0aGFYL.js";import{m as J,n as K,t as Q,a as V}from"./notification-link-CENdaziQ.js";import{u as Z,b as tt}from"./vendor-react-DdNhUK9-.js";import{A as et}from"./arrow-left-DNK6fh5x.js";import{S as rt}from"./settings-Cz62iviH.js";import{i as ot}from"./isToday-C7xv-GeZ.js";import{B as D}from"./bell-D4WR-0m3.js";import{A as it,m as nt}from"./vendor-motion-CdL2ySym.js";import{T as st}from"./trash-2-EocM2Uxl.js";import{C as N}from"./circle-check-BzeG-ygw.js";import{L as at}from"./lock-CWPApfun.js";import{L as ct}from"./lightbulb-CvX2ACIS.js";import{P as W}from"./party-popper-CcTxkyfz.js";import{M as P}from"./message-square-CLxZQpIa.js";import{U as lt}from"./user-plus-e-panZql.js";import{U}from"./users-4wDC2oQA.js";import{S as O}from"./star-B2GJQJHh.js";import{H as dt}from"./house-D1lgTCJ7.js";import"./clipboard-list-BWoyDXDg.js";import"./hard-hat-D6ZR2UoR.js";import"./globe-BblBOU8M.js";import"./building-2-CTs9_w7h.js";import"./vendor-supabase-Csx7YFID.js";import"./isSameDay-CF4KglHU.js";function ut(o,t,r){const d=A(o,r),a=A(t,r);return+d==+a}function mt(o,t){return ut(o,F(o),t)}/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const R=T("AlarmClock",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M12 9v4l2 2",key:"1c63tq"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const B=T("Siren",[["path",{d:"M7 18v-6a5 5 0 1 1 10 0v6",key:"pcx96s"}],["path",{d:"M5 21a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2z",key:"1b4s83"}],["path",{d:"M21 12h1",key:"jtio3y"}],["path",{d:"M18.5 4.5 18 5",key:"g5sp9y"}],["path",{d:"M2 12h1",key:"1uaihz"}],["path",{d:"M12 2v1",key:"11qlp1"}],["path",{d:"m4.929 4.929.707.707",key:"1i51kw"}],["path",{d:"M12 12v6",key:"3ahymv"}]]);/** 12 * @license lucide-react v0.462.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const pt=T("UserMinus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);function ft(o){const t=(o.type??"").toLowerCase();if(t==="urgent_match")return{Icon:B,tint:"bg-destructive/15",iconColor:"text-destructive"};if(t==="positions_filled"||t==="job_closed")return{Icon:N,tint:"bg-success/15",iconColor:"text-success"};if(t==="new_applicant")return{Icon:_.worker.Icon,tint:"bg-primary/15",iconColor:"text-primary"};if(t==="job_reminder")return{Icon:R,tint:"bg-sky-500/15",iconColor:"text-sky-500"};if(t==="job_expiring")return{Icon:C,tint:"bg-warning/15",iconColor:"text-warning"};if(t==="job_match")return{Icon:_.job.Icon,tint:"bg-primary/15",iconColor:"text-primary"};if(t==="job_needs_closeout")return{Icon:C,tint:"bg-warning/15",iconColor:"text-warning"};if(t==="job_invitation")return{Icon:at,tint:"bg-primary/15",iconColor:"text-primary"};if(t==="incoming_call")return{Icon:X,tint:"bg-primary/15",iconColor:"text-primary"};if(t==="profile_tip")return{Icon:ct,tint:"bg-sky-500/15",iconColor:"text-sky-500"};if(t==="phase_understaffed")return{Icon:_.phase.Icon,tint:"bg-destructive/15",iconColor:"text-destructive"};if(t==="application_accepted")return{Icon:W,tint:"bg-success/15",iconColor:"text-success"};if(t==="application_rejected"||t==="application_not_selected")return{Icon:M,tint:"bg-muted",iconColor:"text-muted-foreground"};if(t==="application_withdrawn"||t==="worker_removed")return{Icon:pt,tint:"bg-warning/15",iconColor:"text-warning"};if(t==="new_message"||t==="cold_message"||t==="support_dm")return{Icon:P,tint:"bg-sky-500/15",iconColor:"text-sky-500"};if(t==="connection_made")return{Icon:lt,tint:"bg-primary/15",iconColor:"text-primary"};if(t==="spot_reopened")return{Icon:U,tint:"bg-primary/15",iconColor:"text-primary"};if(t==="job_cancelled")return{Icon:M,tint:"bg-destructive/15",iconColor:"text-destructive"};if(t.startsWith("job_complete_review")||t.includes("review")||t.includes("endorsement"))return{Icon:O,tint:"bg-warning/15",iconColor:"text-warning"};if(t.startsWith("homeowner_lead"))return{Icon:dt,tint:"bg-primary/15",iconColor:"text-primary"};const r=(o.title??"").toLowerCase();return r.includes("accepted")||r.includes("ð")?{Icon:W,tint:"bg-success/15",iconColor:"text-success"}:r.includes("urgent")||r.includes("ð¨")?{Icon:B,tint:"bg-destructive/15",iconColor:"text-destructive"}:r.includes("tomorrow")||r.includes("â°")||r.includes("reminder")?{Icon:R,tint:"bg-sky-500/15",iconColor:"text-sky-500"}:r.includes("positions filled")||r.includes("all positions")?{Icon:N,tint:"bg-success/15",iconColor:"text-success"}:r.includes("starts tomorrow")||r.includes("expiring")||r.includes("â ")?{Icon:C,tint:"bg-warning/15",iconColor:"text-warning"}:r.includes("applicant")||r.includes("ð")||r.includes("withdrew")?{Icon:U,tint:"bg-primary/15",iconColor:"text-primary"}:r.includes("review")||r.includes("endorsed")||r.includes("â")?{Icon:O,tint:"bg-warning/15",iconColor:"text-warning"}:r.includes("message")||r.includes("ð¬")?{Icon:P,tint:"bg-sky-500/15",iconColor:"text-sky-500"}:r.includes("completed")||r.includes("closed")||r.includes("â ")||r.includes("shift confirmed")?{Icon:N,tint:"bg-success/15",iconColor:"text-success"}:{Icon:D,tint:"bg-muted",iconColor:"text-muted-foreground"}}function xt(o){const t=[],r=[],d=[];for(const a of o){const u=new Date(a.created_at);ot(u)?t.push(a):mt(u,{weekStartsOn:1}
16)?r.push(a):d.push(a)}return{today:t,week:r,earlier:d}}function Ht(){var S,q;const{user:o}=Y(),{t}=L(),r=Z(),a=tt().pathname.startsWith("/contractor"),[u,l]=x.useState([]),[y,b]=x.useState(!0),[m,p]=x.useState(0),h=x.useCallback(i=>i?a?i.startsWith("/messages")?i.replace("/messages","/contractor/messages"):i==="/jobs"||i==="/worker/jobs"?"/contractor/jobs":i:i.startsWith("/contractor/messages")?i.replace("/contractor/messages","/messages"):i==="/contractor/jobs"?"/jobs":i.startsWith("/contractor/")?i.replace("/contractor",""):i:null,[a]),w=x.useCallback(i=>{const s=(i.type??"").toLowerCase(),c=i.data??{},n=c.job_id??void 0,f=c.application_id??void 0,E=c.worker_id??void 0;return s==="new_message"||s==="connection_made"?J(i)??(a?"/contractor/messages":"/messages"):s==="profile_tip"?"/worker/profile":s==="incoming_call"&&n?`/jobs/${n}`:s==="job_closed"?a?"/contractor/pending-reviews":"/pending-reviews":s==="job_needs_closeout"&&n?`/contractor/jobs/${n}`:s==="job_complete_review_worker"&&n?`/jobs/${n}?review=pending`:s==="job_complete_review_contractor"&&n?`/contractor/jobs/${n}?review=pending`:(s==="new_applicant"||s==="new_applicants_multi")&&n?f?`/contractor/jobs/${n}?applicant=${f}`:`/contractor/jobs/${n}`:n?a?`/contractor/jobs/${n}`:`/jobs/${n}`:E&&a?`/contractor/workers/${E}`:null},[a]),$=x.useCallback(async()=>{if(!o)return;b(!0);const[{data:i},{count:s}]=await Promise.all([g.from("notifications").select("*").eq("user_id",o.id).order("created_at",{ascending:!1}).limit(100),g.from("notifications").select("id",{count:"exact",head:!0}).eq("user_id",o.id).eq("read",!1)]);i&&l(i),p(s??0),b(!1)},[o]);x.useEffect(()=>{if($(),!o)return;const i=g.channel(`user-notifications-page-${Math.random().toString(36).slice(2,10)}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"notifications",filter:`user_id=eq.${o.id}`},s=>{const c=s.new;l(n=>[c,...n]),c.read||p(n=>n+1)}).on("postgres_changes",{event:"UPDATE",schema:"public",table:"notifications",filter:`user_id=eq.${o.id}`},s=>{const c=s.new;l(n=>n.map(f=>f.id===c.id?{...f,...c}:f))}).on("postgres_changes",{event:"DELETE",schema:"public",table:"notifications",filter:`user_id=eq.${o.id}`},s=>{const c=s.old;l(n=>n.filter(f=>f.id!==c.id))}).subscribe();return()=>{g.removeChannel(i)}},[o,$]);const z=async()=>{!o||m===0||(await g.from("notifications").update({read:!0}).eq("user_id",o.id).eq("read",!1),l(i=>i.map(s=>({...s,read:!0}))),p(0))},j=async i=>{const s=u.some(c=>c.id===i&&!c.read);l(c=>c.filter(n=>n.id!==i)),s&&p(c=>Math.max(0,c-1)),await g.from("notifications").delete().eq("id",i)},k=async i=>{i.read||(await g.from("notifications").update({read:!0}).eq("id",i.id),l(c=>c.map(n=>n.id===i.id?{...n,read:!0}:n)),p(c=>Math.max(0,c-1)));const s=h(K(i))??h(w(i));s&&r(s)},v=x.useMemo(()=>xt(u),[u]),H=a?"/contractor":"/worker";return e.jsxs("div",{className:"min-h-screen pb-24",children:[e.jsx("div",{className:"sticky top-0 z-20 bg-background/85 backdrop-blur-md border-b border-border/60",children:e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3",children:[e.jsx("button",{onClick:()=>r(H),"aria-label":t.aria.back,className:"p-1.5 rounded-md hover:bg-secondary transition-colors",children:e.jsx(et,{className:"w-5 h-5 text-foreground"})}),e.jsxs("h1",{className:"font-display text-lg font-bold text-foreground flex-1",children:["Notifications",m>0&&e.jsx("span",{className:"ml-2 text-xs font-semibold text-primary align-middle",children:((q=(S=t.notifications).newBadge)==null?void 0:q.call(S,m))??`${m} new`})]}),m>0&&e.jsx("button",{onClick:z,className:"text-xs text-primary hover:text-primary/80 font-semibold transition-colors",children:t.notifications.markAllRead}),e.jsx("button",{onClick:()=>r(a?"/contractor/settings":"/worker/settings"),"aria-label":t.aria.notificationPreferences,className:"p-1.5 rounded-md hover:bg-secondary transition-colors",children:e.jsx(rt,{className:"w-5 h-5 text-muted-foreground"})})]})}),e.jsx("div",{className:"px-4 py-4 space-y-6 max-w-2xl mx-auto",children:y?e.jsx("div",{className:"py-12 text-center text-sm text-muted-foreground",children:"Loadingâ¦"}):u.length===0?e.jsx(bt,{isContractor:a}):e.jsxs(e.Fragment,{children:[e.jsx(I,{label:"Today",items:v.today,onOpen:k,onDismiss:j}),e.jsx(I,{label:"This Week",items:v.week,onOpen:k,onDismiss:j}),e.jsx(I,{label:"Earlier",items:v.earlier,onOpen:k,onDismiss:j})]})})]})}function I({label:o,items:t,onOpen:r,onDismiss:d}){return t.length===0?null:e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-caption uppercase tracking-wider font-semibold text-muted-foreground px-1",children:o}),e.jsx("div",{className:"space-y-2",children:e.jsx(it,{initial:!1,children:t.map(a=>e.jsx(gt,{n:a,onOpen:r,onDismiss:d},a.id))})})]})}function gt({n:o,onOpen:t,onDismiss:r}){const{Icon:d,tint:a,iconColor:u}=ft(o),{t:l}=L(),y=Q(o.title,l),b=V(o.body,l),m=!o.read,p=o.type==="new_applicant"&&o.data&&typeof o.data=="object"?Number(o.data.applicant_count??0):0;return e.jsxs(nt.div,{layout:!0,initial:{opacity:0,y:6}
16,animate:{opacity:1,y:0},exit:{opacity:0,x:-120,transition:{duration:.18}},drag:"x",dragConstraints:{left:-160,right:0},dragElastic:.15,onDragEnd:(h,w)=>{w.offset.x<-90&&r(o.id)},className:"relative",children:[e.jsx("div",{className:"absolute inset-0 rounded-xl bg-destructive/15 flex items-center justify-end pr-4 pointer-events-none",children:e.jsx(st,{className:"w-4 h-4 text-destructive"})}),e.jsxs("button",{type:"button",onClick:()=>t(o),className:`relative w-full text-left rounded-xl border transition-all flex items-start gap-3 p-3 ${m?"bg-primary/5 dark:bg-primary/10 border-l-[3px] border-l-primary border-y border-r border-primary/20":"bg-card border-border/60 hover:border-primary/30"}`,children:[e.jsx("span",{className:`w-9 h-9 rounded-full flex items-center justify-center shrink-0 ${a}`,children:e.jsx(d,{className:`w-4 h-4 ${u}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("p",{className:`text-sm leading-snug flex-1 ${m?"font-bold text-foreground":"font-medium text-foreground/90"}`,children:[y,p>1&&e.jsx("span",{className:"ml-2 inline-flex items-center justify-center min-w-[18px] h-[18px] px-1.5 rounded-full bg-primary text-primary-foreground text-micro font-bold align-middle",children:p})]}),e.jsx("span",{className:"text-micro text-muted-foreground shrink-0 mt-0.5",children:G(o.created_at)})]}),b&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-2",children:b})]}),e.jsx("button",{type:"button",onClick:h=>{h.stopPropagation(),r(o.id)},"aria-label":l.aria.dismissNotification,className:"p-1 -m-1 rounded text-muted-foreground hover:text-destructive transition-colors",children:e.jsx(M,{className:"w-3.5 h-3.5"})})]})]})}function bt({isContractor:o}){const{t}=L(),r=o?"No notifications yet â match workers to start finding workers":"No notifications yet â match with a job to get started";return e.jsxs("div",{className:"py-16 text-center space-y-3",children:[e.jsx("div",{className:"mx-auto w-14 h-14 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(D,{className:"w-7 h-7 text-primary"})}),e.jsx("h3",{className:"font-display text-base font-bold text-foreground",children:t.notifications.allCaughtUp??"You're all caught up!"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-xs mx-auto",children:r})]})}export{Ht 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.