PageSourceSearch

https://delicieux-france-website-app--cleaverandfire.replit.app/assets/admin-dashboard-99rFF6CJ.js

js delicieux-france-website-app--cleaverandfire.replit.app collected 2026-10-03 03:51:00 UTC 89,367 bytes, 4 lines download raw bytes

1import{x as Nt,u as vt,bi as yt,bs as as,ap as rs,r,I as te,b8 as se,aq as z,ah as $,j as e,bl as Ze,B as O,b0 as et,b3 as tt,bt as ns,ba as st,L as E,E as is,bu as at,b9 as de,bq as Pe,K as U,au as rt,m as L,M as wt,P as ls,ak as os,a7 as Re,k as nt,p as me,D as cs,bh as it,an as lt,q as ot,o as we,as as ds,$ as ms,a$ as hs,b1 as Oe,b2 as ye,i as xs,W as he,X as K,aW as ps,bv as ct,bg as us,bf as bs,J as gs,aS as Ae,l as fs}from"./index-DVNF8J8H.js";import{A as Ns}from"./admin-breadcrumb-BY0HPwvt.js";import{A as vs}from"./admin-dash-tabs-D3aIAnsp.js";import{A as ys}from"./admin-monthly-calendar-ROZM3IIY.js";import{R as xe}from"./refresh-cw-v6da92lm.js";import{L as dt}from"./lock-open-CqDCwxjl.js";import{L as Te}from"./layout-grid-wX_hnV5r.js";import{G as mt}from"./grip-vertical-Buyd5WZB.js";import{M as ht}from"./monitor-BJqdHYWT.js";import{I as jt}from"./inbox-DMybd_BO.js";import{B as ws}from"./box-DLg48Zcu.js";import{C as xt}from"./calendar-days-DJARjOmE.js";import{A as js}from"./arrow-right-left-KdfalaZB.js";import{G as zs}from"./gift-Bemv9i3c.js";import{T as ks}from"./trash-2-C_tTPs5j.js";import{C as $e}from"./chevron-up-D5g5zfm0.js";import{P as Ss}from"./printer-o2UjkfHd.js";
1import"./chevron-left-94v0zBry.js";const Cs=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],zt=Nt("at-sign",Cs);const Is=[["path",{d:"M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z",key:"qazsjp"}],["path",{d:"M15 3v4a2 2 0 0 0 2 2h4",key:"40519r"}]],pt=Nt("sticky-note",Is),ut=[{value:"strategy",label:"Long-term Strategy"},{value:"marketing",label:"Marketing"},{value:"operations",label:"Operations"},{value:"technical",label:"Technical"},{value:"logistics",label:"Logistics & Delivery"},{value:"culinary",label:"Culinary Operations"},{value:"hr",label:"Human Resources"},{value:"documents",label:"Documents & Legal"},{value:"communications",label:"Communications"},{value:"general",label:"General"}],Ds=[{key:"page_transatlantic_visible",label:"Transatlantic",desc:"International flights page"}];function Es(){const s=yt(),o=se(),{data:N={}}=z({queryKey:["/api/site-settings"]}),h=$({mutationFn:async({key:p,value:b})=>{const f=await fetch(`/api/site-settings/${p}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:b})});if(!f.ok)throw new Error("Failed to update setting");return f.json()},onSuccess:()=>{o.invalidateQueries({queryKey:["/api/site-settings"]})}});return e.jsx("div",{className:"space-y-3",children:Ds.map(p=>{const b=N[p.key]!=="false";return e.jsxs("div",{className:"flex items-center justify-between bg-zinc-800/50 rounded-lg p-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-white",children:p.label}),e.jsx("p",{className:"text-xs text-zinc-400",children:p.desc})]}),s&&e.jsx("button",{onClick:()=>h.mutate({key:p.key,value:b?"false":"true"}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${b?"bg-green-600":"bg-zinc-600"}`,"data-testid":`toggle-${p.key}`,children:e.jsx("span",{className:`inline-block h-4 w-4 rounded-full bg-white transition-transform ${b?"translate-x-6":"translate-x-1"}`})})]},p.key)})})}function Ps(s,o){const N=parseInt(localStorage.getItem(`dfk_seen_${s}`)??"-1",10);return N!==-1&&o>N}function Rs(s,o){localStorage.setItem(`dfk_seen_${s}`,String(o))}function ee(s,o){localStorage.getItem(`dfk_seen_${s}`)===null&&o>=0&&localStorage.setItem(`dfk_seen_${s}`,String(o))}function ia(){const{t:s}=vt(),o=yt(),N=as(),[,h]=rs();r.useEffect(()=>{N==="flight_ops"&&h("/admin/flight-ops",{replace:!0})},[N,h]);const{toast:p}=te(),b=se(),[f,v]=r.useState(!1),[m,u]=r.useState({name:"",email:"",phone:"",emailEnabled:!0,smsEnabled:!0}),[k,x]=r.useState(!1),[c,w]=r.useState(null),[y,d]=r.useState({title:"",content:"",category:"general"}),[l,R]=r.useState(!0),[T,A]=r.useState(!0),[M,pe]=r.useState(!1),[je,ae]=r.useState(!1),[re,a]=r.useState("");r.useCallback(async t=>{try{const n=await fetch(t,{credentials:"include"});if(!n.ok)throw new Error(`HTTP ${n.status}`);const g=await n.blob(),j=URL.createObjectURL(g);window.open(j,"_blank"),setTimeout(()=>URL.revokeObjectURL(j),6e4)}catch(n){p({title:s("Error"),description:n.message,variant:"destructive"})}},[p,s]);const{data:C=[],refetch:ze}=z({queryKey:["/api/admin/conversations"],queryFn:async()=>{const t=await fetch("/api/admin/conversations");if(!t.ok)throw new Error("Failed to fetch conversations");return t.json()},refetchInterval:15e3}),{data:kt,refetch:St}=z({queryKey:["/api/orders"],queryFn:async()=>{const t=await fetch("/api/orders");if(!t.ok)throw new Error("Failed to fetch orders");return t.json()},refetchInterval:3e4}),{data:B=[]}=z({queryKey:["/api/admin/notification-recipients"],queryFn:async()=>{const t=await fetch("/api/admin/notification-recipients");if(!t.ok)throw new Error("Failed to fetch recipients");return t.json()}}),Le=$({mutationFn:async()=>{const t=await fetch("/api/admin/notification-recipients",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:m.name,email:m.email||null,phone:m.phone||null,emailEnabled:m.emailEnabled?"true":"false",smsEnabled:m.smsEnabled?"true":"false"})});if(!t.ok)throw new Error("Failed to add recipient");return t.json()},onSuccess:()=>{p({title:s("Added"),description:s("Notification recipient added.")}),b.invalidateQueries({queryKey:["/api/admin/notification-recipients"]}
1),u({name:"",email:"",phone:"",emailEnabled:!0,smsEnabled:!0})}}),Ct=$({mutationFn:async t=>{if(!(await fetch(`/api/admin/notification-recipients/${t}`,{method:"DELETE"})).ok)throw new Error("Failed to delete recipient")},onSuccess:()=>{p({title:s("Removed"),description:s("Notification recipient removed.")}),b.invalidateQueries({queryKey:["/api/admin/notification-recipients"]})}}),{data:It}=z({queryKey:["/api/admin/notes"],queryFn:async()=>{const t=await fetch("/api/admin/notes");if(!t.ok)throw new Error("Failed to fetch notes");return t.json()}}),{data:Dt}=z({queryKey:["/api/crew-program/inquiries"],queryFn:async()=>{const t=await fetch("/api/crew-program/inquiries");if(!t.ok)throw new Error("Failed to fetch crew inquiries");return t.json()}}),qe=$({mutationFn:async t=>{const n=await fetch("/api/admin/notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error("Failed to create note");return n.json()},onSuccess:()=>{p({title:s("Note Created"),description:s("Your note has been saved.")}),b.invalidateQueries({queryKey:["/api/admin/notes"]}),x(!1),d({title:"",content:"",category:"general"})}}),ke=$({mutationFn:async({id:t,...n})=>{const g=await fetch(`/api/admin/notes/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!g.ok)throw new Error("Failed to update note");return g.json()},onSuccess:()=>{p({title:s("Note Updated")}),b.invalidateQueries({queryKey:["/api/admin/notes"]}),w(null),d({title:"",content:"",category:"general"})}}),Et=$({mutationFn:async t=>{if(!(await fetch(`/api/admin/notes/${t}`,{method:"DELETE"})).ok)throw new Error("Failed to delete note")},onSuccess:()=>{p({title:s("Note Deleted")}),b.invalidateQueries({queryKey:["/api/admin/notes"]})}}),Fe=It?.notes||[],Pt=Fe.filter(t=>t.pinned==="true"),Rt=Fe.filter(t=>t.pinned!=="true"),Ke=[...Pt,...Rt],ne=Dt?.inquiries||[];ne.slice(0,5);const{data:Ot}=z({queryKey:["/api/admin/inventory/low-stock-count"],refetchInterval:6e4}),ie=Ot?.count??0,{data:At}=z({queryKey:["/api/help/open-blocker-count"],refetchInterval:6e4}),W=At?.count??0,{data:Tt}=z({queryKey:["/api/admin/charter-missions/at-risk"],refetchInterval:12e4,select:t=>({count:t?.count??0})}),G=Tt?.count??0,{data:$t}=z({queryKey:["/api/admin/recall/new-count"],refetchInterval:12e4}),J=$t?.count??0,{data:Lt,refetch:_e}=z({queryKey:["/api/admin/delivery-acceptances/needs-review-count"],queryFn:async()=>{const t=await fetch("/api/admin/delivery-acceptances/needs-review-count",{credentials:"include"});return t.ok?t.json():{count:0,orderIds:[]}},refetchInterval:12e4}),Q=Lt?.count??0,qt=r.useRef(null);r.useEffect(()=>{const t=window.location.protocol==="https:"?"wss:":"ws:",n=new WebSocket(`${t}//${window.location.host}/ws/kds`);return qt.current=n,n.onopen=()=>{n.send(JSON.stringify({type:"subscribe",topic:"all"}))},n.onmessage=g=>{try{const j=JSON.parse(g.data);if(j.type==="charter:delivery:accepted"){const P=j.data;(P.condition==="refused"||P.condition==="partial")&&_e()}}catch{}},()=>{n.close()}},[_e]);const{data:Ue}=z({queryKey:["/api/admin/pricing-structures"],staleTime:5*6e4}),{data:Ft}=z({queryKey:["/api/admin/procurement-alerts","summary"],queryFn:async()=>(await fetch("/api/admin/procurement-alerts?days=7")).json(),staleTime:300*1e3}),ue=Ft?.summary,{data:Kt}=z({queryKey:["/api/admin/low-rated-missions"],refetchInterval:300*1e3,staleTime:300*1e3}),Se=Kt?.count??0,{data:_t}=z({queryKey:["/api/admin/pricing/needs-prices"],refetchInterval:300*1e3,staleTime:300*1e3}),Me=_t?.count??0,be=kt?.orders||[],q=C.filter(t=>t.status==="escalated").length,ge=C.length,H=be.filter(t=>t.status==="pending").length,le=be.filter(t=>{const n=new Date().toISOString().split("T")[0];return t.deliveryDate===n}).length,Ce=new Date;Ce.setDate(Ce.getDate()-5);const Ut=Ce.toISOString().split("T")[0],fe=be.filter(t=>t.deliveryDate&&t.deliveryDate>=Ut).length;C.filter(t=>t.status==="escalated").sort((t,n)=>new Date(n.createdAt).getTime()-new Date(t.createdAt).getTime()).slice(0,3),be.filter(t=>t.status==="pending").sort((t,n)=>new Date(n.createdAt).getTime()-new Date(t.createdAt).getTime()).slice(0,3);const[,Mt]=r.useState(0);r.useEffect(()=>{ee("orders",fe),ee("pending",H),ee("today",le),ee("escalated",q),ee("chats",ge),ee("crew",ne.length)},[fe,H,le,q,ge,ne.length]);function V(t,n){return{hasNew:Ps(t,n),markSeen:()=>{Rs(t,n),Mt(g=>g+1)}}}const Be=V("orders",fe),Bt=V("pending",H);V("today",le);const Ie=V("escalated",q),We=V("chats",ge),Ge=V("crew",ne.length),De=["card-chat-dashboard","card-escalated-dashboard","card-topsheets-dashboard","card-crew-inquiries-dashboard","card-bcards-dashboard","card-trello-dashboard","card-kds-dashboard","card-menu-cards-dashboard","card-email-orders-dashboard","card-crew-feedback","card-staff-dashboard","card-permissions-dashboard","card-inventory-dashboard"],[Je,Qe]=r.useState(()=>{try{return JSON.parse(localStorage.getItem("dfk-dash-card-order")??"null")??De}catch{return De}}),[F,Wt]=r.useState(()=>localStorage.getItem("dfk-dash-cards-locked")!=="false"),[Y,He]=r.useState(()=>localStorage.getItem("dfk-dash-daily-ops-reorder")==="true"),X=r.useRef(null),_=r.useRef(!1);function Gt(){Wt(t=>(localStorage.setItem("dfk-dash-cards-locked",String(!t)),!t))}function Jt(){He(t=>{const n=!t;return localStorage.setItem("dfk-dash-daily-ops-reorder",String(n)),n})}function Qt(t){X.current=t,_.current=!1}function Ht(t,n=[]){!X.current||X.current===t||(_.current=!0,Qe(g=>{const j=[...g,...n.filter(I=>!g.includes(I))],P=j.indexOf(X.current),S=j.indexOf(t);return P===-1||S===-1?g:(j.splice(P,1),j.splice(S,0,X.current),localStorage.setItem("dfk-dash-card-order",JSON.stringify(j)),j)}))}function Vt(){X.current=null}const oe=["billing","loan-tracker","escalated-chats","orders","pending-orders","client-menus","menus"],Ve=["orders","pending-orders","billing","menus","escalated-chats"],Ye=["escalated-chats","pen
1ding-orders","orders","billing","menus"],Xe=t=>{if(!Array.isArray(t))return oe;const n=t.filter(g=>typeof g=="string");return n.length===Ve.length&&n.every((g,j)=>g===Ve[j])||n.length===Ye.length&&n.every((g,j)=>g===Ye[j])?oe:[...n,...oe.filter(g=>!n.includes(g))]},[Yt,Ne]=r.useState(()=>{try{return Xe(JSON.parse(localStorage.getItem("dfk-dash-panel-order")??"null"))}catch{return oe}}),Z=r.useRef(null),{data:ce}=z({queryKey:["/api/admin/dashboard-layout"],queryFn:async()=>{const t=await fetch("/api/admin/dashboard-layout");if(!t.ok)throw new Error("Failed to fetch layout");return t.json()},staleTime:1/0});r.useEffect(()=>{if(ce?.layout&&Array.isArray(ce.layout)&&ce.layout.length>0){const t=Xe(ce.layout);Ne(t),localStorage.setItem("dfk-dash-panel-order",JSON.stringify(t))}},[ce]);const Xt=$({mutationFn:async t=>{const n=await fetch("/api/admin/dashboard-layout",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({layout:t})});if(!n.ok)throw new Error("Failed to save layout");return n.json()}}),Ee=$({mutationFn:async()=>{const t=await fetch("/api/admin/dashboard-layout",{method:"DELETE"});if(!t.ok)throw new Error("Failed to reset layout");return t.json()},onSuccess:()=>{Ne(oe),Qe(De),He(!1),localStorage.removeItem("dfk-dash-panel-order"),localStorage.removeItem("dfk-dash-card-order"),localStorage.removeItem("dfk-dash-daily-ops-reorder"),b.setQueryData(["/api/admin/dashboard-layout"],{layout:null}),p({title:s("Layout reset"),description:s("Dashboard is back to default order.")})},onError:()=>{p({title:s("Error"),description:s("Could not reset layout."),variant:"destructive"})}});function Zt(t){Z.current=t,_.current=!1}function es(t){!Z.current||Z.current===t||(_.current=!0,Ne(n=>{const g=[...n],j=g.indexOf(Z.current),P=g.indexOf(t);return j===-1||P===-1?n:(g.splice(j,1),g.splice(P,0,Z.current),localStorage.setItem("dfk-dash-panel-order",JSON.stringify(g)),g)}))}function ts(){Z.current=null,_.current&&Ne(t=>(Xt.mutate(t),t))}const ss=()=>{ze(),St(),p({title:s("Refreshed"),description:s("All data refreshed.")})},ve=[Se,J,ue?.lowStockCount??0,Q,ie,G,W].filter(t=>t>0).length;return e.jsx("div",{className:"min-h-screen bg-black text-white",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-3 sm:px-4 pt-20 pb-8",children:[e.jsx(Ns,{items:[{label:"Dashboard"}]}),e.jsxs("div",{className:"flex flex-col items-start gap-3 sm:flex-row sm:items-center sm:justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-gradient-to-br from-[#d4af37] to-[#aa8a2e] rounded-lg",children:e.jsx(Ze,{className:"w-5 h-5 text-black"})}),e.jsx("h1",{className:"text-xl font-display font-bold",children:s("Operations Dashboard")})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[o&&e.jsxs(O,{onClick:()=>v(!f),variant:"outline",size:"sm",className:"border-zinc-700 hover:bg-zinc-800","data-testid":"button-settings",children:[e.jsx(et,{className:"w-3.5 h-3.5 mr-1.5"}),s("Settings")]}),e.jsxs(O,{onClick:ss,variant:"outline",size:"sm",className:"border-zinc-700 hover:bg-zinc-800","data-testid":"button-refresh-all",children:[e.jsx(xe,{className:"w-3.5 h-3.5 mr-1.5"}),s("Refresh")]}),e.jsx(O,{onClick:Gt,variant:"outline",size:"sm",className:`border-zinc-700 hover:bg-zinc-800 ${F?"":"border-amber-500/40 text-amber-400"}`,"data-testid":"btn-toggle-card-lock-header",title:F?"Unlock to drag & reorder all panels and cards":"Lock layout",children:F?e.jsxs(e.Fragment,{children:[e.jsx(tt,{className:"w-3.5 h-3.5 mr-1.5"}),s("Locked")]}):e.jsxs(e.Fragment,{children:[e.jsx(dt,{className:"w-3.5 h-3.5 mr-1.5 text-amber-400"}),s("Unlocked")]})}),e.jsx(ns,{})]})]}),e.jsx(vs,{}),e.jsx("div",{className:`mb-4 rounded-xl border px-3 py-2.5 ${ve>0?"border-amber-500/20 bg-amber-500/[0.04]":"border-zinc-800 bg-zinc-900/60"}`,"data-testid":"panel-dashboard-alerts",children:e.jsxs("div",{className:"flex items-center gap-2.5 overflow-x-auto pb-1",children:[e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(st,{className:`w-3.5 h-3.5 ${ve>0?"text-amber-400":"text-zinc-500"}`}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-zinc-500",children:ve>0?"Needs attention":"Operations clear"})]}),e.jsx("div",{className:"h-4 w-px bg-zinc-800 shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[Se>0&&e.jsx(E,{href:"/admin/kitchen-report",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-red-500/20 bg-red-500/10 px-2.5 py-1 text-xs text-red-300 whitespace-nowrap hover:bg-red-500/20 transition-colors","data-testid":"alert-low-rated-missions",children:[e.jsx(is,{className:"w-3 h-3"})," ",Se," low-rated"]})}),J>0&&e.jsx(E,{href:"/admin/recall-log",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-red-500/25 bg-red-500/15 px-2.5 py-1 text-xs font-semibold text-red-200 whitespace-nowrap hover:bg-red-500/25 transition-colors","data-testid":"alert-new-recalls",children:[e.jsx(at,{className:"w-3 h-3"}
1)," ",J," recall",J!==1?"s":""]})}),ue&&ue.lowStockCount>0&&e.jsx(E,{href:"/admin/procurement-alerts",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-amber-500/20 bg-amber-500/10 px-2.5 py-1 text-xs text-amber-300 whitespace-nowrap hover:bg-amber-500/20 transition-colors","data-testid":"alert-procurement",children:[e.jsx(de,{className:"w-3 h-3"})," ",ue.lowStockCount," to procure"]})}),Q>0&&e.jsx(E,{href:"/admin/orders",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-rose-500/20 bg-rose-500/10 px-2.5 py-1 text-xs text-rose-300 whitespace-nowrap hover:bg-rose-500/20 transition-colors","data-testid":"alert-needs-review",children:[e.jsx(de,{className:"w-3 h-3"})," ",Q," delivery review",Q!==1?"s":""]})}),G>0&&e.jsx(E,{href:"/admin/charter-missions",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-violet-500/20 bg-violet-500/10 px-2.5 py-1 text-xs text-violet-300 whitespace-nowrap hover:bg-violet-500/20 transition-colors","data-testid":"alert-charter-risk",children:[e.jsx(Pe,{className:"w-3 h-3"})," ",G," mission",G!==1?"s":""," at risk"]})}),ie>0&&e.jsx(E,{href:"/admin/ingredient-stock",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-sky-500/20 bg-sky-500/10 px-2.5 py-1 text-xs text-sky-300 whitespace-nowrap hover:bg-sky-500/20 transition-colors","data-testid":"alert-low-stock",children:[e.jsx(U,{className:"w-3 h-3"})," ",ie," low stock"]})}),W>0&&e.jsx(E,{href:"/admin/help-inbox",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-rose-500/20 bg-rose-500/10 px-2.5 py-1 text-xs text-rose-300 whitespace-nowrap hover:bg-rose-500/20 transition-colors","data-testid":"alert-help-blockers",children:[e.jsx(rt,{className:"w-3 h-3"})," ",W," help request",W!==1?"s":""]})}),ve===0&&e.jsx("span",{className:"text-xs text-zinc-500",children:"No urgent items are waiting for review."})]})]})}),e.jsx(ys,{className:"mb-5"}),f&&e.jsxs(L.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"mb-6 bg-zinc-900/50 border border-zinc-800 rounded-lg p-4 sm:p-6",children:[e.jsxs("h2",{className:"text-xl font-semibold mb-4 flex items-center gap-2",children:[e.jsx(st,{className:"w-5 h-5"}),s("Notification Recipients")]}),e.jsx("p",{className:"text-zinc-400 text-sm mb-6",children:s("Add team members to receive notifications for escalated chats AND new orders.")}),B.length>0&&e.jsxs("div",{className:"mb-6 space-y-3",children:[e.jsxs("h3",{className:"text-sm font-medium text-zinc-300",children:[s("Current Recipients")," (",B.length,")"]}),B.map(t=>e.jsxs("div",{className:"flex items-start gap-3 sm:items-center sm:justify-between bg-zinc-800/50 rounded-lg p-3 sm:p-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:t.name}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 mt-1 text-sm text-zinc-400",children:[t.email&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(wt,{className:"w-3 h-3"}),t.email,t.emailEnabled==="true"&&e.jsxs("span",{className:"text-green-400 text-xs ml-1",children:["(",s("on"),")"]})]}),t.phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ls,{className:"w-3 h-3"}),t.phone,t.smsEnabled==="true"&&e.jsxs("span",{className:"text-green-400 text-xs ml-1",children:["(",s("on"),")"]})]})]})]}),e.jsx(O,{variant:"ghost",size:"sm",onClick:()=>Ct.mutate(t.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10","data-testid":`button-delete-recipient-${t.id}`,children:e.jsx(os,{className:"w-4 h-4"})})]},t.id))]}),e.jsxs("div",{className:"border-t border-zinc-800 pt-6",children:[e.jsxs("h3",{className:"text-sm font-medium text-zinc-300 mb-4 flex items-center gap-2",children:[e.jsx(Re,{className:"w-4 h-4"}),s("Add New Recipient")]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-4",children:[e.jsx("input",{type:"text",value:m.name,onChange:t=>u({...m,name:t.target.value}),placeholder:s("Name"),className:"bg-zinc-800 border border-zinc-700 rounded-lg px-4 py-2.5 text-white placeholder-zinc-500 focus:outline-none focus:border-zinc-500","data-testid":"input-recipient-name"}),e.jsx("input",{type:"email",value:m.email,onChange:t=>u({...m,email:t.target.value}),placeholder:s("Email"),className:"bg-zinc-800 border border-zinc-700 rounded-lg px-4 py-2.5 text-white placeholder-zinc-500 focus:outline-none focus:border-zinc-500","data-testid":"input-recipient-email"}),e.jsx("input",{type:"tel",value:m.phone,onChange:t=>u({...m,phone:t.target.value}),placeholder:s("Phone (optional)"),className:"bg-zinc-800 border border-zinc-700 rounded-lg px-4 py-2.5 text-white placeholder-zinc-500 focus:outline-none focus:border-zinc-500","data-testid":"input-recipient-phone"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:m.emailEnabled,onChange:t=>u({...m,emailEnabled:t.target.checked}),className:"w-4 h-4 rounded border-zinc-600 bg-zinc-800 text-[#d4af37]","data-testid":"checkbox-email-en
1abled"}),e.jsx("span",{className:"text-sm text-zinc-300",children:s("Email Notifications")})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:m.smsEnabled,onChange:t=>u({...m,smsEnabled:t.target.checked}),className:"w-4 h-4 rounded border-zinc-600 bg-zinc-800 text-[#d4af37]","data-testid":"checkbox-sms-enabled"}),e.jsx("span",{className:"text-sm text-zinc-300",children:s("SMS Notifications")})]})]}),e.jsxs(O,{onClick:()=>Le.mutate(),disabled:!m.name||!m.email&&!m.phone||Le.isPending,className:"bg-[#d4af37] text-black hover:bg-[#c4a030]","data-testid":"button-add-recipient",children:[e.jsx(Re,{className:"w-4 h-4 mr-2"}),s("Add Recipient")]})]}),e.jsxs("div",{className:"border-t border-zinc-800 pt-6 mt-6",children:[e.jsxs("h3",{className:"text-sm font-medium text-zinc-300 mb-4 flex items-center gap-2",children:[e.jsx(et,{className:"w-4 h-4"}),s("Page Visibility")]}),e.jsx("p",{className:"text-zinc-400 text-sm mb-4",children:s("Toggle pages on or off without removing them. Hidden pages won't appear in the navigation.")}),e.jsx(Es,{})]}),e.jsxs("div",{className:"border-t border-zinc-800 pt-6 mt-6",children:[e.jsxs("h3",{className:"text-sm font-medium text-zinc-300 mb-2 flex items-center gap-2",children:[e.jsx(Te,{className:"w-4 h-4"}),s("Dashboard Layout")]}),e.jsx("p",{className:"text-zinc-400 text-sm mb-4",children:s("Restore all panels and cards to their default order.")}),e.jsxs(O,{variant:"outline",size:"sm",onClick:()=>Ee.mutate(),disabled:Ee.isPending,className:"border-zinc-700 hover:bg-zinc-800 text-zinc-300","data-testid":"button-reset-layout",children:[e.jsx(xe,{className:`w-3.5 h-3.5 mr-1.5 ${Ee.isPending?"animate-spin":""}`}),s("Reset layout")]})]})]}),(()=>{const t=Yt.slice(0,7),n=!F||Y,g=S=>n?{draggable:!0,onDragStart:()=>Zt(S),onDragEnter:()=>es(S),onDragEnd:ts,onDragOver:I=>I.preventDefault()}:{},j=n?"cursor-grab active:cursor-grabbing active:opacity-60 transition-opacity":"";function P(S){const I="group flex min-w-0 items-center gap-2.5 border-b-2 border-transparent bg-transparent px-2.5 py-2.5 text-left transition-colors hover:bg-zinc-900/60",i=e.jsx(gs,{className:"ml-auto h-4 w-4 shrink-0 text-zinc-700 transition-colors group-hover:text-zinc-300"});return S==="escalated-chats"?e.jsx(E,{href:"/admin/chat",onClick:()=>Ie.markSeen(),draggable:!1,onDragStart:D=>D.preventDefault(),"data-testid":"card-big-escalated-dashboard",children:e.jsxs("div",{className:`${I} hover:border-b-amber-400/80`,children:[e.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center",children:e.jsx(nt,{className:"h-4 w-4 text-amber-400"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-white",children:"Escalated chats"}),e.jsx("p",{className:"mt-0.5 truncate text-xs text-zinc-500",children:q>0?`${q} need attention`:"No human handoffs"})]}),q>0&&e.jsx("span",{className:"rounded-full bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-semibold text-amber-300",children:q}),i]})}):S==="pending-orders"?e.jsx(E,{href:"/admin/orders",onClick:()=>Bt.markSeen(),draggable:!1,onDragStart:D=>D.preventDefault(),"data-testid":"card-big-pending-dashboard",children:e.jsxs("div",{className:`${I} hover:border-b-yellow-400/80`,children:[e.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center",children:e.jsx(U,{className:"h-4 w-4 text-yellow-400"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-white",children:"Pending orders"}),e.jsxs("p",{className:"mt-0.5 truncate text-xs text-zinc-500",children:[H," waiting · ",le," today"]})]}),H>0&&e.jsx("span",{className:"rounded-full bg-yellow-500/15 px-1.5 py-0.5 text-[10px] font-semibold text-yellow-300",children:H}),i]})}):S==="orders"?e.jsx(E,{href:"/admin/orders",onClick:()=>Be.markSeen(),draggable:!1,onDragStart:D=>D.preventDefault(),"data-testid":"card-big-orders-dashboard",children:e.jsxs("div",{className:`${I} hover:border-b-[#d4af37]/80`,children:[e.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center",children:e.jsx(U,{className:"h-4 w-4 text-[#d4af37]"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-white",children:"Orders"}),e.jsxs("p",{className:"mt-0.5 truncate text-xs text-zinc-500",children:[fe," recent · ",le," today"]})]}),Be.hasNew&&e.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-amber-400"}),i]})}):S==="billing"?e.jsx(E,{href:"/admin/billing",draggable:!1,onDragStart:D=>D.preventDefault(),"data-testid":"card-big-billing-dashboard",children:e.jsxs("div",{className:`${I} hover:border-b-emerald-400/80`,children:[e.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center",children:e.jsx(ye,{className:"h-4 w-4 text-emerald-400"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-white",children:"Billing"}),e.jsx("p",{className:"mt-0.5 truncate text-xs text-zinc-500",children:"Invoices · payments · create"})]}),i]})}):S==="loan-tracker"?e.jsx(E,{href:"/admin/loan-tracker",draggable:!1,onDragStart:D=>D.preventDefault(),"data-testid":"card-loan-tracker-dashboard",children:e.jsxs("div",{className:`${I} hover:border-b-red-400/80`,children:[e.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center",children:e.jsx(ye,{className:"h-4 w-4 text-red-400"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-white",children:"Loan tracker"}),e.jsx("p",{className:"mt-0.5 truncate text-xs text-zinc-500",children:"Payments · balance · Excel"})]}),i]})}):S==="client-menus"?e.jsx(E,{href:"/admin/client-menu",draggable:!1,onDragStart:D=>D.preventDefault(),"data-testid":"card-big-client-menus-dashboard",children:e.jsxs("div",{className:`${I} hover:border-b-amber-400/80`,children:[e.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center",children:e.jsx(bs,{className:"h-4 w-4 text-amber-400"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-white",children:"Client menus"}),e.jsx("p",{className:"mt-0.5 truncate text-xs text-zinc-500",children:"Private menus for clients"})]}),i]})}):e.jsx(E,{href:"/admin/menus",draggable:!1,onDragStart:D=>D.preventDefault(),"data-testid":"card-big-menus-dashboard",children:e.jsxs("div",{className:`${I} hover:border-b-amber-400/80`,children:[e.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center",children:e.jsx(it,{className:"h-4 w-4 text-amber-400"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-white",children:"Menus"}),e.jsx("p",{className:"mt-0.5 truncate text-xs text-zinc-500",children:"View · share · email"})]}),i]})})}return e.jsxs("section",{className:"mb-5","data-testid":"panel-operations-command-center",children:[e.jsxs("div",{className:"mb-2.5 flex items-end justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.18em] text-[#d4af37]",children:"Start here"}),e.jsx("h2",{className:"mt-1 text-base font-semibold text-white",children:"Daily operations"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&e.jsx("p",{className:"hidden text-right text-[10px] text-zinc-600 sm:block",children:"Drag to reorder"}),e.jsxs("button",{type:"button",onClick:Jt,className:`inline-flex items-center gap-1.5 rounded-md border px-2 py-1.5 text-[10px] font-semibold uppercase tracking-wider transition-colors ${Y?"border-amber-500/40 bg-amber-500/10 text-amber-300":"border-zinc-800 bg-zinc-900/70 text-zinc-500 hover:border-amber-500/30 hover:text-amber-300"}`,"aria-pressed":Y,title:Y?"Finish arranging Daily operations":"Arrange Daily operations tabs","data-testid":"btn-toggle-daily-ops-reorder",children:[Y?e.jsx(tt,{className:"h-3 w-3"}):e.jsx(dt,{className:"h-3 w-3"}),Y?"Done":"Arrange"]})]})]}),e.jsx("nav",{className:"flex overflow-x-auto border-b border-zinc-800","aria-label":"Daily operations",children:t.map(S=>e.jsxs("div",{className:`relative min-w-[152px] shrink-0 lg:min-w-0 lg:flex-1 ${j}`,...g(S),children:[n&&e.jsx(mt,{className:"absolute left-0.5 top-1/2 z-10 h-3.5 w-3.5 -translate-y-1/2 text-zinc-700"}),P(S)]},S))})]})})(),!1,(()=>{const t=[{href:"/admin/chat",icon:e.jsx(nt,{className:"w-4 h-4 text-[#d4af37]"}),label:s("Chat"),desc:s("Escalated conversations"),badge:ge,hasNew:We.hasNew,onNav:We.markSeen,badgeColor:"zinc",testId:"card-chat-dashboard"},{href:"/admin/chat",icon:e.jsx(de,{className:"w-4 h-4 text-amber-400"}),label:s("Escalated Chats"),desc:s("Needs human attention"),badge:q,hasNew:Ie.hasNew,onNav:Ie.markSeen,badgeColor:"amber",testId:"card-escalated-dashboard"},{href:"/admin/topsheets",icon:e.jsx(me,{className:"w-4 h-4 text-[#d4af37]"}),label:s("Top Sheets"),desc:s("Square invoices → packing lists"),badge:null,hasNew:!1,onNav:()=>{},badgeColor:"zinc",testId:"card-topsheets-dashboard"},{href:"/admin/inquiries",icon:e.jsx(cs,{className:"w-4 h-4 text-sky-400"}),label:s("Crew Inquiries"),desc:s("Crew Program leads"),badge:ne.length,hasNew:Ge.hasNew,onNav:Ge.markSeen,badgeColor:"sky",testId:"card-crew-inquiries-dashboard"},{href:"/admin/inquiries",icon:e.jsx(zt,{className:"w-4 h-4 text-violet-400"}
1),label:"BCards",desc:"Business card follow-ups",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"violet",testId:"card-bcards-dashboard"},{href:"/admin/trello",icon:e.jsx(Ze,{className:"w-4 h-4 text-[#d4af37]"}),label:s("Trello"),desc:s("Boards, cards & tasks"),badge:null,hasNew:!1,onNav:()=>{},badgeColor:"zinc",testId:"card-trello-dashboard"},{href:"/admin/kds",icon:e.jsx(ht,{className:"w-4 h-4 text-emerald-400"}),label:s("Kitchen Display"),desc:s("KDS — real-time prep"),badge:null,hasNew:!1,onNav:()=>{},badgeColor:"zinc",testId:"card-kds-dashboard"},{href:"/admin/menu-cards",icon:e.jsx(it,{className:"w-4 h-4 text-amber-400"}),label:"Menu Cards",desc:"3.5″ × 2″ · platters & boards",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"zinc",testId:"card-menu-cards-dashboard"},{href:"/admin/email-orders",icon:e.jsx(jt,{className:"w-4 h-4 text-[#d4af37]"}),label:s("Email Intake"),desc:"[email protected] → approve",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"zinc",testId:"card-email-orders-dashboard"},{href:"/admin/tail-profiles",icon:e.jsx(Pe,{className:"w-4 h-4 text-amber-400"}),label:"Aircraft Profiles",desc:"Standing preferences by aircraft",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"amber",testId:"card-aircraft-profiles-dashboard"},{href:"/admin/feedback",icon:e.jsx(lt,{className:"w-4 h-4 text-[#d4af37]"}),label:s("Crew Feedback"),desc:s("Feedback & QR code"),badge:null,hasNew:!1,onNav:()=>{},badgeColor:"zinc",testId:"card-crew-feedback"},{href:"/admin/staff",icon:e.jsx(ot,{className:"w-4 h-4 text-[#d4af37]"}),label:s("Staff"),desc:s("Admin login credentials"),badge:null,hasNew:!1,onNav:()=>{},badgeColor:"zinc",testId:"card-staff-dashboard"},{href:"/admin/permissions",icon:e.jsx(we,{className:"w-4 h-4 text-amber-400"}),label:s("Permissions"),desc:s("Role-based access control"),badge:null,hasNew:!1,onNav:()=>{},badgeColor:"zinc",testId:"card-permissions-dashboard"},{href:"/admin/inventory",icon:e.jsx(ws,{className:"w-4 h-4 text-sky-400"}),label:"Inventory",desc:"Square catalog & stock counts",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"zinc",testId:"card-inventory-dashboard"},{href:"/admin/ingredient-stock",icon:e.jsx(U,{className:"w-4 h-4 text-amber-400"}),label:"Stock Control",desc:"Ingredient levels & adjustments",badge:ie||null,hasNew:ie>0,onNav:()=>{},badgeColor:"amber",testId:"card-stock-control-dashboard"},{href:"/admin/prep-lists",icon:e.jsx(lt,{className:"w-4 h-4 text-emerald-400"}),label:"Prep Lists",desc:"Daily kitchen prep by station",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"zinc",testId:"card-prep-lists-dashboard"},{href:"/admin/waste-logs",icon:e.jsx(de,{className:"w-4 h-4 text-red-400"}),label:"Waste Log",desc:"Spoilage, trim & over-prep",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"zinc",testId:"card-waste-logs-dashboard"},{href:"/admin/purchase-orders",icon:e.jsx(me,{className:"w-4 h-4 text-sky-400"}),label:"Purchase Orders",desc:"Supplier POs & receiving",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"zinc",testId:"card-purchase-orders-dashboard"},{href:"/admin/inventory-receipts",icon:e.jsx(ds,{className:"w-4 h-4 text-emerald-400"}),label:"Inventory Receipts",desc:"Scan & log supplier deliveries",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"emerald",testId:"card-inventory-receipts-dashboard"},{href:"/admin/suppliers",icon:e.jsx(ms,{className:"w-4 h-4 text-amber-400"}),label:"Suppliers",desc:"Directory · lead times · linked items",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"zinc",testId:"card-suppliers-dashboard"},{href:"/admin/variance-report",icon:e.jsx(hs,{className:"w-4 h-4 text-rose-400"}),label:"Variance Report",desc:"Theoretical vs actual usage · shrinkage",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"zinc",testId:"card-variance-report-dashboard"},{href:"/admin/kitchen-report",icon:e.jsx(Oe,{className:"w-4 h-4 text-violet-400"}),label:"Kitchen Report",desc:"Waste · stock · cost · prep ops",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"zinc",testId:"card-kitchen-report-dashboard"},{href:"/admin/cost-intelligence",icon:e.jsx(ye,{className:"w-4 h-4 text-emerald-400"}),label:"Cost Intelligence",desc:"Square invoices · revenue · margins",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"emerald",testId:"card-cost-intelligence-dashboard"},{href:"/admin/analytics",icon:e.jsx(Oe,{className:"w-4 h-4 text-violet-400"}),label:"Analytics",desc:"Revenue · orders · top items · hubs",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"violet",testId:"card-analytics-dashboard"},{href:"/admin/loyalty-report",icon:e.jsx(Oe,{className:"w-4 h-4 text-amber-400"}),label:"Loyalty Report",desc:"Points issued · redeemed · breakage · top members",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"amber",testId:"card-loyalty-report-dashboard"},{href:"/admin/catering-calendar",icon:e.jsx(xt,{className:"w-4 h-4 text-sky-400"}),label:"Catering Calendar",desc:"Orders by date · month view",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"sky",testId:"card-catering-calendar-dashboard"},{href:"/admin/equipment",icon:e.jsx(U,{className:"w-4 h-4 text-amber-400"}),label:"Equipment",desc:"Chafing · transport · checkout",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"amber",testId:"card-equipment-dashboard"},{href:"/admin/equipment-catalog",icon:e.jsx(U,{className:"w-4 h-4 text-sky-400"}),label:"Galley Equipment",desc:"Barcoded per-aircraft tracking",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"sky",testId:"card-galley-equipment-dashboard"}
1,{href:"/admin/charters",icon:e.jsx(U,{className:"w-4 h-4 text-violet-400"}),label:"Charter Orders",desc:"Mission briefs · pull lists",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"violet",testId:"card-charters-dashboard"},{href:"/admin/invoice-import",icon:e.jsx(me,{className:"w-4 h-4 text-emerald-400"}),label:"Invoice Import",desc:"AI-extract supplier invoice costs",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"emerald",testId:"card-invoice-import-dashboard"},{href:"/admin/square-price-sync",icon:e.jsx(xe,{className:"w-4 h-4 text-sky-400"}),label:"Square Price Sync",desc:"Map catalog items → food cost %",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"sky",testId:"card-square-price-sync-dashboard"},{href:"/admin/kds/overview",icon:e.jsx(ht,{className:"w-4 h-4 text-emerald-400"}),label:"KDS Overview",desc:"All tickets · 6-stage pipeline view",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"emerald",testId:"card-kds-overview-dashboard"},{href:"/admin/orders",icon:e.jsx(de,{className:"w-4 h-4 text-red-400"}),label:"Needs Review",desc:"Refused / partial delivery acceptances",badge:Q||null,hasNew:Q>0,onNav:()=>{},badgeColor:"red",testId:"card-needs-review-dashboard"},{href:"/admin/kds/expo",icon:e.jsx(js,{className:"w-4 h-4 text-sky-400"}),label:"EXPO Board",desc:"Packed & dispatch · flight-ready",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"sky",testId:"card-kds-expo-dashboard"},{href:"/admin/activity",icon:e.jsx(we,{className:"w-4 h-4 text-violet-400"}),label:"Audit Log",desc:"All admin actions · read-only trail",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"violet",testId:"card-audit-log-dashboard"},{href:"/admin/time-labor",icon:e.jsx(xs,{className:"w-4 h-4 text-[#d4af37]"}),label:"Time & Labor",desc:"Clock-in · hours · timecard approval",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"zinc",testId:"card-time-labor-dashboard"},{href:"/admin/help-inbox",icon:e.jsx(rt,{className:"w-4 h-4 text-rose-400"}),label:"Help Inbox",desc:"Staff requests · claim & resolve",badge:W||null,hasNew:W>0,onNav:()=>{},badgeColor:"red",testId:"card-help-inbox-dashboard"},{href:"/admin/gift-cards",icon:e.jsx(zs,{className:"w-4 h-4 text-[#d4af37]"}),label:"Gift Cards",desc:"Issue · void · track redemptions",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"amber",testId:"card-gift-cards-dashboard"},{href:"/admin/kitchen-board",icon:e.jsx(Te,{className:"w-4 h-4 text-amber-400"}),label:"Kitchen Board",desc:"Kanban tasks · templates · follow-ups",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"amber",testId:"card-kitchen-board-dashboard"},{href:"/admin/charter-missions",icon:e.jsx(Pe,{className:"w-4 h-4 text-amber-400"}),label:"Charter Missions",desc:"9-dept production board · boarding manifest",badge:G||null,hasNew:G>0,onNav:()=>{},badgeColor:"red",testId:"card-charter-missions-dashboard"},{href:"/admin/schedule",icon:e.jsx(xt,{className:"w-4 h-4 text-emerald-400"}),label:"Staff Schedule",desc:"Plan shifts · publish week · actuals",badge:null,hasNew:!1,onNav:()=>{},badgeColor:"emerald",testId:"card-schedule-dashboard"},{href:"/admin/recall-log",icon:e.jsx(at,{className:"w-4 h-4 text-red-400"}),label:"Food Safety Recalls",desc:"FDA/USDA alerts · review & notify",badge:J||null,hasNew:J>0,onNav:()=>{},badgeColor:"red",testId:"card-recall-alerts-dashboard"},{href:"/admin/pricing-hub?tab=company-books&needsPrices=1",icon:e.jsx(ye,{className:"w-4 h-4 text-rose-400"}),label:"Needs Prices",desc:"Unpriced portal items · auto-hidden from clients",badge:Me||null,hasNew:Me>0,onNav:()=>{},badgeColor:"red",testId:"card-needs-prices-dashboard"}],n=Object.fromEntries(t.map(i=>[i.testId,i])),g=[...Je,...t.map(i=>i.testId).filter(i=>!Je.includes(i))].map(i=>n[i]).filter(Boolean),j=g.map(i=>i.testId),P=re.trim().toLowerCase(),S=g.filter(i=>!P||`${i.label} ${i.desc}`.toLowerCase().includes(P)),I=je||P.length>0;return e.jsxs(e.Fragment,{children:[(Ue?.structures??[]).length>0&&e.jsxs("section",{className:"mb-5 overflow-hidden rounded-xl border border-emerald-900/60 bg-[#0d1c19]","data-testid":"panel-portal-links",children:[e.jsxs("div",{className:"border-b border-emerald-900/60 bg-emerald-950/25 px-4 py-3",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.18em] text-emerald-300/80",children:"Client portals"}),e.jsx("h2",{className:"mt-1 text-base font-semibold text-white",children:"Open a portal"})]}),e.jsx("nav",{className:"grid grid-cols-2 gap-1.5 border-b border-emerald-900/60 px-2 py-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-4 xl:grid-cols-5","aria-label":"Client portals",children:(Ue?.structures??[]).map(i=>e.jsxs("a",{href:`/client-login?company=${encodeURIComponent(i.slug)}`,target:"_blank",rel:"noopener noreferrer","data-testid":`portal-link-${i.slug}`,className:"group flex min-w-0 items-start gap-2 rounded-md border-b-2 border-transparent px-3 py-2.5 text-sm font-medium text-zinc-200 transition-colors hover:border-b-emerald-300/80 hover:bg-emerald-900/25 hover:text-white",children:[i.portalLogoUrl?e.jsx("img",{src:i.portalLogoUrl,alt:"",className:"h-4 w-auto max-w-[60px] object-contain opacity-80 transition-opacity group-hover:opacity-100"}):e.jsx(he,{className:"h-3.5 w-3.5 shrink-0 text-zinc-500 transition-colors group-hover:text-emerald-300"}),e.jsx("span",{className:"min-w-0 flex-1 whitespace-nowrap text-[13px] leading-tight",children:i.companyName}),e.jsx("span",{className:`ml-auto shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${i.publishedAt?"border-emerald-700/50 bg-emerald-900/40 text-emerald-300":"border-zinc-700 bg-zinc-800/50 text-zinc-500"}`,children:i.publishedAt?"Live":"Draft"})]},i.id))})]}),e.jsxs("section",{className:"mb-5 rounded-xl border border-zinc-800 bg-zinc-900/50 overflow-hidden","data-testid":"panel-more-tools",children:[e.jsxs("div",{className:"flex flex-col gap-3 px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("button",{onClick:()=>ae(i=>!i),className:"flex items-center gap-2 text-left","data-testid":"btn-toggle-more-tools","aria-expanded":I,children:[e.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-zinc-800",children:e.jsx(Te,{className:"h-3.5 w-3.5 text-[#d4af37]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-white",children:"More tools"}),e.jsxs("p",{className:"text-[10px] text-zinc-600",children:[t.length," workspaces and reports"]})]}),e.jsx(K,{className:`ml-1 h-4 w-4 text-zinc-500 transition-transform ${I?"rotate-180":""}`})]}),e.jsxs("div",{className:"relative w-full sm:max-w-xs",children:[e.jsx(ps,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-zinc-600"}),e.jsx("input",{value:re,onChange:i=>{a(i.target.value),ae(!0)},onFocus:()=>ae(!0),placeholder:"Search tools…","aria-label":"Search dashboard tools",className:"w-full rounded-lg border border-zinc-800 bg-black/20 py-2 pl-8 pr-3 text-xs text-zinc-200 placeholder-zinc-600 outline-none transition-colors focus:border-[#d4af37]/40","data-testid":"input-search-more-tools"})]})]}),I&&e.jsx("div",{className:"border-t border-zinc-800 px-3 pb-3 pt-3",children:S.length===0?e.jsxs("div",{className:"py-8 text-center text-xs text-zinc-600",children:["No tools match “",re,"”."]}):e.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:S.map(i=>e.jsxs("div",{draggable:!F,onDragStart:()=>Qt(i.testId),onDragEnter:()=>Ht(i.testId,j),onDragEnd:Vt,onDragOver:D=>D.preventDefault(),className:`relative flex items-center gap-2.5 rounded-lg border bg-zinc-900 p-3 transition-all group
2                            ${i.hasNew?"border-red-500 animate-pulse shadow-[0_0_8px_rgba(239,68,68,0.3)]":"border-zinc-800 hover:border-zinc-600 hover:bg-zinc-800/80"}
3                            ${F?"cursor-pointer":"cursor-grab active:cursor-grabbing active:opacity-60 active:scale-[0.97]"}`,"data-testid":i.testId,onClick:()=>
3{if(_.current){_.current=!1;return}i.onNav(),window.location.href=i.href},children:[!F&&e.jsx(mt,{className:"absolute left-1 top-1/2 h-3 w-3 -translate-y-1/2 text-zinc-700 transition-colors group-hover:text-zinc-500"}),i.hasNew&&e.jsx("span",{className:"absolute -top-1 -right-1 z-10 h-2.5 w-2.5 rounded-full bg-red-500 ring-2 ring-black"}),i.badge!==null&&i.badge!==void 0&&i.badge>0&&e.jsx("span",{className:`absolute right-1.5 top-1.5 rounded-full px-1.5 py-0.5 text-[9px] font-bold leading-none
4                              ${i.badgeColor==="amber"?"bg-amber-500/25 text-amber-300 border border-amber-500/30":i.badgeColor==="sky"?"bg-sky-500/25 text-sky-300 border border-sky-500/30":i.badgeColor==="violet"?"bg-violet-500/25 text-violet-300 border border-violet-500/30":i.badgeColor==="red"?"bg-rose-500/25 text-rose-300 border border-rose-500/30":"bg-zinc-700 text-zinc-300 border border-zinc-600"}`,children:i.badge}),e.jsx("div",{className:`shrink-0 rounded bg-zinc-800 p-1.5 transition-colors group-hover:bg-zinc-700 ${F?"":"ml-3"}`,children:i.icon}),e.jsxs("div",{className:"min-w-0 pr-4",children:[e.jsx("p",{className:"text-sm font-medium leading-tight",children:i.label}),e.jsx("p",{className:"mt-0.5 truncate text-xs leading-tight text-zinc-500",children:i.desc})]})]},i.testId))})})]})]})})(),e.jsxs("div",{className:"mb-5 grid grid-cols-1 gap-3 lg:grid-cols-2","data-testid":"panel-communication-inboxes",children:[e.jsx(_s,{}),e.jsx(Fs,{})]}),e.jsx("div",{className:"mt-8 p-4 bg-zinc-900/50 border border-zinc-800 rounded-lg",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ot,{className:"w-5 h-5 text-[#d4af37]"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:s("Notification Team")}),e.jsx("p",{className:"text-zinc-400 text-sm",children:B.length===0?s("No recipients configured. Click Settings to add team members."):`${B.length} ${B.length===1?s("member"):s("members")} ${s("will be notified of new alerts")}`})]})]})}),e.jsxs(L.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.4},className:"mt-8 bg-zinc-900 border border-zinc-800 rounded-lg","data-testid":"panel-admin-notes",children:[e.jsxs("div",{className:"p-4 border-b border-zinc-800 flex items-center justify-between",children:[e.jsxs("button",{onClick:()=>pe(t=>!t),className:"flex items-center gap-3 flex-1 min-w-0 text-left","data-testid":"btn-toggle-notes",children:[e.jsx(pt,{className:"w-5 h-5 text-[#d4af37]"}),e.jsx("h2",{className:"font-semibold",children:s("Strategy Notes")}),e.jsx(K,{className:`w-4 h-4 text-zinc-400 ml-1 transition-transform duration-200 ${M?"rotate-180":""}`})]}),o&&M&&e.jsxs(O,{size:"sm",onClick:()=>{w(null),d({title:"",content:"",category:"general"}),x(!k)},className:"bg-[#d4af37] text-black hover:bg-[#c4a030]","data-testid":"button-add-note",children:[e.jsx(Re,{className:"w-4 h-4 mr-1"}),s("Add Note")]})]}),M&&k&&e.jsx("div",{className:"p-4 border-b border-zinc-800 bg-zinc-800/30",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("input",{type:"text",placeholder:s("Note title..."),value:y.title,onChange:t=>d({...y,title:t.target.value}),className:"w-full bg-zinc-800 border border-zinc-700 rounded-lg px-4 py-2.5 text-white placeholder-zinc-500 focus:outline-none focus:border-[#d4af37]/50","data-testid":"input-note-title"}),e.jsx("textarea",{placeholder:s("Write your note..."),value:y.content,onChange:t=>d({...y,content:t.target.value}),rows:4,className:"w-full bg-zinc-800 border border-zinc-700 rounded-lg px-4 py-2.5 text-white placeholder-zinc-500 focus:outline-none focus:border-[#d4af37]/50 resize-none","data-testid":"input-note-content"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("select",{value:y.category,onChange:t=>d({...y,category:t.target.value}),className:"bg-zinc-800 border border-zinc-700 rounded-lg px-3 py-2 text-white focus:outline-none focus:border-[#d4af37]/50","data-testid":"select-note-category",children:ut.map(t=>e.jsx("option",{value:t.value,children:s(t.label)},t.value))}),e.jsx("div",{className:"flex-1"}),e.jsx(O,{variant:"outline",size:"sm",onClick:()=>{x(!1),d({title:"",content:"",category:"general"})},className:"border-zinc-700","data-testid":"button-cancel-note",children:s("Cancel")}),e.jsx(O,{size:"sm",onClick:()=>{c?ke.mutate({id:c.id,...y}):qe.mutate(y)},disabled:!y.title||!y.content||qe.isPending||ke.isPending,className:"bg-[#d4af37] text-black hover:bg-[#c4a030]","data-testid":"button-save-note",children:s(c?"Update":"Save")})]})]})}),M&&e.jsx("div",{className:"p-4",children:Ke.length===0?e.jsxs("div",{className:"text-center py-8 text-zinc-300",children:[e.jsx(pt,{className:"w-10 h-10 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:s("No notes yet")}),e.jsx("p",{className:"text-sm",children:s("Add notes to track strategies and important information")})]}):e.jsx("div",{className:"space-y-3",children:Ke.map(t=>e.jsx("div",{className:`p-4 rounded-lg border ${t.pinned==="true"?"bg-[#d4af37]/5 border-[#d4af37]/30":"bg-zinc-800/50 border-zinc-700/50"}`,"data-testid":`card-note-${t.id}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[t.pinned==="true"&&e.jsx(ct,{className:"w-3 h-3 text-[#d4af37]"}),e.jsx("h3",{className:"font-medium",children:t.title})]}),e.jsx("p",{className:"text-sm text-zinc-400 mt-1 whitespace-pre-wrap",children:t.content}),e.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[e.jsx("span",{className:"text-xs px-2 py-0.5 bg-zinc-700/50 rounded text-zinc-400",children:ut.find(n=>n.value===t.category)?.label||t.category}),e.jsx("span",{className:"text-xs text-zinc-300",children:new Date(t.updatedAt).toLocaleDateString()})]})]}),o&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(O,{variant:"ghost",size:"sm",onClick:()=>ke.mutate({id:t.id,pinned:t.pinned==="true"?"false":"true"}),className:"p-1.5 h-auto","data-testid":`button-pin-note-${t.id}`,children:e.jsx(ct,{className:`w-4 h-4 ${t.pinned==="true"?"text-[#d4af37]":"text-zinc-300"}`})}),e.jsx(O,{variant:"ghost",size:"sm",onClick:()=>{w(t),d({title:t.title,content:t.content,category:t.category}),x(!0)},className:"p-1.5 h-auto text-zinc-300 hover:text-white","data-testid":`button-edit-note-${t.id}`,children:e.jsx(us,{className:"w-4 h-4"})}),e.jsx(O,{variant:"ghost",size:"sm",onClick:()=>Et.mutate(t.id),className:"p-1.5 h-auto text-zinc-300 hover:text-red-400","data-testid":`button-delete-note-${t.id}`,children:e.jsx(ks,{className:"w-4 h-4"})})]})]})},t.id))})})]}),e.jsx($s,{canEdit:o}),e.jsx(Os,{canEdit:o}),e.jsx(Ls,{canEdit:o}),o&&e.jsx(Ts,{}),o&&e.jsx(As,{})]})})}function Os({canEdit:s}){const{t:o}=vt(),{toast:N}=te(),h=se(),[p,b]=r.useState(!1),[f,v]=r.useState(!1),[m,u]=r.useState({name:"",description:"",category:"entree",priceUsd:""}),[k,x]=r.useState(!1),[c,w]=r.useState(null),[y,d]=r.useState(""),{data:l}=z({queryKey:["/api/admin/ghost-menu"],enabled:p,queryFn:async()=>{const a=await fetch("/api/admin/ghost-menu");if(!a.ok)throw new Error("Failed to fetch ghost menu");return a.json()}}),R=l?.items??[],T=R.filter(a=>a.status==="available"),A=R.filter(a=>a.status==="reserved");async function M(){if(m.name.trim()){x(!0);try{if(!(await fetch("/api/admin/ghost-menu",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)})).ok)throw new Error;N({title:"Ghost Menu Item Created"}),u({name:"",description:"",category:"entree",priceUsd:""}),v(!1),h.invalidateQueries({queryKey:["/api/admin/ghost-menu"]})}catch{N({title:"Error",description:"Failed to create item.",variant:"destructive"})}finally{x(!1)}}}async function pe(a,C,ze){try{await fetch(`/api/admin/ghost-menu/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:C,reservedForOrderId:ze??null})}),h.invalidateQueries({queryKey:["/api/admin/ghost-menu"]})}catch{N({title:"Error",description:"Failed to update status.",variant:"destructive"})}}async function je(){c&&(await pe(c,"reserved",y.trim()||null),w(null),d(""),N({title:"Reserved",description:y.trim()?`Linked to order #${y.trim().slice(0,8)}`:"Item marked reserved."}))}async function ae(a){if(confirm("Remove this ghost menu item?"))try{await fetch(`/api/admin/ghost-menu/${a}`,{method:"DELETE"}),h.invalidateQueries({queryKey:["/api/admin/ghost-menu"]})}catch{N({title:"Error",description:"Failed to delete item.",variant:"destructive"})}}const re=a=>a==="available"?"bg-green-500/20 text-green-400 border-green-500/30":a==="reserved"?"bg-amber-500/20 text-amber-400 border-amber-500/30":"bg-zinc-700/50 text-zinc-300 border-zinc-600";return e.jsxs(L.div,{initial:{opacity:0,y:20}
4,animate:{opacity:1,y:0},transition:{delay:.4},className:"bg-zinc-900 border border-zinc-800 rounded-lg overflow-hidden mt-6","data-testid":"panel-ghost-menu",children:[e.jsxs("button",{className:"w-full p-4 border-b border-zinc-800 flex items-center justify-between text-left hover:bg-zinc-800/30 transition-colors",onClick:()=>b(a=>!a),"data-testid":"button-toggle-ghost-menu",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(me,{className:"w-5 h-5 text-purple-400"}),e.jsxs("h2",{className:"font-semibold",children:[o("Ghost Menu")," — VVIP Reserved Inventory"]}),e.jsxs("span",{className:"text-xs text-zinc-300",children:["(",T.length," available)"]})]}),e.jsx("span",{className:"text-zinc-400 text-xs",children:p?"▲ collapse":"▼ expand"})]}),p&&e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsx("p",{className:"text-xs text-zinc-300",children:"Ghost menu items are off-menu VVIP preparations not visible to standard clients. Reserve items against specific order IDs."}),s&&e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{onClick:()=>v(a=>!a),className:"text-xs bg-purple-700 hover:bg-purple-800 text-white px-3 py-1.5 rounded-lg transition-colors","data-testid":"button-new-ghost-item",children:"+ New Item"})}),f&&e.jsxs("div",{className:"bg-zinc-800 border border-zinc-700 rounded-lg p-4 space-y-3",children:[e.jsx("input",{className:"w-full bg-zinc-900 border border-zinc-700 rounded-lg px-3 py-2 text-sm text-zinc-200 placeholder-zinc-600",placeholder:"Item name (e.g. A5 Wagyu Tataki)",value:m.name,onChange:a=>u(C=>({...C,name:a.target.value})),"data-testid":"input-ghost-item-name"}),e.jsx("input",{className:"w-full bg-zinc-900 border border-zinc-700 rounded-lg px-3 py-2 text-sm text-zinc-200 placeholder-zinc-600",placeholder:"Description...",value:m.description,onChange:a=>u(C=>({...C,description:a.target.value})),"data-testid":"input-ghost-item-description"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[e.jsx("select",{className:"bg-zinc-900 border border-zinc-700 rounded-lg px-3 py-2 text-sm text-zinc-200",value:m.category,onChange:a=>u(C=>({...C,category:a.target.value})),"data-testid":"select-ghost-item-category",children:["appetizer","entree","dessert","beverage","specialty"].map(a=>e.jsx("option",{value:a,children:a.charAt(0).toUpperCase()+a.slice(1)},a))}),e.jsx("input",{className:"bg-zinc-900 border border-zinc-700 rounded-lg px-3 py-2 text-sm text-zinc-200 placeholder-zinc-600",placeholder:"Price USD (e.g. 485)",value:m.priceUsd,onChange:a=>u(C=>({...C,priceUsd:a.target.value})),"data-testid":"input-ghost-item-price"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:M,disabled:k||!m.name.trim(),className:"flex-1 bg-purple-700 hover:bg-purple-800 disabled:opacity-40 text-white text-sm py-2 rounded-lg transition-colors","data-testid":"button-save-ghost-item",children:k?"Saving…":"Create Ghost Item"}),e.jsx("button",{onClick:()=>v(!1),className:"px-4 text-zinc-400 hover:text-white text-sm transition-colors",children:"Cancel"})]})]}),R.length===0?e.jsxs("div",{className:"text-center py-8 text-zinc-400",children:[e.jsx(me,{className:"w-8 h-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No ghost menu items yet"})]}):e.jsx("div",{className:"space-y-2",children:[...T,...A].map(a=>e.jsxs("div",{className:"flex flex-col items-stretch gap-3 sm:flex-row sm:items-center bg-zinc-800 border border-zinc-700 rounded-lg px-3 sm:px-4 py-3","data-testid":`row-ghost-item-${a.id}`,children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium text-zinc-200 truncate",children:a.name}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full border ${re(a.status)}`,children:a.status})]}),a.description&&e.jsx("p",{className:"text-xs text-zinc-300 truncate",children:a.description}),e.jsxs("div",{className:"flex items-center gap-3 mt-0.5 text-xs text-zinc-400",children:[e.jsx("span",{className:"capitalize",children:a.category}),a.priceUsd&&e.jsxs("span",{children:["$",a.priceUsd]}),a.reservedForOrderId&&e.jsxs("span",{children:["Reserved: #",a.reservedForOrderId.slice(0,8)]})]})]}),s&&e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 shrink-0",children:[a.status==="available"&&c!==a.id&&e.jsx("button",{onClick:()=>{w(a.id),d("")},className:"text-xs text-amber-400 hover:text-amber-300 bg-amber-500/10 border border-amber-500/20 px-2 py-1 rounded transition-colors","data-testid":`button-reserve-ghost-item-${a.id}`,children:"Reserve for Order"}),c===a.id&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{className:"bg-zinc-800 border border-zinc-600 rounded px-2 py-1 text-xs text-white w-28 placeholder-zinc-500",placeholder:"Order ID (opt.)",value:y,onChange:C=>d(C.target.value),autoFocus:!0,"data-testid":`input-reserve-order-id-${a.id}`}),e.jsx("button",{onClick:je,className:"text-xs text-amber-400 bg-amber-500/10 border border-amber-500/20 px-2 py-1 rounded","data-testid":`button-confirm-reserve-${a.id}`,children:"✓"}),e.jsx("button",{onClick:()=>w(null),className:"text-xs text-zinc-300 px-1 py-1 rounded",children:"✕"})]}),a.status==="reserved"&&e.jsx("button",{onClick:()=>pe(a.id,"available",null),className:"text-xs text-green-400 hover:text-green-300 bg-green-500/10 border border-green-500/20 px-2 py-1 rounded transition-colors","data-testid":`button-release-ghost-item-${a.id}`,children:"Release"}),e.jsx("button",{onClick:()=>ae(a.id),className:"text-xs text-red-500 hover:text-red-400 px-2 py-1 rounded transition-colors","data-testid":`button-delete-ghost-item-${a.id}`,children:"✕"})]})]},a.id))})]})]})}function As(){const{toast:s}=te(),[o,N]=r.useState(!1),[h,p]=r.useState(""),[b,f]=r.useState(""),[v,m]=r.useState(!1),[u,k]=r.useState(!1),{data:x,refetch:c}=z({queryKey:["/api/admin/pricing-passcode/status"],queryFn:async()=>(await fetch("/api/admin/pricing-passcode/status",{credentials:"include"})).json()});async function w(){if(!/^\d{6}$/.test(h)){s({title:"Invalid passcode",description:"Use exactly 6 digits.",variant:"destructive"});return}if(h!==b){s({title:"Passcodes don't match",description:"Enter the same passcode twice.",variant:"destructive"});return}m(!0);try{const l=await fetch("/api/admin/pricing-passcode/set",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({passcode:h})});if(!l.ok)throw new Error((await l.json()).error||"Failed to save passcode");p(""),f(""),await c(),s({title:"Pricing publish passcode saved",description:"A passcode will be required before pricing is pushed."})}catch(l){s({title:"Could not save passcode",description:l.message,variant:"destructive"})}finally{m(!1)}}async function y(){if(confirm("Remove the pricing publish passcode? Pricing pushes will be blocked until a new one is set.")){k(!0);try{const l=await fetch("/api/admin/pricing-passcode",{method:"DELETE",credentials:"include"});if(!l.ok)throw new Error((await l.json()).error||"Failed to remove passcode");await c(),s({title:"Pricing publish passcode removed"})}catch(l){s({title:"Could not remove passcode",description:l.message,variant:"destructive"})}finally{k(!1)}}}const d=!!x?.set;return e.jsxs(L.div,{initial:{opacity:0,y:16}
4,animate:{opacity:1,y:0},className:"bg-zinc-900 border border-zinc-800 rounded-xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>N(l=>!l),className:"w-full flex items-center justify-between gap-3 px-4 sm:px-6 py-4 hover:bg-zinc-800/40 transition-colors","data-testid":"toggle-pricing-publish-passcode",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-amber-500/10 flex items-center justify-center",children:e.jsx(we,{className:"w-4 h-4 text-amber-400"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-bold text-white uppercase tracking-wider",children:"Pricing Publish Passcode"}),e.jsx("p",{className:"text-xs text-zinc-500 mt-0.5",children:d?"Required for portal, Square, and global menu pushes":"Not set — pricing pushes are blocked"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`text-xs font-bold px-2 py-0.5 rounded-full ${d?"bg-green-500/15 text-green-400":"bg-red-500/15 text-red-400"}`,children:d?"Active":"Required"}),o?e.jsx($e,{className:"w-4 h-4 text-zinc-500"}):e.jsx(K,{className:"w-4 h-4 text-zinc-500"})]})]}),o&&e.jsxs("div",{className:"px-4 pb-4 sm:px-6 sm:pb-6 border-t border-zinc-800 pt-5 space-y-4",children:[e.jsx("p",{className:"text-sm text-zinc-400",children:"Enter this six-digit code whenever approved pricing is pushed to the client portal, Square, or the global menu. The code is stored securely and never displayed."}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-zinc-500 uppercase tracking-wider block mb-1",children:"New passcode (6 digits)"}),e.jsx("input",{type:"password",inputMode:"numeric",maxLength:6,value:h,onChange:l=>p(l.target.value.replace(/\D/g,"")),placeholder:"••••••",className:"w-full bg-zinc-800 border border-zinc-700 rounded-lg px-3 py-2 text-white text-sm placeholder-zinc-600 focus:outline-none focus:border-amber-500/50","data-testid":"input-pricing-publish-passcode"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-zinc-500 uppercase tracking-wider block mb-1",children:"Confirm passcode"}),e.jsx("input",{type:"password",inputMode:"numeric",maxLength:6,value:b,onChange:l=>f(l.target.value.replace(/\D/g,"")),placeholder:"••••••",className:"w-full bg-zinc-800 border border-zinc-700 rounded-lg px-3 py-2 text-white text-sm placeholder-zinc-600 focus:outline-none focus:border-amber-500/50","data-testid":"input-confirm-pricing-publish-passcode"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("button",{onClick:w,disabled:v,className:"bg-amber-600 hover:bg-amber-500 disabled:opacity-40 text-white text-sm px-4 py-2 rounded-lg","data-testid":"button-save-pricing-publish-passcode",children:v?"Saving…":d?"Replace passcode":"Save passcode"}),d&&e.jsx("button",{onClick:y,disabled:u,className:"text-sm text-red-400 hover:text-red-300 px-3 py-2",children:u?"Removing…":"Remove passcode"})]})]})]})}function Ts(){const{toast:s}=te(),[o,N]=r.useState(!1),[h,p]=r.useState(""),[b,f]=r.useState(""),[v,m]=r.useState(!1),[u,k]=r.useState(!1),{data:x,refetch:c}=z({queryKey:["/api/admin/pin/status"],queryFn:async()=>(await fetch("/api/admin/pin/status",{credentials:"include"})).json()}),w=x?.set;async function y(){if(!/^\d{4,8}$/.test(h)){s({title:"Invalid PIN",description:"PIN must be 4–8 digits.",variant:"destructive"});return}if(h!==b){s({title:"PINs don't match",description:"Please enter the same PIN twice.",variant:"destructive"});return}m(!0);try{const l=await fetch("/api/admin/pin/set",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({pin:h})});if(!l.ok)throw new Error((await l.json()).error||"Failed");s({title:"PIN saved",description:"Order action PIN has been set."}),p(""),f(""),c()}catch(l){s({title:"Error",description:l.message,variant:"destructive"})}finally{m(!1)}}async function d(){if(confirm("Remove the order action PIN? Anyone will be able to cancel/decline orders without a PIN.")){k(!0);try{if(!(await fetch("/api/admin/pin",{method:"DELETE",credentials:"include"})).ok)throw new Error("Failed to remove PIN");s({title:"PIN removed",description:"Order action PIN has been cleared."}),c()}catch(l){s({title:"Error",description:l.message,variant:"destructive"})}finally{k(!1)}}}return e.jsxs(L.div,{initial:{opacity:0,y:16}
4,animate:{opacity:1,y:0},transition:{delay:.1},className:"bg-zinc-900 border border-zinc-800 rounded-xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>N(l=>!l),className:"w-full flex items-center justify-between gap-3 px-4 sm:px-6 py-4 hover:bg-zinc-800/40 transition-colors","data-testid":"toggle-pin-settings",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-red-500/10 flex items-center justify-center",children:e.jsx(we,{className:"w-4 h-4 text-red-400"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-bold text-white uppercase tracking-wider",children:"Order Action PIN"}),e.jsx("p",{className:"text-xs text-zinc-500 mt-0.5",children:w?"PIN is active — required to cancel or decline orders":"No PIN set — cancel/decline are unprotected"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`text-xs font-bold px-2 py-0.5 rounded-full ${w?"bg-green-500/15 text-green-400":"bg-zinc-700 text-zinc-400"}`,children:w?"Active":"Not set"}),o?e.jsx($e,{className:"w-4 h-4 text-zinc-500"}):e.jsx(K,{className:"w-4 h-4 text-zinc-500"})]})]}),o&&e.jsxs("div",{className:"px-4 pb-4 sm:px-6 sm:pb-6 border-t border-zinc-800 pt-5 space-y-4",children:[e.jsx("p",{className:"text-sm text-zinc-400",children:"When a PIN is active, any admin who tries to cancel or decline an order will see a numeric keypad popup and must enter the correct PIN before the action proceeds."}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-zinc-500 uppercase tracking-wider block mb-1",children:"New PIN (4–8 digits)"}),e.jsx("input",{type:"password",inputMode:"numeric",pattern:"\\d*",maxLength:8,value:h,onChange:l=>p(l.target.value.replace(/\D/g,"")),placeholder:"••••",className:"w-full bg-zinc-800 border border-zinc-700 rounded-lg px-3 py-2 text-white text-sm placeholder-zinc-600 focus:outline-none focus:border-amber-500/50","data-testid":"input-new-pin"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-zinc-500 uppercase tracking-wider block mb-1",children:"Confirm PIN"}),e.jsx("input",{type:"password",inputMode:"numeric",pattern:"\\d*",maxLength:8,value:b,onChange:l=>f(l.target.value.replace(/\D/g,"")),placeholder:"••••",className:"w-full bg-zinc-800 border border-zinc-700 rounded-lg px-3 py-2 text-white text-sm placeholder-zinc-600 focus:outline-none focus:border-amber-500/50","data-testid":"input-confirm-pin"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("button",{onClick:y,disabled:v||h.length<4,className:"px-4 py-2 text-xs font-bold uppercase tracking-widest text-black disabled:opacity-40 disabled:cursor-not-allowed transition-all",style:{background:"#d4af37"},"data-testid":"button-set-pin",children:v?"Saving…":w?"Update PIN":"Set PIN"}),w&&e.jsx("button",{onClick:d,disabled:u,className:"px-4 py-2 text-xs font-bold uppercase tracking-widest border border-red-500/50 text-red-400 hover:bg-red-500/10 rounded-lg transition-all disabled:opacity-40","data-testid":"button-remove-pin",children:u?"Removing…":"Remove PIN"})]})]})]})}function $s({canEdit:s}){const{toast:o}=te(),N=se(),[h,p]=r.useState(!1),[b,f]=r.useState({}),[v,m]=r.useState(!1),[u,k]=r.useState(!1),{data:x={}}=z({queryKey:["kitchen-statuses"],queryFn:()=>fetch("/api/kitchen-statuses").then(l=>l.json()),enabled:h});r.useEffect(()=>{if(!h)return;const l={};Ae.forEach(R=>{l[R.code]=x[R.code]||"live"}),f(l),m(!1)},[h,x]);const c=(l,R)=>{f(T=>({...T,[l]:R})),m(!0)},w=async()=>{k(!0);try{if(!(await fetch("/api/site-settings/kitchen_statuses",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:JSON.stringify(b)}),credentials:"include"})).ok)throw new Error("Save failed");N.invalidateQueries({queryKey:["kitchen-statuses"]}),o({title:"Kitchen statuses saved"}),m(!1)}catch{o({title:"Failed to save",variant:"destructive"})}finally{k(!1)}},y=[{value:"live",label:"Live",dot:"bg-green-400",text:"text-green-400"},{value:"conditional",label:"Conditional",dot:"bg-yellow-400",text:"text-yellow-400"},{value:"closed",label:"Closed",dot:"bg-red-400",text:"text-red-400"}],d={live:0,conditional:0,closed:0};return Ae.forEach(l=>{d[b[l.code]||"live"]++}),e.jsxs(L.div,{className:"mb-4 bg-zinc-900/50 border border-zinc-800 rounded-lg overflow-hidden","data-testid":"panel-kitchen-status",children:[e.jsxs("button",{onClick:()=>p(l=>!l),className:"w-full flex items-center justify-between gap-3 px-4 sm:px-6 py-4 hover:bg-zinc-800/40 transition-colors","data-testid":"button-toggle-kitchen-status",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(fs,{className:"w-4 h-4 text-amber-400"}),e.jsx("h2",{className:"font-semibold",children:"Kitchen Network Status"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 ml-2",children:[d.live>0&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-green-500/15 text-green-400 rounded font-mono",children:[d.live," Live"]}),d.conditional>0&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-yellow-500/15 text-yellow-400 rounded font-mono",children:[d.conditional," Conditional"]}),d.closed>
40&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-red-500/15 text-red-400 rounded font-mono",children:[d.closed," Closed"]})]})]}),h?e.jsx($e,{className:"w-4 h-4 text-zinc-400"}):e.jsx(K,{className:"w-4 h-4 text-zinc-400"})]}),h&&e.jsxs("div",{className:"px-4 pb-4 sm:px-6 sm:pb-6",children:[e.jsx("p",{className:"text-zinc-400 text-sm mb-4",children:"Set each kitchen's operational status. Changes appear live on the homepage strip."}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2 mb-4",children:Ae.map(l=>{const R=b[l.code]||"live",T=y.find(A=>A.value===R);return e.jsxs("div",{className:"bg-zinc-800/50 border border-zinc-700/50 rounded p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${T.dot} ${R==="live"?"animate-pulse":""}`}),e.jsx("span",{className:"font-mono font-bold text-xs text-white",children:l.name}),e.jsx("span",{className:"text-zinc-400 text-[10px] font-mono",children:l.code})]}),s?e.jsx("div",{className:"flex gap-1",children:y.map(A=>e.jsx("button",{onClick:()=>c(l.code,A.value),className:`flex-1 py-1 text-[10px] font-mono uppercase rounded transition-all ${R===A.value?`${A.dot} text-black font-bold`:"bg-zinc-700/40 text-zinc-300 hover:bg-zinc-700"}`,"data-testid":`button-kitchen-status-${l.code}-${A.value}`,children:A.label},A.value))}):e.jsx("span",{className:`text-xs font-mono font-bold ${T.text}`,children:T.label})]},l.code)})}),s&&e.jsxs("div",{className:"flex items-center gap-3 border-t border-zinc-800 pt-4",children:[e.jsx("button",{onClick:w,disabled:u||!v,className:"px-4 py-2 text-xs font-bold uppercase tracking-widest text-black transition-all disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"#d4af37"},"data-testid":"button-save-kitchen-statuses",children:u?"Saving…":"Save Changes"}),v&&e.jsx("span",{className:"text-xs text-amber-400 font-mono",children:"Unsaved changes"})]})]})]})}const bt=[{key:"setup",printerKey:"label_setup_printer",sizeKey:"label_setup_size",label:"Setup Label",color:"green",desc:"Printed at the start of each kitchen pull — confirms setup details",headerClass:"text-green-400 border-green-800/40 bg-green-950/30"},{key:"box",printerKey:"label_box_printer",sizeKey:"label_box_size",label:"Box / Delivery Label",color:"blue",desc:"Affixed to every delivery box — includes DFK logo, airport, FBO, and QR code",headerClass:"text-blue-400 border-blue-800/40 bg-blue-950/30"},{key:"item",printerKey:"label_item_printer",sizeKey:"label_item_size",label:"Item Labels",color:"amber",desc:"One per food item — includes client, tail, date, FBO, and dietary flags",headerClass:"text-amber-400 border-amber-800/40 bg-amber-950/30"}];function Ls({canEdit:s}){const o=se(),{toast:N}=te(),[h,p]=r.useState(!1),[b,f]=r.useState({}),[v,m]=r.useState(!1),{data:u={}}=z({queryKey:["/api/site-settings"],enabled:h});r.useEffect(()=>{if(!h)return;const x={};bt.forEach(c=>{x[c.printerKey]=u[c.printerKey]||"",x[c.sizeKey]=u[c.sizeKey]||""}),f(x)},[h,u]);const k=async()=>{m(!0);try{await Promise.all(Object.entries(b).map(([x,c])=>fetch(`/api/site-settings/${x}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:c}),credentials:"include"}))),o.invalidateQueries({queryKey:["/api/site-settings"]}),N({title:"Label printer settings saved"})}catch{N({title:"Failed to save label settings",variant:"destructive"})}finally{m(!1)}};return e.jsxs(L.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.18},className:"bg-zinc-900 border border-zinc-700 rounded-xl overflow-hidden","data-testid":"panel-label-settings",children:[e.jsxs("button",{onClick:()=>p(x=>!x),className:"w-full flex items-center justify-between px-5 py-4 hover:bg-zinc-800/50 transition-colors text-left","data-testid":"button-toggle-label-settings",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ss,{className:"w-5 h-5 text-amber-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white font-semibold text-sm",children:"Label Printer Settings"}),e.jsx("p",{className:"text-zinc-500 text-xs mt-0.5",children:"Setup · Box · Item — printers & paper sizes"})]})]}),e.jsx(K,{className:`w-4 h-4 text-zinc-400 transition-transform duration-200 ${h?"rotate-180":""}`})]}),h&&e.jsxs("div",{className:"border-t border-zinc-700 p-4 sm:p-5 space-y-4",children:[bt.map(x=>e.jsxs("div",{className:`rounded-lg border p-4 ${x.headerClass}`,children:[e.jsx("p",{className:"text-sm font-bold mb-0.5",children:x.label}),e.jsx("p",{className:"text-zinc-500 text-xs mb-3",children:x.desc}),s?e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-zinc-500 font-semibold uppercase tracking-wider",children:"Printer"}),e.jsx("input",{type:"text",value:b[x.printerKey]??"",onChange:c=>f(w=>({...w,[x.printerKey]:c.target.value})),className:"mt-1 w-full bg-zinc-800 border border-zinc-600 rounded px-2.5 py-1.5 text-sm text-white focus:outline-none focus:border-amber-500/50","data-testid":`input-${x.key}-printer`})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-zinc-500 font-semibold uppercase tracking-wider",children:"Paper / Label Size"}),e.jsx("input",{type:"text",value:b[x.sizeKey]??"",onChange:c=>f(w=>({...w,[x.sizeKey]:c.target.value})),className:"mt-1 w-full bg-zinc-800 border border-zinc-600 rounded px-2.5 py-1.5 text-sm text-white focus:outline-none focus:border-amber-500/50","data-testid":`input-${x.key}-size`})]})]}):e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-zinc-500 font-semibold uppercase tracking-wider",children:"Printer"}),e.jsx("p",{className:"text-sm text-white mt-0.5",children:u[x.printerKey]||"—"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-zinc-500 font-semibold uppercase tracking-wider",children:"Label Size"}),e.jsx("p",{className:"text-sm text-white mt-0.5",children:u[x.sizeKey]||"—"})]})]})]},x.key)),s&&e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{onClick:k,disabled:v,className:"flex items-center gap-2 px-4 py-2 bg-amber-500 hover:bg-amber-400 disabled:opacity-50 text-black text-sm font-bold rounded transition-colors","data-testid":"button-save-label-settings",children:v?"Saving…":"Save Label Settings"})})]})]})}function gt({className:s}
4){return e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:s,children:e.jsx("path",{d:"M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"})})}function qs(s){try{const o=new Date(s),h=(new Date().getTime()-o.getTime())/36e5;return h<24?o.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):h<168?o.toLocaleDateString([],{weekday:"short"}):o.toLocaleDateString([],{month:"short",day:"numeric"})}catch{return""}}function ft(s){return s.length===11&&s.startsWith("1")?`+1 (${s.slice(1,4)}) ${s.slice(4,7)}-${s.slice(7)}`:`+${s}`}function Fs(){const s=se(),{data:o,isLoading:N,error:h,refetch:p,isFetching:b}=z({queryKey:["/api/admin/whatsapp/messages"],refetchInterval:6e4,retry:1}),f=$({mutationFn:()=>fetch("/api/admin/whatsapp/messages/read-all",{method:"PATCH"}).then(d=>d.json()),onSuccess:()=>s.invalidateQueries({queryKey:["/api/admin/whatsapp/messages"]})}),v=o?.configured??!1,m=o?.messages??[],u=o?.unread??m.filter(d=>!d.isRead).length,k=h?.message,x="https://web.whatsapp.com",[c,w]=r.useState(!1),y=r.useRef(!1);return r.useEffect(()=>{!y.current&&u>0&&(y.current=!0,w(!0))},[u]),e.jsxs(L.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.18},className:`mb-5 rounded-lg overflow-hidden transition-colors ${!c&&u>0?"border-2 border-red-500 animate-pulse bg-zinc-900":"border border-zinc-800 bg-zinc-900"}`,"data-testid":"panel-whatsapp-inbox",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-zinc-800 flex items-center justify-between",children:[e.jsxs("button",{onClick:()=>w(d=>!d),className:"flex items-center gap-2.5 flex-1 min-w-0 text-left","data-testid":"btn-toggle-whatsapp",children:[e.jsx(gt,{className:"w-4 h-4 text-[#25D366] shrink-0"}),e.jsxs("div",{children:[e.jsx("h2",{className:"font-semibold text-sm leading-tight",children:"WhatsApp"}),e.jsx("p",{className:"text-[10px] text-zinc-500 leading-tight",children:"+1 (313) 542-2152"})]}),u>0&&e.jsxs("span",{className:"px-1.5 py-0.5 bg-[#25D366]/20 text-[#25D366] text-xs rounded-full font-medium","data-testid":"badge-whatsapp-unread",children:[u," new"]}),e.jsx(K,{className:`w-4 h-4 text-zinc-400 ml-auto transition-transform duration-200 ${c?"rotate-180":""}`})]}),c&&e.jsxs("div",{className:"flex items-center gap-1.5 ml-2",children:[v&&u>0&&e.jsx("button",{onClick:()=>f.mutate(),disabled:f.isPending,className:"px-2 py-1 rounded text-xs text-zinc-500 hover:text-zinc-300 hover:bg-zinc-800 transition-all disabled:opacity-40",title:"Mark all read","data-testid":"btn-whatsapp-mark-all-read",children:"Mark read"}),e.jsx("a",{href:x,target:"_blank",rel:"noopener noreferrer",className:"p-1.5 rounded text-zinc-500 hover:text-[#25D366] hover:bg-zinc-800 transition-colors",title:"Open WhatsApp Web","data-testid":"link-whatsapp-web",children:e.jsx(he,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>p(),disabled:b,className:"p-1.5 rounded text-zinc-500 hover:text-white hover:bg-zinc-800 transition-colors disabled:opacity-40",title:"Refresh","data-testid":"btn-whatsapp-refresh",children:e.jsx(xe,{className:`w-3.5 h-3.5 ${b?"animate-spin":""}`})})]})]}),c&&(N?e.jsx("div",{className:"px-4 py-6 text-center text-zinc-500 text-sm animate-pulse",children:"Loading…"}):v?k?e.jsx("div",{className:"px-4 py-5 text-sm text-red-400/70",children:k}):m.length===0?e.jsx("div",{className:"px-4 py-6 text-center text-zinc-600 text-sm",children:"No messages yet"}):e.jsx("div",{className:"divide-y divide-zinc-800/60",children:m.map(d=>e.jsxs("div",{className:`flex items-start gap-3 px-4 py-3 transition-colors ${d.isRead?"":"bg-zinc-800/20"}`,"data-testid":`row-wa-message-${d.id}`,children:[e.jsx("div",{className:"shrink-0 mt-1.5",children:d.isRead?e.jsx("div",{className:"w-1.5 h-1.5"}):e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#25D366]"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:`text-sm truncate ${d.isRead?"text-zinc-300":"font-semibold text-white"}`,children:d.fromName||ft(d.from)}),e.jsx("span",{className:"text-xs text-zinc-600 shrink-0",children:qs(d.receivedAt)})]}),d.fromName&&e.jsx("p",{className:"text-[10px] text-zinc-600 leading-tight",children:ft(d.from)}),e.jsx("p",{className:`text-xs truncate mt-0.5 ${d.isRead?"text-zinc-500":"text-zinc-200"}`,children:d.body})]}
4),e.jsx("a",{href:`https://web.whatsapp.com/send?phone=${d.from}`,target:"_blank",rel:"noopener noreferrer",className:"shrink-0 mt-0.5 p-1 rounded text-zinc-700 hover:text-[#25D366] hover:bg-zinc-800 transition-colors",title:"Reply on WhatsApp Web","data-testid":`btn-wa-reply-${d.id}`,children:e.jsx(he,{className:"w-3 h-3"})})]},d.id))}):e.jsxs("div",{className:"px-4 py-5 flex items-start gap-3 text-sm",children:[e.jsx(gt,{className:"w-4 h-4 text-[#25D366] shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-zinc-300 font-medium",children:"WhatsApp Business API not connected"}),e.jsx("p",{className:"text-zinc-500 text-xs mt-1 leading-relaxed",children:"To receive messages here, connect the WhatsApp Business API from Meta:"}),e.jsxs("ol",{className:"text-zinc-600 text-xs mt-2 space-y-1 list-decimal list-inside leading-relaxed",children:[e.jsxs("li",{children:["Go to ",e.jsx("strong",{className:"text-zinc-400",children:"developers.facebook.com"})," → Create App → Business → WhatsApp"]}),e.jsxs("li",{children:["Add ",e.jsx("strong",{className:"text-zinc-400",children:"+1 (313) 542-2152"})," as your phone number"]}),e.jsxs("li",{children:["Copy your ",e.jsx("strong",{className:"text-zinc-400",children:"Access Token"})," and ",e.jsx("strong",{className:"text-zinc-400",children:"Phone Number ID"})]}),e.jsxs("li",{children:["Add them to Replit Secrets as ",e.jsx("code",{className:"bg-zinc-800 px-1 rounded",children:"WHATSAPP_ACCESS_TOKEN"}),", ",e.jsx("code",{className:"bg-zinc-800 px-1 rounded",children:"WHATSAPP_PHONE_NUMBER_ID"})]}),e.jsxs("li",{children:["Set webhook URL to ",e.jsxs("code",{className:"bg-zinc-800 px-1 rounded text-[10px]",children:[window.location.origin,"/api/webhooks/whatsapp"]})," and add a ",e.jsx("code",{className:"bg-zinc-800 px-1 rounded",children:"WHATSAPP_WEBHOOK_VERIFY_TOKEN"})," secret"]})]}),e.jsxs("a",{href:x,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 mt-3 text-xs text-[#25D366] hover:underline",children:[e.jsx(he,{className:"w-3 h-3"})," Open WhatsApp Web in the meantime"]})]})]}))]})}function Ks(s){if(!s)return"";try{const o=new Date(s);if(Number.isNaN(o.getTime()))return"";const h=(new Date().getTime()-o.getTime())/36e5;return h<24?o.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):h<168?o.toLocaleDateString([],{weekday:"short"}):o.toLocaleDateString([],{month:"short",day:"numeric"})}catch{return""}}function _s(){const{data:s,isLoading:o,error:N,refetch:h,isFetching:p}=z({queryKey:["/api/admin/gmail/recent"],refetchInterval:9e4,retry:1}),b=s?.emails??[],f=s?.state??(N?"TEMPORARY_ERROR":"READY"),v=b.filter(c=>c.isUnread).length,[m,u]=r.useState(!1),k=r.useRef(!1);r.useEffect(()=>{!k.current&&v>0&&(k.current=!0,u(!0))},[v]),r.useEffect(()=>{!o&&f!=="READY"&&u(!0)},[f,o]);const x={NOT_CONNECTED:{title:"Gmail inbox is not connected",detail:"Connect the [email protected] mailbox to show its read-only Inbox summary here."},WRONG_ACCOUNT:{title:"A different Gmail account is connected",detail:"Reconnect the Gmail integration with [email protected] to show its Inbox summary."},PERMISSION_REQUIRED:{title:"Inbox read access is needed",detail:"Reconnect the Gmail integration and allow Gmail read-only access. This dashboard will not change messages."},TEMPORARY_ERROR:{title:"Mailbox review is in SST Inbox",detail:"Open SST Inbox to review approved messages in one place. The dashboard preview is temporarily unavailable."}};return e.jsxs(L.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.15},className:`mb-5 rounded-lg overflow-hidden transition-colors ${!m&&v>0?"border-2 border-red-500 animate-pulse bg-zinc-900":"border border-zinc-800 bg-zinc-900"}`,"data-testid":"panel-gmail-inbox",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-zinc-800 flex items-center justify-between",children:[e.jsxs("button",{onClick:()=>u(c=>!c),className:"flex items-center gap-2.5 flex-1 min-w-0 text-left","data-testid":"btn-toggle-gmail",children:[e.jsx(zt,{className:"w-4 h-4 text-[#c9a84c] shrink-0"}),e.jsxs("div",{children:[e.jsx("h2",{className:"font-semibold text-sm leading-tight",children:"[email protected]"}),f==="READY"&&!o&&e.jsx("p",{className:"text-[10px] text-emerald-400/70 leading-tight",children:"Verified Inbox · read-only"})]}),v>0&&e.jsxs("span",{className:"px-1.5 py-0.5 bg-[#c9a84c]/20 text-[#c9a84c] text-xs rounded-full font-medium","data-testid":"badge-gmail-unread",children:[v," new"]}),e.jsx(K,{className:`w-4 h-4 text-zinc-400 ml-auto transition-transform duration-200 ${m?"rotate-180":""}`})]}),e.jsxs(E,{href:"/admin/sst-inbox",className:"ml-2 inline-flex shrink-0 items-center gap-1.5 rounded px-2 py-1.5 text-xs font-medium text-amber-300/80 transition-colors hover:bg-zinc-800 hover:text-amber-200",title:"Open the Single Source Truth inbox","data-testid":"link-gmail-to-sst",children:[e.jsx(jt,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"SST Inbox"})]}),m&&e.jsx("button",{onClick:()=>h(),disabled:p,className:"ml-2 p-1.5 rounded text-zinc-500 hover:text-white hover:bg-zinc-800 transition-colors disabled:opacity-40",title:"Refresh inbox","data-testid":"btn-gmail-refresh",children:e.jsx(xe,{className:`w-3.5 h-3.5 ${p?"animate-spin":""}`})})]}),m&&(o?e.jsx("div",{className:"px-4 py-6 text-center text-zinc-500 text-sm animate-pulse",children:"Loading inbox…"}):f!=="READY"?e.jsxs("div",{className:"px-4 py-5 flex items-start gap-3 text-sm",children:[e.jsx(wt,{className:"w-4 h-4 text-amber-400 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-zinc-300 font-medium",children:x[f].title}),e.jsx("p",{className:"text-zinc-500 text-xs mt-1 leading-relaxed",children:x[f].detail})]})]}):b.length===0?e.jsx("div",{className:"px-4 py-6 text-center text-zinc-600 text-sm",children:"No messages in this Inbox"}):e.jsx("div",{className:"divide-y divide-zinc-800/60",children:b.map(c=>e.jsxs("a",{href:`https://mail.google.com/mail/u/0/#inbox/${encodeURIComponent(c.threadId)}`,target:"_blank",rel:"noopener noreferrer",className:`flex items-start gap-3 px-4 py-3 hover:bg-zinc-800/50 transition-colors group ${c.isUnread?"bg-zinc-800/20":""}`,"data-testid":`row-gmail-email-${c.id}`,children:[e.jsx("div",{className:"shrink-0 mt-1.5",children:c.isUnread?e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#c9a84c]"}):e.jsx("div",{className:"w-1.5 h-1.5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:`text-sm truncate ${c.isUnread?"font-semibold text-white":"text-zinc-300"}`,children:c.sender}),e.jsx("span",{className:"text-xs text-zinc-600 shrink-0",children:Ks(c.receivedAt)})]}),e.jsx("p",{className:`text-xs truncate mt-0.5 ${c.isUnread?"text-zinc-200":"text-zinc-500"}`,children:c.subject}),c.preview&&e.jsx("p",{className:"text-xs text-zinc-600 truncate mt-0.5",children:c.preview})]}),e.jsx(he,{className:"w-3 h-3 text-zinc-700 group-hover:text-zinc-500 shrink-0 mt-1 transition-colors"})]},c.id))}))]})}export{ia 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.