1import{r as l,j as e}from"./vendor-react-TXDxJ4pL.js";import{m as ds}from"./mugshotSrc-BxHC8MR4.js";import{u as Ht}from"./useUploads-DIR33u1G.js";import{s as cs,r as Ot,a as ps,b as xs,c as us,d as fs}from"./callsignMemory-CF8nrxl-.js";import{b as wt,F as ft,G as gs,H as me,I as he,J as hs,K as ys,L as ms,M as Z,N as bs,O as je,P as js,Q as vs,R as Ss,U as it,V as Cs,W as ks,X as ws,Y as Ns,Z as zs,_ as Bs,a1 as Vt,a3 as Is,a5 as Pt,a4 as Rs,a6 as Ds,a7 as Ts}from"./index-DSQ6kcyn.js";import{u as As}from"./announcementList-BgCxnfMK.js";import{H as Ls}from"./vendor-helmet-COw7OOqs.js";import{U as Os,z as Ze,V as lt,I as Gt,m as Qe,W as Ps,X as be,Y as _s,a as Fs,Z as Ws,_ as _t,h as Es,$ as $s,a0 as Nt,a1 as dt,a2 as gt,a3 as Ms,a4 as Us,a5 as Ct,a6 as zt,P as we,b as Bt,a7 as Yt,a8 as Re,a9 as It,aa as qs,ab as Hs,ac as Vs,ad as Gs,ae as Ft,af as Ys,ag as Xs,Q as Rt,ah as St,ai as ut,G as He,J as Js,aj as Ne,ak as at,v as kt,al as Ve,j as Zs,y as Wt,H as Xt,k as Jt,am as Zt,an as Qs,ao as Et,ap as Ks,F as $t,aq as er,ar as tr,as as sr,at as rr,au as nr,av as Qt}from"./vendor-icons--IBbgi4o.js";import{C as or}from"./CivFlagBadges-DkXfh_kF.js";import{a as ir}from"./civFlagTts-FrgnvXHw.js";import{y as F}from"./vendor-toastify-zImE3QEX.js";import ar from"./CadMessaging-Bvp2A7Ht.js";import lr from"./UnitGroupModal-CVGQOJIG.js";import{C as dr}from"./CommunitySelectionModal-DNq_sNvx.js";import{L as cr}from"./LicenseImageModal-DMNzZetY.js";import{S as pr}from"./StreetAutocomplete-SghH9207.js";import{u as xr,C as ur}from"./CallTypeInput-Ct4ROE3q.js";import{C as fr}from"./CallLocationInput-BftKFqi-.js";import{C as Kt}from"./CivilianAutofill-BzuUuGeS.js";import{u as gr}from"./useCallJurisdiction-DU83tjUN.js";import{a as hr}from"./newCallDefaults-D1OKogB0.js";import{u as yr,a as mr}from"./useUnitDetailsStep-tnVjGdRP.js";import{L as Mt}from"./leaflet-src-CQwB3M6p.js";import{M as br,T as jr}from"./leaflet-DBSIo_XY.js";import{g as vr}from"./mapGeometry-CHWrEvAH.js";import{l as Sr}from"./lookupOutcome-DGh_jVXl.js";import{C as Cr}from"./CallAlprPhotos-DP4kHeAY.js";import{a as ht}from"./vendor-router-BfSjmGu8.js";import{M as kr}from"./Marker-DZPskalJ.js";import{u as wr}from"./hooks-DdP8AsRG.js";import"./uploadRefs-D6AeyZEr.js";import"./vendor-i18n-ZeuoPmU-.js";import"./vendor-axios-BCn5QfZZ.js";import"./vendor-socket-Kk_l3rvZ.js";import"./vendor-CYhC9tBg.js";import"./cadMessaging-B7xvCgeS.js";import"./premierMessageFrom-Jyf5oLMk.js";import"./cadPalette-De09FqSH.js";import"./dispatchQueues-DJRIhcjp.js";import"./ImageLightbox-D8djBVPt.js";import"./safeUrl-DOkjlKUY.js";import"./Skeleton-COAjcOAJ.js";function Nr(){const t=wr();return l.useEffect(()=>{const o=()=>{try{t.invalidateSize()}catch{}},h=[0,120,350,700].map(k=>setTimeout(o,k));let n;const y=t.getContainer?t.getContainer():null;return typeof ResizeObserver<"u"&&y&&(n=new ResizeObserver(()=>o()),n.observe(y)),()=>{h.forEach(clearTimeout),n&&n.disconnect()}},[t]),null}const zr=(t,o)=>t?typeof t=="string"?t:t.useDiscordNickname===!1&&t.displayName?t.displayName:o&&(t.discordNicks?.[o]||t.discordNicks?.get?.(o))||t.displayName||t.username||"Unknown":"Unknown";class Br{constructor(){this.pendingRequests=new Map,this.cache=new Map,this.cacheTimeout=5e3,this.requestQueue=[],this.isProcessing=!1,this.rateLimitDelay=1e3,this.lastRequestTime=0}async execute(o,h,n={}){const{skipCache:y=!1,priority:k="normal",retryCount:w=3,retryDelay:f=2e3}=n;if(this.pendingRequests.has(o))return this.pendingRequests.get(o);if(!y){const W=this.cache.get(o);if(W&&Date.now()-W.timestamp<this.cacheTimeout)return W.data}const m=this.enqueueRequest(o,h,{priority:k,retryCount:w,retryDelay:f});return this.pendingRequests.set(o,m),m}async enqueueRequest(o,h,n){return new Promise((y,k)=>{const w={key:o,requestFn:h,resolve:y,reject:k,options:n,attempts:0};n.priority==="high"?this.requestQueue.unshift(w):this.requestQueue.push(w),this.processQueue()})}async processQueue(){if(!(this.isProcessing||this.requestQueue.length===0)){for(this.isProcessing=!0;this.requestQueue.length>0;){const o=this.requestQueue.shift(),n=Date.now()-this.lastRequestTime;n<this.rateLimitDelay&&await this.delay(this.rateLimitDelay-n);
1try{this.lastRequestTime=Date.now();const y=await this.executeWithRetry(o);this.cache.set(o.key,{data:y,timestamp:Date.now()}),o.resolve(y)}catch(y){o.reject(y)}finally{this.pendingRequests.delete(o.key)}}this.isProcessing=!1}}async executeWithRetry(o){const{requestFn:h,options:n}=o,{retryCount:y,retryDelay:k}=n;for(let w=0;w<=y;w++)try{return await h()}catch(f){const m=f.response?.status===429;if(w===y)throw f;if(m){const M=k*Math.pow(2,w);await this.delay(M)}else if(f.response?.status>=500)await this.delay(k);else throw f}}delay(o){return new Promise(h=>setTimeout(h,o))}clearCache(o){o?(this.cache.delete(o),this.pendingRequests.delete(o)):(this.cache.clear(),this.pendingRequests.clear())}getQueueStatus(){return{queueLength:this.requestQueue.length,isProcessing:this.isProcessing,cacheSize:this.cache.size,pendingRequests:this.pendingRequests.size}}}const Dt=new Br,Ir=async t=>Dt.execute(`pdf-${t}`,async()=>(await Z.get(`/reports/${t}/pdf`,{responseType:"blob",timeout:3e4})).data,{skipCache:!0,priority:"normal",retryCount:3,retryDelay:2e3}),Rr=async t=>Dt.execute(`report-${t}`,async()=>(await Z.get(`/reports/${t}`)).data,{priority:"high",retryCount:3,retryDelay:1e3}),Fn=async(t,o,h)=>Dt.execute(`reports-${t}-${o}-${h}`,async()=>{try{return(await Z.get("/reports/by-civilian",{params:{firstName:t,lastName:o,communityId:h}})).data}catch(n){if(n.response?.status===429)throw n;try{const y=await Z.get("/reports/by-subject",{params:{firstName:t,lastName:o,communityId:h}});return Array.isArray(y.data)?y.data:y.data.reports||[]}catch(y){return console.error("Error with alternative endpoint:",y),[]}}},{priority:"normal",retryCount:3,retryDelay:2e3}),Dr=async t=>{try{return(await Z.post("/judicial/suspension-requests",t)).data}catch(o){throw console.error("Error creating suspension request:",o),o}},Tt=[{ui:"10-41",text:"Beginning Shift",api:"10-41",code:"10-41",color:"#4ade80",bgColor:"#052e16",borderColor:"#16a34a",requiresCallsign:!0,action:"beginShift",icon:e.jsx(Xt,{}),description:"Beginning Shift",category:"dispatch"},{ui:"10-8",text:"In Service",api:"10-8",code:"10-8",color:"#4ade80",bgColor:"#052e16",borderColor:"#16a34a",action:"update",icon:e.jsx(dt,{}),description:"In Service",category:"dispatch"},{ui:"10-11",text:"Traffic Stop",api:"10-11",actualStatus:"10-11",code:"10-11",color:"#fbbf24",bgColor:"#422006",borderColor:"#f59e0b",action:"trafficStop",icon:e.jsx(Bt,{}),description:"Traffic Stop",category:"dispatch"},{ui:"10-6",text:"Busy",api:"10-6",code:"10-6",color:"#f87171",bgColor:"#450a0a",borderColor:"#dc2626",action:"update",icon:e.jsx(Jt,{}),description:"Busy",category:"dispatch"},{ui:"10-97",text:"Enroute",api:"10-97",actualStatus:"10-97",code:"10-97",color:"#60a5fa",bgColor:"#172554",borderColor:"#3b82f6",action:"attach",icon:e.jsx(Ne,{}),description:"Enroute",category:"dispatch"},{ui:"10-23",text:"On Scene",api:"10-23",actualStatus:"10-23",code:"10-23",color:"#4ade80",bgColor:"#052e16",borderColor:"#16a34a",action:"attach",icon:e.jsx(lt,{}),description:"On Scene",category:"dispatch"},{ui:"10-7",text:"Out of Service",api:"10-7",code:"10-7",color:"#9ca3af",bgColor:"#1f2937",borderColor:"#6b7280",action:"update",icon:e.jsx(Zt,{}),description:"Out of Service",category:"dispatch"},{ui:"10-42",text:"End Shift",api:"10-42",code:"10-42",color:"#ef4444",bgColor:"#450a0a",borderColor:"#dc2626",action:"endShift",icon:e.jsx(Nt,{}),description:"End Shift",category:"dispatch"}],Tr={"10-41":e.jsx(Xt,{}),"10-8":e.jsx(dt,{}),"10-11":e.jsx(Bt,{}),"10-6":e.jsx(Jt,{}),"10-97":e.jsx(Ne,{}),"10-23":e.jsx(lt,{}),"10-7":e.jsx(Zt,{}),"10-42":e.jsx(Nt,{})},Ut={"10-11":"trafficStop","10-41":"beginShift","10-97":"attach","10-23":"attach","10-76":"attach","10-42":"endShift"},Ar=(t,o,h)=>{if(h&&h!=="update")return h;if(Ut[t])return Ut[t];const n=(o||"").toLowerCase();return n.includes("traffic stop")||n.includes("traffic")?"trafficStop":n.includes("beginning shift")||n.includes("begin shift")||n.includes("start shift")?"beginShift":n.includes("enroute")||n.includes("en route")||n.includes("scene")||n.includes("responding")?"attach":n.includes("end shift")||n.includes("off duty")?"endShift":h||"update"},Lr=t=>t?.length?t.map(o=>{const h=Ar(o.code,o.label,o.action);return{ui:o.code,text:o.label,api:o.code,code:o.code,color:o.color||"#4ade80",bgColor:o.bgColor||"#052e16",borderColor:o.borderColor||"#16a34a",icon:Tr[o.code]||e.jsx(Nt,{}),action:h,requiresCallsign:h==="beginShift"}}):Tt,Or=(t,o=!1)=>({container:{fontFamily:"Arial, sans-serif",backgroundColor:"#1a1f2e",color:"#ffffff",height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden",userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none"},header:{backgroundColor:"#0f1419",padding:o?"8px 10px":"12px 16px",display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid #2d3748",minHeight:o?"44px":"60px"},cadHeaderText:{fontSize:o?"12px":"16px",fontWeight:"normal",color:"#e2e8f0",display:"flex",alignItems:"center",gap:o?"4px":"10px",flexWrap:"wrap"},mainArea:{display:"flex",flex:1,overflow:"hidden",backgroundColor:"#1a1f2e"},statusSidebar:{width:o?"70px":"180px",backgroundColor:"#0f1419",borderRight:"1px solid transparent",padding:o?"4px":"10px",display:o?"none":"flex",flexDirection:"column",gap:o?"4px":"10px",overflowY:"auto",WebkitOverflowScrolling:"touch",transition:"border-color 0.2s ease"},statusButton:{padding:"16px 12px",border:"none",backgroundColor:"#1a1f2e",color:"#e2e8f0",cursor:"pointer",fontSize:"16px",textAlign:"center",transition:"all 0.2s ease",minHeight:"60px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",fontWeight:"normal",borderRadius:"6px",WebkitTapHighlightColor:"transparent",touchAction:"manipulation"},menuSidebar:o?{position:"absolute",top:0,left:0,bottom:0,width:t?"0":"220px",backgroundColor:"#0f1419",borderRight:"1px solid transparent",transition:"width 0.3s ease, border-color 0.2s ease",overflow:"hidden",zIndex:100}:{width:t?"0":"240px",backgroundColor:"#0f1419",borderRight:"1px solid transparent",transition:"width 0.3s ease, border-color 0.2s ease",overflow:"hidden"},menuButton:{padding:o?"12px 16px":"16px 20px",border:"none",backgroundColor:"transparent",color:"#e2e8f0",cursor:"pointer",fontSize:o?"14px":"16px",textAlign:"left",display:"flex",alignItems:"center",gap:"12px",transition:"all 0.2s ease",width:"100%",minHeight:o?"44px":"52px",WebkitTapHighlightColor:"transparent",touchAction:"manipulation"},menuButtonActive:{backgroundColor:"#2d3748",color:"#ffffff"},content:{flex:1,padding:"12px",overflow:"auto",backgroundColor:"#1a1f2e",WebkitOverflowScrolling:"touch"},footer:{backgroundColor:"#0f1419",color:"#e2e8f0",padding:o?"6px 10px":"12px 16px",display:"flex",justifyContent:"space-between",alignItems:"center",minHeight:o?"36px":"60px",borderTop:"1px solid #2d3748",fontSize:o?"11px":"15px",flexWrap:"wrap",gap:"10px"},tableWrapper:{backgroundColor:"#0f1419",overflow:"hidden",marginBottom:"12px",border:"1px solid #2d3748",borderRadius:"6px"},modal:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.85)",display:"flex",justifyContent:"center",alignItems:"center",zIndex:1e3,padding:"20px"},modalContent:{"--cad-surface":"#0f1419","--cad-raised":"#1a1f2e","--cad-line":"#2d3748","--cad-text":"#e2e8f0","--cad-text-muted":"#9ca3af","--cad-accent":"#3b82f6",backgroundColor:"#0f1419",padding:"28px",borderRadius:"8px",width:"90%",maxWidth:"520px",maxHeight:"90vh",overflowY:"auto",border:"1px solid #2d3748",WebkitOverflowScrolling:"touch"},modalInput:{width:"100%",padding:"14px 16px",marginBottom:"14px",backgroundColor:"#1a1f2e",border:"1px solid #2d3748",color:"#e2e8f0",borderRadius:"6px",fontSize:"16px",minHeight:"48px",WebkitAppearance:"none"},modalButton:{padding:"14px 24px",margin:"6px",border:"1px solid #2d3748",borderRadius:"6px",cursor:"pointer",fontSize:"16px",transition:"all 0.2s ease",backgroundColor:"#1a1f2e",color:"#e2e8f0",minHeight:"52px",WebkitTapHighlightColor:"transparent",touchAction:"manipulation"},touchButton:{padding:"16px 24px",minHeight:"56px",fontSize:"16px",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",WebkitTapHighlightColor:"transparent",touchAction:"manipulation"},primary:"#3b82f6",danger:"#ef4444",warning:"#f59e0b",success:"#10b981",text:"#e2e8f0",textDark:"#9ca3af",border:"#2d3748"}),Ke=({children:t,onClose:o,themeStyles:h})=>e.jsx("div",{style:h.modal,onClick:o,children:e.jsx("div",{style:h.modalContent,onClick:n=>n.stopPropagation(),children:t})}),es=({plate:t,plateText:o,width:h=100})=>{const n=Ht();if(!t?.imageDataUri)return null;const y=Math.round(h*.5),k=Math.max(9,Math.round((t.textSizePercent||28)/100*y));return e.jsxs("div",{style:{position:"relative",width:h,height:y,borderRadius:4,overflow:"hidden",background:"#000",flexShrink:0},children:[e.jsx("img",{src:n(t.imageDataUri),alt:t.name||"Plate",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}),e.jsx("div",{style:{position:"absolute",left:`${t.textXPercent??50}%`,top:`${t.textYPercent??60}%`,transform:"translate(-50%, -50%)",color:t.textColor||"#000",fontWeight:800,fontSize:k,fontFamily:"'Geist Mono','JetBrains Mono',ui-monospace,SFMono-Regular,Menlo,monospace",textShadow:"0 1px 2px rgba(0,0,0,0.35)",whiteSpace:"nowrap",pointerEvents:"none"},children:o})]})},Je=({type:t,status:o,icon:h,licenseNumber:n,onView:y})=>
1{const w=(m=>{switch(m?.toLowerCase()){case"valid":return{bg:"#052e16",border:"#16a34a",text:"#4ade80"};case"suspended":return{bg:"#422006",border:"#f59e0b",text:"#fbbf24"};case"revoked":return{bg:"#450a0a",border:"#dc2626",text:"#ef4444"};case"expired":return{bg:"#1f2937",border:"#6b7280",text:"#9ca3af"};default:return{bg:"#1f2937",border:"#374151",text:"#9ca3af"}}})(o),f=o&&o!=="None";return e.jsxs("div",{style:{padding:"6px 10px",backgroundColor:w.bg,border:`1px solid ${w.border}`,borderRadius:6,display:"inline-flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",gap:2,minHeight:46,boxSizing:"border-box",fontSize:12.5,fontWeight:600,lineHeight:1.2},children:[e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{color:w.text,display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,fontSize:13,flexShrink:0},children:h}),e.jsx("span",{style:{color:w.text},children:t}),e.jsx("span",{style:{color:w.text,opacity:.55},children:"â¢"}),e.jsx("span",{style:{color:w.text},children:o||"None"}),y&&f&&e.jsxs("button",{onClick:m=>{m.stopPropagation(),y()},title:"View license card",style:{background:"transparent",border:"none",color:w.text,padding:"0 4px",cursor:"pointer",fontSize:11,fontWeight:600,display:"inline-flex",alignItems:"center",gap:3,marginLeft:4,opacity:.9,textDecoration:"underline",textUnderlineOffset:2},children:[e.jsx(Rt,{style:{fontSize:10}})," View"]})]}),n&&f&&e.jsx("span",{style:{fontSize:10.5,fontFamily:"monospace",color:w.text,opacity:.7,paddingLeft:20},children:n})]})},Pr=({person:t,onClose:o,onSubmit:h,themeStyles:n})=>{const[y,k]=l.useState({licenseType:"drivers",reason:"",notes:"",urgency:"normal"}),w=f=>{if(f.preventDefault(),!y.reason){F.error("Please provide a reason for the suspension request");return}h(y)};return e.jsxs(Ke,{onClose:o,themeStyles:n,children:[e.jsx("h3",{style:{fontSize:"22px",marginBottom:"24px"},children:"Request License Suspension"}),e.jsxs("div",{style:{marginBottom:"20px",padding:"16px",backgroundColor:"#1a1f2e",borderRadius:"6px"},children:[e.jsxs("strong",{children:[t.firstName," ",t.lastName]}),e.jsxs("div",{style:{fontSize:"14px",color:"#9ca3af",marginTop:"4px"},children:["License: ",t.licenseNumber||t.licenses?.drivers?.licenseNumber||"N/A"]})]}),e.jsxs("form",{onSubmit:w,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"14px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"14px"},children:"License Type"}),e.jsxs("select",{value:y.licenseType,onChange:f=>k({...y,licenseType:f.target.value}),style:n.modalInput,children:[e.jsx("option",{value:"drivers",children:"Driver's License"}),e.jsx("option",{value:"firearms",children:"Firearms License"}),e.jsx("option",{value:"both",children:"Both Licenses"})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"14px"},children:"Urgency"}),e.jsxs("select",{value:y.urgency,onChange:f=>k({...y,urgency:f.target.value}),style:n.modalInput,children:[e.jsx("option",{value:"normal",children:"Normal"}),e.jsx("option",{value:"high",children:"High Priority"}),e.jsx("option",{value:"urgent",children:"Urgent"})]})]})]}),e.jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"14px",marginTop:"14px"},children:"Reason *"}),e.jsx("textarea",{placeholder:"Provide detailed reason for suspension...",value:y.reason,onChange:f=>k({...y,reason:f.target.value}),style:{...n.modalInput,minHeight:"100px",resize:"vertical"},required:!0}),e.jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"14px"},children:"Additional Notes"}),e.jsx("textarea",{placeholder:"Any additional information...",value:y.notes,onChange:f=>k({...y,notes:f.target.value}),style:{...n.modalInput,minHeight:"80px",resize:"vertical"}}),e.jsxs("div",{style:{display:"flex",gap:"14px",marginTop:"24px"},children:[e.jsx("button",{type:"button",onClick:o,style:{...n.touchButton,backgroundColor:"#6b7280",color:"#fff",flex:1,border:"none"},children:"Cancel"}),e.jsxs("button",{type:"submit",style:{...n.touchButton,backgroundColor:n.warning,color:"#000",flex:1,border:"none"},children:[e.jsx(Qt,{})," Submit Request"]})]})]})]})},ts=({reportId:t,onClose:o,themeStyles:h})=>{const[n,y]=l.useState(null),[k,w]=l.useState(!0),[f,m]=l.useState("");l.useEffect(()=>{t&&W()},[t]);const W=async()=>{try{w(!0);const S=await Rr(t);y(S)}catch(S){console.error("Error fetching report:",S),m("Failed to load report")}finally{w(!1)}},M=S=>({"written-warning":"Written Warning",citation:"Citation",arrest:"Arrest Report",incident:"Incident Report",crash:"Crash Report","search-warrant":"Search Warrant","arrest-warrant":"Arrest Warrant","implied-consent":"Admin Per Se / Implied Consent",tow:"Tow Sheet",trespass:"Trespass Form",cve:"CVE Report",dui:"DUI Report",supplement:"Supplement Report","missing-person":"Missing Persons","property-damage":"Property Damage Report"})[S]||S,R=S=>({draft:"#6b7280",submitted:"#3b82f6",approved:"#10b981",denied:"#ef4444"})[S]||"#6b7280";return k?e.jsx("div",{style:{...h.modal,zIndex:1100},onClick:o,children:e.jsx("div",{style:{...h.modalContent,maxWidth:"900px"},onClick:S=>S.stopPropagation(),children:e.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[e.jsx(Re,{className:"fa-spin",style:{fontSize:"24px",marginBottom:"16
1px"}}),e.jsx("p",{children:"Loading report..."})]})})}):f||!n?e.jsx("div",{style:{...h.modal,zIndex:1100},onClick:o,children:e.jsx("div",{style:{...h.modalContent,maxWidth:"900px"},onClick:S=>S.stopPropagation(),children:e.jsxs("div",{style:{textAlign:"center",padding:"40px",color:"#ef4444"},children:[e.jsx("p",{children:f||"Report not found"}),e.jsx("button",{onClick:o,style:{...h.modalButton,marginTop:"20px"},children:"Close"})]})})}):e.jsx("div",{style:{...h.modal,zIndex:1100},onClick:o,children:e.jsxs("div",{style:{...h.modalContent,maxWidth:"900px",maxHeight:"90vh",overflowY:"auto"},onClick:S=>S.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px",borderBottom:"2px solid #2d3748",paddingBottom:"16px"},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{fontSize:"24px",margin:0},children:M(n.reportType)}),e.jsxs("div",{style:{display:"flex",gap:"16px",marginTop:"8px",fontSize:"14px",color:"#9ca3af"},children:[e.jsxs("span",{children:["Case #: ",n.caseNumber||"N/A"]}),e.jsx("span",{children:"â¢"}),e.jsxs("span",{children:["Officer: ",n.officerName||n.officerId]}),e.jsx("span",{children:"â¢"}),e.jsx("span",{children:new Date(n.dateTime).toLocaleString()})]})]}),e.jsx("button",{onClick:o,style:{background:"none",border:"none",color:"#e2e8f0",fontSize:"28px",cursor:"pointer",padding:"8px",minWidth:"44px",minHeight:"44px"},children:e.jsx(Qe,{})})]}),e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("span",{style:{padding:"6px 16px",backgroundColor:R(n.status),color:"#fff",borderRadius:"4px",fontSize:"14px",fontWeight:"bold"},children:n.status?.toUpperCase()}),n.approvalStatus&&e.jsxs("span",{style:{padding:"6px 16px",backgroundColor:n.approvalStatus==="approved"?"#10b981":n.approvalStatus==="denied"?"#ef4444":"#f59e0b",color:"#fff",borderRadius:"4px",fontSize:"14px",fontWeight:"bold",marginLeft:"8px"},children:["APPROVAL: ",n.approvalStatus?.toUpperCase()]})]}),e.jsxs("div",{style:{backgroundColor:"#1a1f2e",padding:"16px",borderRadius:"6px",marginBottom:"20px"},children:[e.jsx("h3",{style:{fontSize:"16px",marginBottom:"12px",color:"#60a5fa"},children:"Officer & Location Information"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px",fontSize:"14px"},children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Officer:"})," ",n.officerName||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Badge #:"})," ",n.badgeNumber||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Department:"})," ",n.department||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Unit:"})," ",n.unit||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Location:"})," ",n.location||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Zone/Beat:"})," ",n.zone||"N/A"," / ",n.beat||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Weather:"})," ",n.weather||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Lighting:"})," ",n.lighting||"N/A"]})]})]}),(n.subjectFirstName||n.subjectLastName)&&e.jsxs("div",{style:{backgroundColor:"#1a1f2e",padding:"16px",borderRadius:"6px",marginBottom:"20px",border:"1px solid #3b82f6"},children:[e.jsx("h3",{style:{fontSize:"16px",marginBottom:"12px",color:"#60a5fa"},children:"Subject Information"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px",fontSize:"14px"},children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Name:"})," ",[n.subjectFirstName,n.subjectMiddleName,n.subjectLastName].filter(Boolean).join(" ")||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Alias:"})," ",n.subjectAlias||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"DOB:"})," ",n.subjectDOB?new Date(n.subjectDOB).toLocaleDateString():"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Age:"})," ",n.subjectAge||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Sex:"})," ",n.subjectSex||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Race:"})," ",n.subjectRace||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Height:"})," ",n.subjectHeight||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Weight:"})," ",n.subjectWeight||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Hair:"})," ",n.subjectHair||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Eyes:"})," ",n.subjectEyes||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"License #:"})," ",n.subjectLicense||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"License State:"})," ",n.subjectLicenseState||"N/A"]})]}),n.subjectAddress&&e.jsxs("div",{style:{marginTop:"12px"},children:[e.jsx("strong",{children:"Address:"})," ",[n.subjectAddress,n.subjectCity,n.subjectState,n.subjectZip].filter(
1Boolean).join(", ")]}),n.subjectPhone&&e.jsxs("div",{style:{marginTop:"8px"},children:[e.jsx("strong",{children:"Phone:"})," ",n.subjectPhone]}),n.subjectMarks&&e.jsxs("div",{style:{marginTop:"8px"},children:[e.jsx("strong",{children:"Identifying Marks:"})," ",n.subjectMarks]})]}),n.vehiclePlate&&e.jsxs("div",{style:{backgroundColor:"#1a1f2e",padding:"16px",borderRadius:"6px",marginBottom:"20px",border:"1px solid #f59e0b"},children:[e.jsx("h3",{style:{fontSize:"16px",marginBottom:"12px",color:"#fbbf24"},children:"Vehicle Information"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px",fontSize:"14px"},children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Plate:"})," ",n.vehiclePlate||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"State:"})," ",n.vehicleState||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Year:"})," ",n.vehicleYear||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Make:"})," ",n.vehicleMake||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Model:"})," ",n.vehicleModel||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Style:"})," ",n.vehicleStyle||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Color:"})," ",[n.vehicleColor,n.vehicleColorSecondary].filter(Boolean).join(" / ")||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"VIN:"})," ",n.vehicleVIN||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Owner:"})," ",n.vehicleOwner||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Condition:"})," ",n.vehicleCondition||"N/A"]})]})]}),n.violations&&n.violations.length>0&&e.jsxs("div",{style:{backgroundColor:"#1a1f2e",padding:"16px",borderRadius:"6px",marginBottom:"20px",border:"1px solid #ef4444"},children:[e.jsx("h3",{style:{fontSize:"16px",marginBottom:"12px",color:"#ef4444"},children:"Violations/Charges"}),n.violations.map((S,P)=>e.jsxs("div",{style:{padding:"12px",backgroundColor:"#0f1419",marginBottom:"8px",borderRadius:"4px"},children:[e.jsxs("div",{style:{fontWeight:"bold",marginBottom:"4px"},children:[S.code," - ",S.description]}),e.jsxs("div",{style:{fontSize:"13px",color:"#9ca3af"},children:["Severity: ",S.severity||"N/A"," | Fine: $",S.fine||0]})]},P))]}),(n.narrative||n.arrestNarrative||n.warningReason||n.duiObservations)&&e.jsxs("div",{style:{backgroundColor:"#1a1f2e",padding:"16px",borderRadius:"6px",marginBottom:"20px"},children:[e.jsx("h3",{style:{fontSize:"16px",marginBottom:"12px",color:"#60a5fa"},children:"Narrative / Details"}),n.narrative&&e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsx("strong",{children:"General Narrative:"}),e.jsx("p",{style:{marginTop:"8px",whiteSpace:"pre-wrap"},children:n.narrative})]}),n.arrestNarrative&&e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsx("strong",{children:"Arrest Narrative:"}),e.jsx("p",{style:{marginTop:"8px",whiteSpace:"pre-wrap"},children:n.arrestNarrative})]}),n.warningReason&&e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsx("strong",{children:"Warning Reason:"}),e.jsx("p",{style:{marginTop:"8px",whiteSpace:"pre-wrap"},children:n.warningReason})]}),n.duiObservations&&e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsx("strong",{children:"DUI Observations:"}),e.jsx("p",{style:{marginTop:"8px",whiteSpace:"pre-wrap"},children:n.duiObservations})]})]}),n.evidence&&n.evidence.length>0&&e.jsxs("div",{style:{backgroundColor:"#1a1f2e",padding:"16px",borderRadius:"6px",marginBottom:"20px"},children:[e.jsx("h3",{style:{fontSize:"16px",marginBottom:"12px",color:"#60a5fa"},children:"Evidence"}),n.evidence.map((S,P)=>e.jsxs("div",{style:{padding:"8px",backgroundColor:"#0f1419",marginBottom:"8px",borderRadius:"4px"},children:[e.jsxs("strong",{children:[S.type,":"]})," ",S.description,S.location&&e.jsxs("span",{children:[" (Location: ",S.location,")"]})]},P))]}),n.witnesses&&n.witnesses.length>0&&e.jsxs("div",{style:{backgroundColor:"#1a1f2e",padding:"16px",borderRadius:"6px",marginBottom:"20px"},children:[e.jsx("h3",{style:{fontSize:"16px",marginBottom:"12px",color:"#60a5fa"},children:"Witnesses"}),n.witnesses.map((S,P)=>e.jsxs("div",{style:{padding:"8px",backgroundColor:"#0f1419",marginBottom:"8px",borderRadius:"4px"},children:[e.jsx("strong",{children:S.name})," - ",S.contact,S.statement&&e.jsx("p",{style:{marginTop:"4px",fontSize:"13px"},children:S.statement})]},P))]}),n.approvalStatus&&e.jsxs("div",{style:{backgroundColor:"#1a1f2e",padding:"16px",borderRadius:"6px",marginBottom:"20px",border:`1px solid ${n.approvalStatus==="approved"?"#10b981":"#ef4444"}`},children:[e.jsx("h3",{style:{fontSize:"16px",marginBottom:"12px",color:n.approvalStatus==="approved"?"#10b981":"#ef4444"},children:"Supervisor Review"}),e.jsxs("div",{style:{fontSize:"14px"},children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Status:"})," ",n.approvalStatus?.toUpperCase()]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Reviewed By:"})," ",n.approvedBy||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Date:"}
1)," ",n.approvalDate?new Date(n.approvalDate).toLocaleString():"N/A"]}),n.approvalNotes&&e.jsxs("div",{style:{marginTop:"8px"},children:[e.jsx("strong",{children:"Notes:"})," ",n.approvalNotes]})]})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",marginTop:"28px",justifyContent:"flex-end"},children:[e.jsxs("button",{onClick:async()=>{try{const S=await Ir(n._id),P=window.URL.createObjectURL(S);window.open(P,"_blank"),setTimeout(()=>window.URL.revokeObjectURL(P),100)}catch(S){console.error("Error generating PDF:",S),F.error(je(S,"Failed to generate PDF. Please try again."))}},style:{...h.touchButton,backgroundColor:"#10b981",color:"#fff",border:"none"},children:[e.jsx(It,{})," Download PDF"]}),e.jsx("button",{onClick:o,style:{...h.touchButton,backgroundColor:"#2d3748",border:"none"},children:"Close"})]})]})})},_r=({onConfirm:t,onClose:o,themeStyles:h,user:n,availableDepartments:y=[],communityId:k,requireVehicle:w=!1})=>{const f=mr()==="signon",[m,W]=l.useState(()=>{cs(k,(n?.communities||[]).find(A=>String(A._id)===String(k))?.callSignByDepartment);const c=n?.department||sessionStorage.getItem("lastDepartment")||"",u=Ot(k,c);return{department:c,subDepartment:n?.subDepartment||sessionStorage.getItem("lastSubDepartment")||"",callSign:u||n?.callSign||sessionStorage.getItem("lastCallSign")||"",apparatusId:"",useDiscordNickname:xs(k,n),displayName:ps(k,n)}}),[M,R]=l.useState(!1),[S,P]=l.useState([]),[U,ee]=l.useState(!1),[q,j]=l.useState([]),V=y.find(c=>(c.shortName||c.abbreviation)===m.department||c.name===m.department);l.useEffect(()=>{const c=Ot(k,m.department);c&&W(u=>u.callSign===c?u:{...u,callSign:c})},[m.department,k]),l.useEffect(()=>{(async()=>{if(!k||!V?._id){P([]);return}ee(!0);try{const{data:u}=await Z.get("/sub-departments",{params:{communityId:k,departmentId:V._id}});P(u.subDepartments||[])}catch(u){console.error("Error fetching sub-departments:",u),P([])}finally{ee(!1)}})()},[k,V?._id]),l.useEffect(()=>{if(!w||!k||!V?._id){j([]);return}let c=!1;return ws(k,V._id).then(u=>{c||j((u?.apparatus||[]).filter(A=>A.status!=="out-of-service"))}).catch(()=>{c||j([])}),()=>{c=!0}},[w,k,V?._id]);const _=c=>{if(c.preventDefault(),!m.department||!m.callSign){F.warning("Please enter both department and call sign.");return}if(w&&q.length>0&&!m.apparatusId){F.warning("Please select a vehicle for your shift.");return}if(!f&&!m.useDiscordNickname&&!m.displayName){F.warning("Please enter a display name or enable Discord nickname.");return}Is(m.department),sessionStorage.setItem("lastCallSign",m.callSign),us(k,m.department,m.callSign),sessionStorage.setItem("lastSubDepartment",m.subDepartment||""),sessionStorage.setItem("lastDisplayName",m.displayName),fs(k,m),t(m)};return e.jsxs(Ke,{onClose:o,themeStyles:h,children:[e.jsx("h3",{style:{fontSize:"22px",marginBottom:"24px",color:"#ffffff"},children:"Beginning Shift (10-41)"}),e.jsxs("form",{onSubmit:_,children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("label",{style:{display:"block",marginBottom:"10px",fontSize:"18px"},children:"Department *"}),y.length>0&&!M?e.jsxs(e.Fragment,{children:[e.jsxs("select",{value:m.department,onChange:c=>W({...m,department:c.target.value,subDepartment:""}),style:{...h.modalInput,fontSize:"16px"},required:!0,children:[e.jsx("option",{value:"",children:"Select Department"}),y.map(c=>e.jsxs("option",{value:c.shortName||c.abbreviation,children:[c.name," (",c.shortName||c.abbreviation,")"]},c._id))]}),e.jsx("button",{type:"button",onClick:()=>R(!0),style:{fontSize:"15px",color:h.primary,background:"none",border:"none",cursor:"pointer",marginTop:"10px",textDecoration:"underline",padding:"8px"},children:"Enter manually"})]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",placeholder:"Enter Department (e.g., LSPD, BCSO)",value:m.department,onChange:c=>W({...m,department:c.target.value,subDepartment:""}),style:h.modalInput,required:!0}),y.length>0&&e.jsx("button",{type:"button",onClick:()=>R(!1),style:{fontSize:"15px",color:h.primary,background:"none",border:"none",cursor:"pointer",marginTop:"10px",textDecoration:"underline",padding:"8px"},children:"Select from list"})]})]}),(S.length>0||U)&&e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("label",{style:{display:"block",marginBottom:"10px",fontSize:"18px"},children:"Sub-Department"}),e.jsxs("select",{value:m.subDepartment,onChange:c=>W({...m,subDepartment:c.target.value}),style:{...h.modalInput,fontSize:"16px"},children:[e.jsx("option",{value:"",children:"None (General)"}),S.map(c=>
1e.jsxs("option",{value:c.shortName,children:[c.name," (",c.shortName,")"]},c._id))]}),e.jsx("p",{style:{fontSize:"13px",color:"#9ca3af",marginTop:"6px"},children:"Select your subdivision / specialized unit"})]}),w&&e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("label",{style:{display:"block",marginBottom:"10px",fontSize:"18px"},children:"Vehicle *"}),V?._id?q.length===0?e.jsx("div",{style:{fontSize:"14px",color:"#9ca3af"},children:"No fleet vehicles available for this department. You can still begin your shift."}):e.jsxs("select",{value:m.apparatusId,onChange:c=>W({...m,apparatusId:c.target.value}),style:{...h.modalInput,fontSize:"16px"},required:!0,children:[e.jsx("option",{value:"",children:"Select Vehicle"}),q.map(c=>e.jsxs("option",{value:c._id,children:[c.unitId,c.name?` - ${c.name}`:"",c.plate?` (${c.plate})`:""]},c._id))]}):e.jsx("div",{style:{fontSize:"14px",color:"#9ca3af"},children:"Select a department first to choose a vehicle."})]}),e.jsxs("div",{style:{marginBottom:"28px"},children:[e.jsx("label",{style:{display:"block",marginBottom:"10px",fontSize:"18px"},children:"Call Sign *"}),e.jsx("input",{type:"text",placeholder:"Enter Call Sign (e.g., 1A-23)",value:m.callSign,onChange:c=>W({...m,callSign:c.target.value}),style:h.modalInput,required:!0})]}),!f&&e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",fontSize:"16px",color:"#e5e7eb"},children:[e.jsx("input",{type:"checkbox",checked:m.useDiscordNickname,onChange:c=>W({...m,useDiscordNickname:c.target.checked}),style:{width:"20px",height:"20px",accentColor:"#5865F2",cursor:"pointer",appearance:"auto",WebkitAppearance:"checkbox",opacity:1}}),"Use Discord Nickname"]}),e.jsx("div",{style:{fontSize:"13px",color:"#9ca3af",marginTop:"4px",marginLeft:"30px"},children:"When enabled, your Discord server nickname will be shown in the active units table."})]}),!f&&!m.useDiscordNickname&&e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("label",{style:{display:"block",marginBottom:"10px",fontSize:"18px"},children:"Display Name *"}),e.jsx("input",{type:"text",placeholder:"Enter your name to display (e.g., John Smith)",value:m.displayName,onChange:c=>W({...m,displayName:c.target.value}),style:h.modalInput,required:!0})]}),e.jsxs("div",{style:{display:"flex",gap:"14px",marginTop:"28px"},children:[e.jsx("button",{type:"button",onClick:o,style:{...h.touchButton,backgroundColor:"#6b7280",color:"#fff",borderColor:"#6b7280",flex:1,border:"none"},children:"Cancel"}),e.jsx("button",{type:"submit",style:{...h.touchButton,backgroundColor:h.primary,color:"#fff",flex:1,border:"none"},children:"Begin Shift"})]})]})]})},Fr=({calls:t,onAttach:o,onClose:h,themeStyles:n})=>e.jsxs(Ke,{onClose:h,themeStyles:n,children:[e.jsx("h3",{style:{fontSize:"22px",marginBottom:"24px"},children:"Attach to Call"}),t?.length>0?t.map(y=>e.jsxs("button",{onClick:()=>o(y),style:{...n.touchButton,backgroundColor:"#1a1f2e",width:"100%",textAlign:"left",marginBottom:"14px",padding:"20px",border:"1px solid #2d3748",flexDirection:"column",alignItems:"flex-start"},children:[e.jsx("div",{style:{fontWeight:"bold",fontSize:"18px"},children:y.incident_number}),e.jsxs("div",{style:{fontSize:"15px",opacity:.8,marginTop:"6px"},children:[y.call_type," - ",y.location]}),(y.city||y.county)&&e.jsx("div",{style:{fontSize:"13px",opacity:.6,marginTop:"4px"},children:[y.city,y.county].filter(Boolean).join(", ")})]},y._id)):e.jsx("p",{style:{textAlign:"center",padding:"24px",fontSize:"16px"},children:"No active calls available."}),e.jsxs("div",{style:{display:"flex",gap:"14px",marginTop:"24px"},children:[e.jsx("button",{onClick:()=>o(null),style:{...n.touchButton,backgroundColor:n.warning,color:"#000",flex:1,border:"none"},children:"Set Status Without Call"}),e.jsx("button",{onClick:h,style:{...n.touchButton,backgroundColor:"#2d3748",flex:1,border:"none"},children:"Cancel"})]})]}),ss=({call:t,liveCall:o,onClose:h,themeStyles:n,recentLookups:y,activeUnits:k=[],guildId:w,onSearchItem:f,onCompleteCall:m,activeCommunity:W})=>{const[M,R]=l.useState(""),[S,P]=l.useState("details"),[U,ee]=l.useState(null),[q,j]=l.useState(!1),[V,_]=l.useState(!1),[c,u]=l.useState({}),[A,oe]=l.useState(!1),{user:$}=wt();l.useEffect(()=>{t&&ge()},[t]);const ge=async()=>
1{if(t?._id){j(!0);try{const r=await Z.get(`/calls/${t._id}`);r.data&&ee(r.data)}catch(r){console.error("Error fetching call details:",r),ee(t)}finally{j(!1)}}},te=async()=>{if(!(!M.trim()||!t?._id))try{const r=await Z.post(`/calls/${t._id}/notes`,{text:M});R(""),r.data?.notes?ee(p=>p&&{...p,notes:r.data.notes}):ge(),F.success("Note added")}catch(r){console.error("Error adding note:",r),F.error(je(r,"Failed to add note"))}},ae=async r=>{if(t?._id)try{const p=r.recordId||r.civilianId||r.vehicleId;r.lookupType==="vehicle"?await Z.patch(`/calls/${t._id}/attach-vehicle`,{vehicleId:p,plate:r.snapshot?.plate,color:r.snapshot?.color,make:r.snapshot?.make,model:r.snapshot?.model,year:r.snapshot?.year}):await Vt(t._id,{civilianId:p,firstName:r.snapshot?.firstName,lastName:r.snapshot?.lastName,dateOfBirth:r.snapshot?.dateOfBirth,phone:r.snapshot?.phone,licenseNumber:r.snapshot?.licenseNumber},"dashboard-page-3"),ge(),F.success("Attached to call")}catch(p){console.error("Error attaching to call:",p),F.error(je(p,"Failed to attach"))}},ce=()=>{const r=U||t;u({callType:r.callType||"",location:r.location||"",caller:r.caller||"",description:r.description||"",status:r.status||"pending",priority:r.priority||"normal",postal:r.postal||"",city:r.city||"",county:r.county||""}),_(!0)},B=async()=>{if(t?._id){oe(!0);try{await Z.put(`/calls/${t._id}`,c),_(!1),ge(),F.success("Call updated")}catch(r){console.error("Error updating call:",r),F.error(je(r,"Failed to update call"))}finally{oe(!1)}}};if(!t)return null;const g=U||t,E=g.notes||[],G=g.involvedCivilians||[],se=g.involvedVehicles||[],ne=(()=>{if(g.assignedUnits&&g.assignedUnits.length>0&&typeof g.assignedUnits[0]=="object")return g.assignedUnits;const r=g.attachedUnits||g.assignedUnits||[];return r.length>0&&k.length>0?r.map(p=>{const C=typeof p=="object"?p._id||p.unitId:p,v=k.find(X=>X._id===C||X.username===C||X.callSign===C);return v?{_id:v._id,callSign:v.callSign||v.username,unitId:{callSign:v.callSign,username:v.username},status:(v.status||"").split("@")[0].trim(),assignedAt:p.assignedAt||g.createdAt}:{_id:C,callSign:typeof p=="string"?p:p.callSign||"Unknown",status:"assigned"}}):k.length>0?k.filter(C=>C.activeCallId===g._id).map(C=>({_id:C._id,callSign:C.callSign||C.username,unitId:{callSign:C.callSign,username:C.username},status:(C.status||"").split("@")[0].trim(),assignedAt:g.createdAt})):[]})(),N={pending:"#f59e0b",assigned:"#3b82f6",enroute:"#8b5cf6","on-scene":"#10b981",closed:"#6b7280",cancelled:"#ef4444"},a={assigned:"#3b82f6",enroute:"#8b5cf6","on-scene":"#10b981",cleared:"#6b7280"},I=[{key:"details",label:"Details"},{key:"units",label:`Units (${ne.length})`},{key:"involved",label:`Involved (${G.length+se.length})`}];return e.jsx("div",{style:{...n.modal,zIndex:1050},onClick:h,children:e.jsxs("div",{style:{...n.modalContent,maxWidth:"800px",maxHeight:"90vh",overflowY:"auto",padding:0},onClick:r=>r.stopPropagation(),children:[e.jsxs("div",{style:{padding:"20px",borderBottom:"1px solid #2d3748",backgroundColor:"#1a1f2e",position:"sticky",top:0,zIndex:10},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{margin:0,fontSize:"20px",color:"#e2e8f0"},children:g.incidentNumber||`Call #${t._id?.slice(-6)}`}),e.jsxs("div",{style:{fontSize:"14px",color:"#9ca3af",marginTop:"4px"},children:[g.callType," ",g.location?`⢠${g.location}`:""]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[V?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:B,disabled:A,style:{padding:"6px 14px",borderRadius:"6px",border:"none",backgroundColor:"#10b981",color:"#fff",cursor:A?"not-allowed":"pointer",fontSize:"13px",fontWeight:"500",opacity:A?.7:1},children:A?"Saving...":"Save"}),e.jsx("button",{onClick:()=>_(!1),style:{padding:"6px 14px",borderRadius:"6px",border:"1px solid #4b5563",backgroundColor:"transparent",color:"#9ca3af",cursor:"pointer",fontSize:"13px",fontWeight:"500"},children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[m&&g.status!=="closed"&&g.status!=="cancelled"&&ne.some(r=>{const p=r.unitId?._id||r.unitId||r._id;return String(p)===String($?._id)})&&e.jsxs("button",{onClick:()=>m(t),style:{padding:"6px 14px",borderRadius:"6px",border:"none",backgroundColor:"#10b981",color:"#fff",cursor:"pointer",fontSize:"13px",fontWeight:"500",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Zs,{style:{fontSize:"12px"}})," Complete Call"]}),e.jsxs("button",{onClick:ce,style:{padding:"6px 14px",borderRadius:"6px",border:"1px solid #3b82f6",backgroundColor:"transparent",color:"#3b82f6",cursor:"pointer",fontSize:"13px",fontWeight:"500",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Ct,{style:{fontSize:"12px"}})," Edit"]})]}),e.jsx("button",{onClick:h,style:{background:"none",border:"none",color:"#9ca3af",fontSize:"24px",cursor:"pointer",padding:"0 8px"},children:"Ã"})]})]}),e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"16px"},children:I.map(r=>e.jsx("button",{onClick:()=>P(r.key),style:{padding:"8px 16px",borderRadius:"6px",border:"none",backgroundColor:S===r.key?"#3b82f6":"#2d3748",color:S===r.key?"#fff":"#9ca3af",cursor:"pointer",fontSize:"14px",fontWeight:"500"},children:r.label},r.key))})]}),e.jsx("div",{style:{padding:"20px",paddingBottom:"28px"},children:q?e.jsxs("div",{style:{textAlign:"center",padding:"40px",color:"#9ca3af"},children:[e.jsx(Re,{className:"fa-spin",style:{fontSize:"24px"}}),e.jsx("p",{children:"Loading..."})]}):e.jsxs(e.Fragment,{children:[S==="details"&&e.jsxs("div",{children:[e.jsx("div",{style:{backgroundColor:"#0f1419",padding:"16px",borderRadius:"8px",marginBottom:"16
1px"},children:V?e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#6b7280",marginBottom:"4px",display:"block"},children:"Status"}),e.jsx("select",{value:c.status,onChange:r=>u(p=>({...p,status:r.target.value})),style:{width:"100%",padding:"8px",backgroundColor:"#1a1f2e",border:"1px solid #2d3748",borderRadius:"6px",color:"#e2e8f0",fontSize:"14px"},children:["pending","assigned","enroute","on-scene","closed","cancelled"].map(r=>e.jsx("option",{value:r,children:r.toUpperCase()},r))})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#6b7280",marginBottom:"4px",display:"block"},children:"Priority"}),e.jsx("select",{value:c.priority,onChange:r=>u(p=>({...p,priority:r.target.value})),style:{width:"100%",padding:"8px",backgroundColor:"#1a1f2e",border:"1px solid #2d3748",borderRadius:"6px",color:"#e2e8f0",fontSize:"14px"},children:(()=>{const r=W?.cadSettings?.priorities;return r&&r.length>0?r.map(p=>e.jsx("option",{value:p.value,children:p.label},p.value)):["low","normal","medium","high","critical"].map(p=>e.jsx("option",{value:p,children:p.toUpperCase()},p))})()})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#6b7280",marginBottom:"4px",display:"block"},children:"Call Type"}),e.jsx("input",{value:c.callType,onChange:r=>u(p=>({...p,callType:r.target.value})),style:{width:"100%",padding:"8px",backgroundColor:"#1a1f2e",border:"1px solid #2d3748",borderRadius:"6px",color:"#e2e8f0",fontSize:"14px",boxSizing:"border-box"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#6b7280",marginBottom:"4px",display:"block"},children:"Caller"}),e.jsx("input",{value:c.caller,onChange:r=>u(p=>({...p,caller:r.target.value})),style:{width:"100%",padding:"8px",backgroundColor:"#1a1f2e",border:"1px solid #2d3748",borderRadius:"6px",color:"#e2e8f0",fontSize:"14px",boxSizing:"border-box"}})]}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("label",{style:{fontSize:"12px",color:"#6b7280",marginBottom:"4px",display:"block"},children:"Location"}),e.jsx("input",{value:c.location,onChange:r=>u(p=>({...p,location:r.target.value})),style:{width:"100%",padding:"8px",backgroundColor:"#1a1f2e",border:"1px solid #2d3748",borderRadius:"6px",color:"#e2e8f0",fontSize:"14px",boxSizing:"border-box"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#6b7280",marginBottom:"4px",display:"block"},children:"Postal"}),e.jsx("input",{value:c.postal,onChange:r=>u(p=>({...p,postal:r.target.value})),style:{width:"100%",padding:"8px",backgroundColor:"#1a1f2e",border:"1px solid #2d3748",borderRadius:"6px",color:"#e2e8f0",fontSize:"14px",boxSizing:"border-box"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#6b7280",marginBottom:"4px",display:"block"},children:"City"}),e.jsx("input",{value:c.city,onChange:r=>u(p=>({...p,city:r.target.value})),style:{width:"100%",padding:"8px",backgroundColor:"#1a1f2e",border:"1px solid #2d3748",borderRadius:"6px",color:"#e2e8f0",fontSize:"14px",boxSizing:"border-box"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#6b7280",marginBottom:"4px",display:"block"},children:"County"}),e.jsx("input",{value:c.county,onChange:r=>u(p=>({...p,county:r.target.value})),style:{width:"100%",padding:"8px",backgroundColor:"#1a1f2e",border:"1px solid #2d3748",borderRadius:"6px",color:"#e2e8f0",fontSize:"14px",boxSizing:"border-box"}})]}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("label",{style:{fontSize:"12px",color:"#6b7280",marginBottom:"4px",display:"block"},children:"Description"}),e.jsx("textarea",{value:c.description,onChange:r=>u(p=>({...p,description:r.target.value})),rows:3,style:{width:"100%",padding:"8px",backgroundColor:"#1a1f2e",border:"1px solid #2d3748",borderRadius:"6px",color:"#e2e8f0",fontSize:"14px",resize:"vertical",boxSizing:"border-box"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#6b7280"},children:"Created"}),e.jsx("div",{style:{fontSize:"14px",color:"#e2e8f0"}
1,children:g.createdAt?new Date(g.createdAt).toLocaleString():"Unknown"})]}),g.createdBy&&e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#6b7280"},children:"Created By"}),e.jsx("div",{style:{fontSize:"14px",color:"#e2e8f0"},children:g.createdBy?.username||g.createdBy})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#6b7280"},children:"Status"}),e.jsx("div",{style:{fontSize:"14px",fontWeight:"600",color:N[g.status]||"#6b7280",textTransform:"uppercase"},children:g.status||"Unknown"})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#6b7280"},children:"Priority"}),e.jsx("div",{style:{fontSize:"14px",color:W?.cadSettings?.priorities?.find(p=>p.value===g.priority)?.color||"#e2e8f0",fontWeight:"600"},children:W?.cadSettings?.priorities?.find(p=>p.value===g.priority)?.label||(g.priority||"normal").toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#6b7280"},children:"Location"}),e.jsx("div",{style:{fontSize:"14px",color:"#e2e8f0"},children:g.location||"Not specified"})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#6b7280"},children:"Caller"}),e.jsx("div",{style:{fontSize:"14px",color:"#e2e8f0"},children:g.caller||"Unknown"})]}),(g.city||g.county)&&e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#6b7280"},children:"City / County"}),e.jsx("div",{style:{fontSize:"14px",color:"#e2e8f0"},children:[g.city,g.county].filter(Boolean).join(", ")||"N/A"})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#6b7280"},children:"Created"}),e.jsx("div",{style:{fontSize:"14px",color:"#e2e8f0"},children:g.createdAt?new Date(g.createdAt).toLocaleString():"Unknown"})]}),g.createdBy&&e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#6b7280"},children:"Created By"}),e.jsx("div",{style:{fontSize:"14px",color:"#e2e8f0"},children:g.createdBy?.username||g.createdBy})]}),g.disposition&&e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#6b7280"},children:"Disposition"}),e.jsx("div",{style:{fontSize:"14px",color:"#10b981",fontWeight:"600"},children:g.disposition})]})]}),g.coordinates?.x!=null&&g.coordinates?.y!=null&&(()=>{const{lat:r,lng:p}=vr(g.coordinates.x,g.coordinates.y),C=Mt.divIcon({className:"",html:'<div style="width:14px; height:14px; background:#ef4444; border-radius:50%; border:2px solid #fff; box-shadow:0 2px 6px rgba(0,0,0,0.5);"></div>',iconSize:[14,14],iconAnchor:[7,7]});return e.jsxs("div",{style:{marginTop:"12px"},children:[e.jsxs("label",{style:{fontSize:"12px",color:"#6b7280",display:"flex",alignItems:"center",gap:"6px",marginBottom:"6px"},children:[e.jsx(lt,{style:{color:"#ef4444",fontSize:"11px"}}),"Call Location",e.jsxs("span",{style:{fontFamily:"monospace",color:"#4b5563",fontSize:"11px"},children:[Math.round(g.coordinates.x),", ",Math.round(g.coordinates.y)]})]}),e.jsx("div",{style:{height:"220px",borderRadius:"6px",overflow:"hidden",border:"1px solid #2d3748"},children:e.jsxs(br,{center:[r,p],zoom:5,crs:Mt.CRS.Simple,style:{height:"100%",width:"100%"},minZoom:2,maxZoom:7,zoomControl:!1,attributionControl:!1,children:[e.jsx(jr,{url:"/tiles/{z}_{x}_{y}.jpg",tileSize:256,minZoom:0,maxZoom:7,maxNativeZoom:7,noWrap:!0,errorTileUrl:"/tiles/empty.jpg"}),e.jsx(Nr,{}),e.jsx(kr,{position:[r,p],icon:C})]})})]})})(),g.description&&e.jsxs("div",{style:{marginTop:"12px",padding:"10px",backgroundColor:"rgba(59, 130, 246, 0.08)",borderRadius:"6px",border:"1px solid rgba(59, 130, 246, 0.2)"},children:[e.jsx("label",{style:{fontSize:"12px",color:"#93c5fd",fontWeight:"600"},children:g.callType?.startsWith("Traffic Stop")?"Traffic Stop Details":"Description"}),e.jsx("div",{style:{fontSize:"14px",color:"#e2e8f0",marginTop:"6px",display:"flex",flexDirection:"column",gap:"4px"},children:g.description.split(" | ").map((r,p)=>e.jsx("div",{style:{display:"flex",gap:"6px"},children:r.includes(":")?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{color:"#93c5fd",fontWeight:"500"},children:[r.split(":")[0],":"]}),e.jsx("span",{children:r.split(":").slice(1).join(":").trim()})]}):e.jsx("span",{children:r})},p))})]})]})}
1),e.jsx(Cr,{call:o||U||t,style:{marginTop:0,marginBottom:"16px"}}),e.jsxs("div",{style:{marginTop:"16px"},children:[e.jsxs("label",{style:{fontSize:"14px",color:"#9ca3af",marginBottom:"8px",display:"flex",alignItems:"center"},children:[e.jsx(Ct,{style:{marginRight:"6px"}}),"Add Note"]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("input",{type:"text",value:M,onChange:r=>R(r.target.value),onKeyDown:r=>r.key==="Enter"&&te(),placeholder:"Type a note visible to all units...",style:{flex:1,padding:"12px",backgroundColor:"#0f1419",border:"1px solid #2d3748",borderRadius:"6px",color:"#e2e8f0",fontSize:"14px"}}),e.jsx("button",{onClick:te,disabled:!M.trim(),style:{padding:"12px 20px",backgroundColor:M.trim()?"#3b82f6":"#2d3748",color:"#fff",border:"none",borderRadius:"6px",cursor:M.trim()?"pointer":"not-allowed",fontSize:"14px"},children:"Add"})]})]}),E.length>0&&e.jsxs("div",{style:{marginTop:"16px"},children:[e.jsxs("label",{style:{fontSize:"13px",fontWeight:"600",color:"#9ca3af",marginBottom:"10px",display:"flex",alignItems:"center",textTransform:"uppercase",letterSpacing:"0.05em"},children:[e.jsx(It,{style:{marginRight:"6px"}}),"Notes (",E.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px",maxHeight:"320px",overflowY:"auto",paddingRight:"4px"},children:[...E].reverse().map((r,p)=>{const C=typeof r=="string"?r:r.text||"",v=r.addedBy,X=v?typeof v=="object"?v.displayName||w&&(v.discordNicks?.[w]||v.discordNicks?.get?.(w))||v.username||"Unknown":String(v):"Dispatch",Ce=X[0]?.toUpperCase()||"?",We=r.addedAt?new Date(r.addedAt):null,De=We?We.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"";return e.jsxs("div",{style:{display:"flex",gap:"10px",padding:"12px 14px",backgroundColor:"#1a1f2e",borderRadius:"8px",border:"1px solid #2d3748",borderLeft:"3px solid #3b82f6"},children:[e.jsx("div",{style:{width:"32px",height:"32px",borderRadius:"50%",flexShrink:0,backgroundColor:"#1e3a5f",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"13px",fontWeight:"700",color:"#60a5fa"},children:Ce}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},children:[e.jsx("span",{style:{fontSize:"13px",fontWeight:"600",color:"#93c5fd"},children:X}),e.jsx("span",{style:{fontSize:"11px",color:"#6b7280",whiteSpace:"nowrap",marginLeft:"8px"},children:De})]}),e.jsx("div",{style:{fontSize:"14px",color:"#e2e8f0",lineHeight:"1.55",wordBreak:"break-word"},children:C})]})]},r._id||p)})})]})]}),S==="units"&&e.jsxs("div",{children:[e.jsxs("h4",{style:{color:"#e2e8f0",marginBottom:"12px",fontSize:"16px",display:"flex",alignItems:"center"},children:[e.jsx(Wt,{style:{marginRight:"8px"}}),"Assigned Units"]}),ne.length>0?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:ne.map((r,p)=>{const C=r.unitId||{},v=r.callSign||C.callSign,X=C.displayName||C.username||"Unknown",Ce=v||X;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"14px",backgroundColor:"#0f1419",borderRadius:"8px",border:"1px solid #2d3748",borderLeft:`4px solid ${a[r.status]||"#3b82f6"}`},children:[e.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"50%",backgroundColor:a[r.status]||"#3b82f6",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(Wt,{style:{color:"#fff",fontSize:"16px"}})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:"15px",color:"#e2e8f0",fontWeight:"600"},children:Ce}),v&&e.jsx("div",{style:{fontSize:"12px",color:"#9ca3af"},children:X})]}),e.jsxs("div",{style:{textAlign:"right"},children:[e.jsx("div",{style:{padding:"4px 10px",borderRadius:"4px",backgroundColor:`${a[r.status]||"#3b82f6"}20`,color:a[r.status]||"#3b82f6",fontSize:"12px",fontWeight:"600",textTransform:"uppercase"},children:r.status||"assigned"}),e.jsx("div",{style:{fontSize:"11px",color:"#6b7280",marginTop:"4px"},children:r.assignedAt?new Date(r.assignedAt).toLocaleString():""}),r.assignedAt&&e.jsx("div",{style:{fontSize:"11px",marginTop:"2px"},children:e.jsx(Vr,{since:r.assignedAt})})]})]},r._id||p)})}):e.jsx("div",{style:{padding:"40px",textAlign:"center",color:"#6b7280",backgroundColor:"#0f1419",borderRadius:"8px"},children:"No units assigned to this call"})]}),S==="involved"&&e.jsxs("div",{children:[e.jsxs("h4",{style:{color:"#e2e8f0",marginBottom:"12px",fontSize:"16px",display:"flex",alignItems:"center"},children:[e.jsx(we,{style:{marginRight:"8px"}}),"Civilians (",G.length,")"]}),G.length>0?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px",marginBottom:"20px"},children:G.map((r,p)=>e.jsxs("div",{onClick:()=>
1{if(f){const C=`${r.firstName||""} ${r.lastName||""}`.trim();C&&f(C,"civilian")}},style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px",backgroundColor:"#0f1419",borderRadius:"8px",border:"1px solid #2d3748",cursor:f?"pointer":"default",transition:"border-color 0.15s"},onMouseEnter:C=>f&&(C.currentTarget.style.borderColor="#3b82f6"),onMouseLeave:C=>f&&(C.currentTarget.style.borderColor="#2d3748"),children:[e.jsx("div",{style:{width:"36px",height:"36px",borderRadius:"6px",backgroundColor:"#3b82f6",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(we,{style:{color:"#fff",fontSize:"14px"}})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{fontSize:"14px",color:"#e2e8f0",fontWeight:"500"},children:[r.firstName||""," ",r.lastName||""]}),e.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:[r.licenseNumber,r.phone].filter(Boolean).join(" ⢠")||"No additional info"})]}),(r.warrants?.length>0||r.missingPerson)&&e.jsxs("div",{style:{display:"flex",gap:"6px"},children:[r.warrants?.length>0&&e.jsx("span",{style:{padding:"2px 8px",borderRadius:"4px",backgroundColor:"#dc262620",color:"#ef4444",fontSize:"11px",fontWeight:"600"},children:"WARRANTS"}),r.missingPerson&&e.jsx("span",{style:{padding:"2px 8px",borderRadius:"4px",backgroundColor:"#f59e0b20",color:"#f59e0b",fontSize:"11px",fontWeight:"600"},children:"MISSING"})]}),f&&e.jsx(be,{style:{color:"#6b7280",fontSize:"12px",flexShrink:0}})]},r._id||p))}):e.jsx("div",{style:{padding:"20px",textAlign:"center",color:"#6b7280",backgroundColor:"#0f1419",borderRadius:"8px",marginBottom:"20px"},children:"No civilians linked"}),e.jsxs("h4",{style:{color:"#e2e8f0",marginBottom:"12px",fontSize:"16px",display:"flex",alignItems:"center"},children:[e.jsx(Ne,{style:{marginRight:"8px"}}),"Vehicles (",se.length,")"]}),se.length>0?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px",marginBottom:"20px"},children:se.map((r,p)=>e.jsxs("div",{onClick:()=>{f&&r.plate&&f(r.plate,"vehicle")},style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px",backgroundColor:"#0f1419",borderRadius:"8px",border:"1px solid #2d3748",cursor:f&&r.plate?"pointer":"default",transition:"border-color 0.15s"},onMouseEnter:C=>f&&r.plate&&(C.currentTarget.style.borderColor="#f59e0b"),onMouseLeave:C=>f&&(C.currentTarget.style.borderColor="#2d3748"),children:[e.jsx("div",{style:{width:"36px",height:"36px",borderRadius:"6px",backgroundColor:"#f59e0b",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(Ne,{style:{color:"#fff",fontSize:"14px"}})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:"14px",color:"#e2e8f0",fontWeight:"500"},children:r.plate||"No plate"}),e.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:[r.color,r.year,r.make,r.model].filter(Boolean).join(" ")||"Unknown vehicle"})]}),(r.stolen||r.impounded)&&e.jsxs("div",{style:{display:"flex",gap:"6px"},children:[r.stolen&&e.jsx("span",{style:{padding:"2px 8px",borderRadius:"4px",backgroundColor:"#dc262620",color:"#ef4444",fontSize:"11px",fontWeight:"600"},children:"STOLEN"}),r.impounded&&e.jsx("span",{style:{padding:"2px 8px",borderRadius:"4px",backgroundColor:"#f59e0b20",color:"#f59e0b",fontSize:"11px",fontWeight:"600"},children:"IMPOUNDED"})]}),f&&r.plate&&e.jsx(be,{style:{color:"#6b7280",fontSize:"12px",flexShrink:0}})]},r._id||p))}):e.jsx("div",{style:{padding:"20px",textAlign:"center",color:"#6b7280",backgroundColor:"#0f1419",borderRadius:"8px",marginBottom:"20px"},children:"No vehicles linked"}),y&&y.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{style:{color:"#e2e8f0",marginBottom:"12px",fontSize:"16px",display:"flex",alignItems:"center"},children:[e.jsx(gt,{style:{marginRight:"8px"}}),"Attach from Recent Lookups"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px",maxHeight:"250px",overflowY:"auto"},children:y.slice(0,10).map((r,p)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 12px",backgroundColor:"#0f1419",borderRadius:"8px",border:"1px solid #2d3748"},children:[e.jsx("div",{style:{width:"32px",height:"32px",borderRadius:"6px",backgroundColor:r.lookupType==="civilian"?"#3b82f6":"#f59e0b",display:"flex",alignItems:"center",justifyContent:"center"},children:r.lookupType==="civilian"?e.jsx(we,{style:{color:"#fff",fontSize:"12px"}}):e.jsx(Ne,{style:{color:"#fff",fontSize:"12px"}})}),e.jsx("div",{style:{flex:1},children:e.jsx("div",{style:{fontSize:"13px",color:"#e2e8f0"},children:r.lookupType==="civilian"?r.snapshot?.name||`${r.snapshot?.firstName||""} ${r.snapshot?.lastName||""}`.trim()||"Unknown":r.snapshot?.plate||"Unknown"})}),e.jsx("button",{onClick:()=>ae(r),style:{padding:"6px 14px",backgroundColor:"#10b981",color:"#fff",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"12px",fontWeight:"500"},children:"Attach"})]},p))})]})]})]})})]})})},Wr=({loading:t,disabled:o,onClick:h,themeStyles:n})=>e.jsx("button",{type:"button",onClick:h,disabled:t||o,style:{...n.touchButton,padding:"0 18px",backgroundColor:t||o?"#374151":n.primary,color:"#fff",border:"none",opacity:t||o?.6:1,flexShrink:0},children:t?e.jsx(Re,{style:{animation:"spin 1s linear infinite"}}):e.jsx(be,{})}),Er=({onLog:t,onClose:o,themeStyles:h})=>{const{activeCommunity:n}=ft(),y=n?.cadSettings?.licenseFormat?.vehicle||"",k=n?._id,w=n?.cadSettings?.enableTrafficStopDetails!==!1,[f,m]=l.useState({plate:"",make:"",model:"",color:"",year:"",road:"",postal:"",notes:"",occupants:"1"}),[W,M]=l.useState(!1),[R,S]=l.useState(!1),[P,U]=l.useState(!1),ee=async()=>
1{if(f.plate.trim()){M(!0),S(!1);try{const{data:j}=await Z.post("/lookup",{query:f.plate.trim(),type:"plate",communityId:k}),_=(Array.isArray(j)?j:[]).find(c=>c.plate?.replace(/\s/g,"").toUpperCase()===f.plate.replace(/\s/g,"").toUpperCase());_?(m(c=>({...c,make:_.make||c.make,model:_.model||c.model,color:_.color||c.color,year:_.year?String(_.year):c.year})),S(!0)):F.warning("No vehicle found with this plate")}catch(j){F.error(je(j,"Plate lookup failed"))}finally{M(!1)}}},q={...h.modalInput,marginBottom:0};return e.jsxs(Ke,{onClose:o,themeStyles:h,children:[e.jsx("h3",{style:{fontSize:"22px",marginBottom:"16px"},children:"Log Traffic Stop"}),e.jsxs("form",{onSubmit:j=>{if(j.preventDefault(),!P){if(!f.plate||!f.road){F.warning("Plate and road are required.");return}U(!0),t({...f})}},children:[e.jsxs("div",{style:{display:"flex",gap:"10px"},children:[e.jsx("input",{type:"text",placeholder:y?`Plate * (e.g. ${y})`:"License Plate *",value:f.plate,required:!0,onChange:j=>{m({...f,plate:j.target.value}),S(!1)},onKeyDown:j=>j.key==="Enter"&&(j.preventDefault(),ee()),style:{...q,flex:1}}),e.jsx(Wr,{loading:W,disabled:!f.plate.trim(),onClick:ee,themeStyles:h})]}),R&&e.jsxs("div",{style:{color:"#4ade80",fontSize:"12px",margin:"4px 0"},children:[e.jsx(dt,{style:{verticalAlign:"middle",marginRight:4}}),"Vehicle autofilled"]}),e.jsx("div",{style:{marginTop:"12px"},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"10px"},children:[e.jsx("input",{type:"text",placeholder:"Make",value:f.make,onChange:j=>m({...f,make:j.target.value}),style:q}),e.jsx("input",{type:"text",placeholder:"Model",value:f.model,onChange:j=>m({...f,model:j.target.value}),style:q}),e.jsx("input",{type:"text",placeholder:"Color",value:f.color,onChange:j=>m({...f,color:j.target.value}),style:q}),e.jsx("input",{type:"text",placeholder:"Year",value:f.year,onChange:j=>m({...f,year:j.target.value}),style:q})]})}),e.jsxs("div",{style:{marginTop:"10px",display:"flex",flexDirection:"column",gap:"10px"},children:[e.jsx(pr,{placeholder:"Road/Street Name *",value:f.road,onChange:j=>m({...f,road:j.target.value}),style:q,communityId:k,required:!0}),e.jsx("input",{type:"text",placeholder:"Postal Code",value:f.postal,onChange:j=>m({...f,postal:j.target.value}),style:q})]}),w&&e.jsx("div",{style:{marginTop:"10px",display:"flex",flexDirection:"column",gap:"10px"},children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"flex-start"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:{fontSize:"12px",color:"#9ca3af",marginBottom:"4px",display:"block"},children:"Reason / Notes"}),e.jsx("input",{type:"text",placeholder:"e.g. Speeding, expired tabs, reckless driving",value:f.notes,onChange:j=>m({...f,notes:j.target.value}),style:q})]}),e.jsxs("div",{style:{width:"80px",flexShrink:0},children:[e.jsx("label",{style:{fontSize:"12px",color:"#9ca3af",marginBottom:"4px",display:"block"},children:"Occupants"}),e.jsx("select",{value:f.occupants,onChange:j=>m({...f,occupants:j.target.value}),style:{...q,width:"100%"},children:[1,2,3,4,5,6,7,8].map(j=>e.jsxs("option",{value:String(j),children:[j,"x"]},j))})]})]})}),e.jsxs("div",{style:{display:"flex",gap:"14px",marginTop:"20px"},children:[e.jsx("button",{type:"button",onClick:o,style:{...h.touchButton,flex:1,backgroundColor:"#2d3748",border:"none"},children:"Cancel"}),e.jsx("button",{type:"submit",disabled:P,style:{...h.touchButton,backgroundColor:h.primary,color:"#fff",flex:1,border:"none",opacity:P?.6:1},children:P?"Logging...":"Log Stop"})]})]})]})},$r=({onClose:t,onSubmit:o,themeStyles:h,communityId:n})=>{const y=xr(),k=gr({communityId:n}),{apply:w}=k,[f,m]=l.useState({location:"",postal:"",city:"",county:"",crossStreets:"",coordinates:null,description:"",callerName:"",callerPhone:""}),W=l.useMemo(()=>zs(y.cadSettings?.priorities),[y.cadSettings?.priorities]),[M,R]=l.useState(!1),[S,P]=l.useState([]),[U,ee]=l.useState([]),[q,j]=l.useState(!1),[V,_]=l.useState(!1),c=l.useRef(null),u=l.useRef(null);l.useEffect(()=>{m(B=>w(B))},[w]);const A=(B,g)=>g.length>0?B.filter(E=>E.toLowerCase().includes(g.toLowerCase())).slice(0,8):B.slice(0,8),oe=B=>{m(E=>({...E,city:B}));const g=A(k.cities,B);P(g),j(g.length>0)},$=B=>{m(E=>({...E,county:B}));const g=A(k.counties,B);ee(g),_(g.length>0)};l.useEffect(()=>{const B=g=>{c.current&&!c.current.contains(g.target)&&j(!1),u.current&&!u.current.contains(g.target)&&_(!1)};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[]);const ge=async B=>{B.preventDefault();const g=y.callType.trim();if(!g||!f.location.trim()){F.warning("Please fill in Call Type and Location");return}R(!0);try{await o({callType:g,location:f.location.trim(),postal:f.postal,city:f.city,county:f.county,callerName:f.callerName.trim()||"911 Caller",callerPhone:f.callerPhone.trim(),description:f.description.trim(),priority:y.priority}),t()}catch(E){console.error("Error creating call:",E),F.error("Failed to create call: "+(E?.response?.data?.message||E?.response?.data?.msg||E.message||"Unknown error"))}finally{R(!1)}},te={fontSize:"12px",color:"#9ca3af",textTransform:"uppercase",display:"block",marginBottom:"6px"},ae={...h.modalInput,marginBottom:0},ce={position:"absolute",top:"100%",left:0,right:0,zIndex:1e3,backgroundColor:"#1a1f2e",border:"1px solid #4a5568",borderTop:"none",borderRadius:"0 0 6px 6px",maxHeight:"160px",overflowY:"auto",boxShadow:"0 4px 12px rgba(0,0,0,0.4)"};return e.jsxs(Ke,{onClose:t,themeStyles:h,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px"},children:[e.jsxs("h3",{style:{margin:0,fontSize:"1.25rem",fontWeight:"600",display:"flex",alignItems:"center"},children:[e.jsx(Yt,{style:{marginRight:"8px",color:"#3b82f6",flexShrink:0}}),"Create 911 Call"]}),e.jsx("button",{type:"button","aria-label":"Close",onClick:t,style:{background:"none",border:"none",color:"#e2e8f0",fontSize:"24px",cursor:"pointer"},children:e.jsx(Qe,{})})]}),e.jsxs("form",{onSubmit:ge,children:[e.jsxs("div",{style:{display:"grid",gap:"16px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:te,children:"Priority Level *"}),e.jsx("div",{role:"group","aria-label":"Priority",style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(96px, 1fr))",gap:"8px"},children:W.map(B=>{const g=y.priority===B.value,E=Bs(B);
1return e.jsx("button",{type:"button","aria-pressed":g,"data-priority":B.value,onClick:()=>y.setPriority(B.value),style:{minWidth:0,padding:"10px 8px",backgroundColor:g?E.background:"#1a1f2e",color:g?E.color:"#fff",border:`2px solid ${g?E.background:"#2d3748"}`,borderRadius:"6px",cursor:"pointer",fontWeight:"600",fontSize:"13px",lineHeight:1.25,whiteSpace:"normal"},children:B.label},B.value)})})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"d3-nc-type",style:te,children:"Call Type *"}),e.jsx(ur,{id:"d3-nc-type",value:y.callType,onChange:y.setCallType,placeholder:"Start typing call type...",inputStyle:ae,required:!0})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:"12px"},children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"d3-nc-location",style:te,children:"Location / Address *"}),e.jsx(fr,{id:"d3-nc-location",value:f.location,onChange:B=>m(g=>({...g,location:B})),onResolved:B=>m(g=>hr(g,B,k.defaults)),communityId:n,style:ae,placeholder:"123 Main St, Los Santos",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"d3-nc-postal",style:te,children:"Postal Code"}),e.jsx("input",{id:"d3-nc-postal",type:"text",value:f.postal,onChange:B=>m(g=>({...g,postal:B.target.value})),style:ae,placeholder:"123"})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[e.jsxs("div",{ref:c,style:{position:"relative"},children:[e.jsx("label",{htmlFor:"d3-nc-city",style:te,children:"City"}),e.jsx("input",{id:"d3-nc-city",type:"text",value:f.city,onChange:B=>oe(B.target.value),onFocus:()=>oe(f.city),style:ae,placeholder:"Start typing city...",autoComplete:"off"}),q&&S.length>0&&e.jsx("div",{style:ce,children:S.map((B,g)=>e.jsx("div",{onMouseDown:E=>{E.preventDefault(),m(G=>({...G,city:B})),j(!1)},style:{padding:"8px 12px",cursor:"pointer",fontSize:"14px",color:"#e2e8f0",borderBottom:g<S.length-1?"1px solid #2d3748":"none"},onMouseEnter:E=>E.target.style.backgroundColor="#2d3748",onMouseLeave:E=>E.target.style.backgroundColor="transparent",children:B},B))})]}),e.jsxs("div",{ref:u,style:{position:"relative"},children:[e.jsx("label",{htmlFor:"d3-nc-county",style:te,children:"County"}),e.jsx("input",{id:"d3-nc-county",type:"text",value:f.county,onChange:B=>$(B.target.value),onFocus:()=>$(f.county),style:ae,placeholder:"Start typing county...",autoComplete:"off"}),V&&U.length>0&&e.jsx("div",{style:ce,children:U.map((B,g)=>e.jsx("div",{onMouseDown:E=>{E.preventDefault(),m(G=>({...G,county:B})),_(!1)},style:{padding:"8px 12px",cursor:"pointer",fontSize:"14px",color:"#e2e8f0",borderBottom:g<U.length-1?"1px solid #2d3748":"none"},onMouseEnter:E=>E.target.style.backgroundColor="#2d3748",onMouseLeave:E=>E.target.style.backgroundColor="transparent",children:B},B))})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"d3-nc-caller",style:te,children:"Caller Name"}),e.jsx(Kt,{id:"d3-nc-caller",value:f.callerName,onChange:B=>m(g=>({...g,callerName:B})),onSelect:B=>m(g=>({...g,callerName:`${B.firstName} ${B.lastName}`.trim(),callerPhone:B.phone||g.callerPhone})),communityId:n,themeStyles:{modalInput:ae},placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"d3-nc-phone",style:te,children:"Caller Phone"}),e.jsx("input",{id:"d3-nc-phone",type:"text",value:f.callerPhone,onChange:B=>m(g=>({...g,callerPhone:B.target.value})),style:ae,placeholder:"555-1234"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"d3-nc-description",style:te,children:"Description / Details"}),e.jsx("textarea",{id:"d3-nc-description",value:f.description,onChange:B=>m(g=>({...g,description:B.target.value})),style:{...h.modalInput,minHeight:"100px",resize:"vertical",marginBottom:0},placeholder:"Provide details about the incident..."})]})]}),e.jsxs("div",{style:{marginTop:"24px",display:"flex",justifyContent:"flex-end",gap:"12px"},children:[e.jsx("button",{type:"button",onClick:t,style:h.modalButton,children:"Cancel"}),e.jsx("button",{type:"submit",disabled:M,style:{...h.modalButton,backgroundColor:"#3b82f6",color:"#fff",opacity:M?.6:1,cursor:M?"not-allowed":"pointer"},children:M?"Creating...":"Create Call"})]})]})]})},Mr=({onClose:t,themeStyles:o,activeCommunityId:h,user:n,userRoles:y})=>{const{activeCommunity:k}=ft(),w=k?.cadSettings?.licenseFormat||{},[f,m]=l.useState([]),[W,M]=l.useState(!0),[R,S]=l.useState("active"),[P,U]=l.useState(!1),[ee,q]=l.useState(null),[j,V]=l.useState(!1),[_,c]=l.useState(""),[u,A]=l.useState({type:"person",priority:"medium",reason:"",description:"",subjectFirstName:"",subjectLastName:"",subjectDOB:"",subjectLicense:"",vehiclePlate:"",vehicleMake:"",vehicleModel:"",vehicleColor:"",vehicleYear:""}),oe=k?.cadSettings?.boloPermission||"supervisor",$=y.isSuperAdmin||y.isCommunityAdmin,ge=$||y.isSupervisor,te=oe==="all"?!0:oe==="supervisor"?ge:$;l.useEffect(()=>{h&&(M(!0),ae())},[R,h]);const ae=async()=>{try{const r=await Z.get("/bolos",{params:{communityId:h,activeOnly:R==="active"?"true":"false"}});m(Array.isArray(r.data)?r.data:[])}catch(r){console.error("Error fetching BOLOs:",r),m([])}finally{M(!1)}},ce=r=>{A(p=>({...p,subjectFirstName:r.firstName||p.subjectFirstName,subjectLastName:r.lastName||p.subjectLastName,subjectDOB:r.dateOfBirth?new Date(r.dateOfBirth).toISOString().split("T")[0]:p.subjectDOB,subjectLicense:r.licenseNumber||p.subjectLicense})),c(`${r.firstName} ${r.lastName}`)},B=async()=>
1{if(!u.subjectLicense){F.warning("Please enter a license number to lookup");return}V(!0);try{const{data:r}=await Z.post("/lookup",{query:u.subjectLicense,type:"license",communityId:h}),p=r.find(C=>C.licenseNumber===u.subjectLicense||C.driversLicense===u.subjectLicense);p?ce(p):F.warning("No person found with this license number")}catch{F.warning("Error looking up person")}finally{V(!1)}},g=async()=>{if(!u.vehiclePlate){F.warning("Please enter a license plate to lookup");return}V(!0);try{const{data:r}=await Z.post("/lookup",{query:u.vehiclePlate,type:"plate",communityId:h}),p=r.find(C=>C.plate&&C.plate.replace(/\s/g,"").toUpperCase()===u.vehiclePlate.replace(/\s/g,"").toUpperCase());p?A(C=>({...C,vehicleMake:p.make||C.vehicleMake,vehicleModel:p.model||C.vehicleModel,vehicleColor:p.color||C.vehicleColor,vehicleYear:p.year||C.vehicleYear})):F.warning("No vehicle found with this plate number")}catch(r){F.error(je(r,"Error looking up vehicle"))}finally{V(!1)}},E=async r=>{if(r.preventDefault(),!u.reason||!u.description){F.warning("Please provide both reason and description for the BOLO");return}const p=u.subjectFirstName||u.subjectLastName||u.subjectLicense,C=u.vehiclePlate;if(!p&&!C){F.warning("Either subject information or vehicle information must be provided");return}const v={reason:u.reason,description:u.description,priority:u.priority||"medium",communityId:h,subjectFirstName:u.subjectFirstName||void 0,subjectLastName:u.subjectLastName||void 0,subjectDOB:u.subjectDOB||void 0,subjectLicense:u.subjectLicense||void 0,subjectDescription:u.subjectDescription||void 0,vehiclePlate:u.vehiclePlate||void 0,vehicleMake:u.vehicleMake||void 0,vehicleModel:u.vehicleModel||void 0,vehicleColor:u.vehicleColor||void 0,vehicleYear:u.vehicleYear||void 0,vehicleDescription:u.vehicleDescription||void 0};Object.keys(v).forEach(X=>{v[X]===void 0&&delete v[X]});try{ee?await Pt(ee._id,v):await Ds(v),ae(),U(!1),q(null),A({type:"person",priority:"medium",reason:"",description:"",subjectFirstName:"",subjectLastName:"",subjectDOB:"",subjectLicense:"",vehiclePlate:"",vehicleMake:"",vehicleModel:"",vehicleColor:"",vehicleYear:""}),c("")}catch(X){console.error("Error saving BOLO:",X),F.error(`Failed to save BOLO: ${X.response?.data?.message||X.message}`)}},G=r=>{q(r),A(r),c(r.subjectFirstName&&r.subjectLastName?`${r.subjectFirstName} ${r.subjectLastName}`:""),U(!0)},se=async r=>{F.warn(e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:"10px"},children:"Remove this BOLO?"}),e.jsxs("div",{style:{display:"flex",gap:"10px"},children:[e.jsx("button",{onClick:async()=>{F.dismiss();try{await Rs(r),await ae(),F.success("BOLO removed successfully!")}catch(p){F.error(je(p,"Failed to delete BOLO"))}},style:{padding:"6px 16px",backgroundColor:"#dc2626",color:"#fff",border:"none",borderRadius:"4px",cursor:"pointer"},children:"Delete"}),e.jsx("button",{onClick:()=>F.dismiss(),style:{padding:"6px 16px",backgroundColor:"#374151",color:"#fff",border:"none",borderRadius:"4px",cursor:"pointer"},children:"Cancel"})]})]}),{autoClose:!1,closeOnClick:!1,draggable:!1,closeButton:!1})},ne=async r=>{try{await Pt(r._id,{...r,isActive:!1}),ae()}catch(p){console.error("Error deactivating BOLO:",p)}},N=async r=>{try{const p=await Z.get(`/bolos/${r}/pdf`,{responseType:"blob"}),C=new Blob([p.data],{type:"application/pdf"}),v=URL.createObjectURL(C);window.open(v,"_blank"),setTimeout(()=>URL.revokeObjectURL(v),6e4)}catch(p){console.error("Error printing BOLO:",p),F.error(je(p,"Failed to generate BOLO PDF"))}},a=f.filter(r=>r.isActive!==!1),I=f.filter(r=>r.isActive===!1);return e.jsxs(Ke,{onClose:t,themeStyles:o,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px"},children:[e.jsx("h3",{style:{margin:0,fontSize:"22px"},children:"BOLO Management"}),e.jsx("button",{onClick:t,style:{background:"none",border:"none",color:"#e2e8f0",fontSize:"28px",cursor:"pointer",padding:"12px",minWidth:"48px",minHeight:"48px"},children:e.jsx(Qe,{})})]}),P?e.jsxs("form",{onSubmit:E,children:[e.jsx("h4",{style:{marginBottom:"24px",fontSize:"20px"},children:ee?"Edit BOLO":"Create New BOLO"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"14px"}
1,children:[e.jsxs("select",{value:u.type,onChange:r=>A({...u,type:r.target.value}),style:o.modalInput,children:[e.jsx("option",{value:"person",children:"Person"}),e.jsx("option",{value:"vehicle",children:"Vehicle"}),e.jsx("option",{value:"both",children:"Both"})]}),e.jsxs("select",{value:u.priority,onChange:r=>A({...u,priority:r.target.value}),style:o.modalInput,children:[e.jsx("option",{value:"low",children:"Low Priority"}),e.jsx("option",{value:"medium",children:"Medium Priority"}),e.jsx("option",{value:"high",children:"High Priority"})]})]}),e.jsx("input",{type:"text",placeholder:"Reason for BOLO *",value:u.reason,onChange:r=>A({...u,reason:r.target.value}),style:o.modalInput,required:!0}),e.jsx("textarea",{placeholder:"Description (Required) *",value:u.description,onChange:r=>A({...u,description:r.target.value}),style:{...o.modalInput,minHeight:"120px",resize:"vertical"},required:!0}),(u.type==="person"||u.type==="both")&&e.jsxs(e.Fragment,{children:[e.jsx("h5",{style:{marginTop:"24px",marginBottom:"14px",fontSize:"18px"},children:"Subject Information"}),e.jsxs("div",{style:{marginBottom:"14px"},children:[e.jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"14px"},children:"Search for Person"}),e.jsx(Kt,{value:_,onChange:c,onSelect:ce,communityId:h,themeStyles:o,placeholder:"Type name to search civilians..."})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"14px"},children:[e.jsx("input",{type:"text",placeholder:"First Name",value:u.subjectFirstName,onChange:r=>A({...u,subjectFirstName:r.target.value}),style:o.modalInput}),e.jsx("input",{type:"text",placeholder:"Last Name",value:u.subjectLastName,onChange:r=>A({...u,subjectLastName:r.target.value}),style:o.modalInput}),e.jsx("input",{type:"date",placeholder:"Date of Birth",value:u.subjectDOB,onChange:r=>A({...u,subjectDOB:r.target.value}),style:o.modalInput}),e.jsxs("div",{style:{display:"flex",gap:"10px"},children:[e.jsx("input",{type:"text",placeholder:w.drivers?`License Number (e.g. ${w.drivers})`:"License Number",value:u.subjectLicense,onChange:r=>A({...u,subjectLicense:r.target.value}),style:{...o.modalInput,flex:1}}),e.jsx("button",{type:"button",onClick:B,disabled:j||!u.subjectLicense,style:{...o.modalButton,margin:0,padding:"0 20px",backgroundColor:j||!u.subjectLicense?"#6b7280":o.primary,color:"#fff",opacity:j||!u.subjectLicense?.6:1,minWidth:"52px"},children:e.jsx(be,{})})]})]})]}),(u.type==="vehicle"||u.type==="both")&&e.jsxs(e.Fragment,{children:[e.jsx("h5",{style:{marginTop:"24px",marginBottom:"14px",fontSize:"18px"},children:"Vehicle Information"}),e.jsxs("div",{style:{display:"flex",gap:"10px",marginBottom:"14px"},children:[e.jsx("input",{type:"text",placeholder:w.vehicle?`License Plate (e.g. ${w.vehicle})`:"License Plate",value:u.vehiclePlate,onChange:r=>A({...u,vehiclePlate:r.target.value}),style:{...o.modalInput,flex:1}}),e.jsx("button",{type:"button",onClick:g,disabled:j||!u.vehiclePlate,style:{...o.modalButton,margin:0,padding:"0 20px",backgroundColor:j||!u.vehiclePlate?"#6b7280":o.primary,color:"#fff",opacity:j||!u.vehiclePlate?.6:1,minWidth:"52px"},children:e.jsx(be,{})})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"14px"},children:[e.jsx("input",{type:"text",placeholder:"Make",value:u.vehicleMake,onChange:r=>A({...u,vehicleMake:r.target.value}),style:o.modalInput}),e.jsx("input",{type:"text",placeholder:"Model",value:u.vehicleModel,onChange:r=>A({...u,vehicleModel:r.target.value}),style:o.modalInput}),e.jsx("input",{type:"text",placeholder:"Color",value:u.vehicleColor,onChange:r=>A({...u,vehicleColor:r.target.value}),style:o.modalInput}),e.jsx("input",{type:"text",placeholder:"Year",value:u.vehicleYear,onChange:r=>A({...u,vehicleYear:r.target.value}),style:o.modalInput})]})]}),e.jsxs("div",{style:{display:"flex",gap:"14px",marginTop:"32px"},children:[e.jsx("button",{type:"button",onClick:()=>{U(!1),c("")},style:{...o.touchButton,flex:1,backgroundColor:"#2d3748",border:"none"},children:"Cancel"}),e.jsx("button",{type:"submit",style:{...o.touchButton,backgroundColor:o.primary,color:"#fff",flex:1,border:"none"},children:ee?"Update BOLO":"Create BOLO"})]})]}):e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",gap:"10px",marginBottom:"24px",flexWrap:"wrap"},children:[e.jsxs("button",{onClick:()=>S("active"),style:{...o.touchButton,backgroundColor:R==="active"?"#2d3748":"#1a1f2e",minWidth:"120px",flex:1},children:["Active (",a.length,")"]}),e.jsxs("button",{onClick:()=>S("inactive"),style:{...o.touchButton,backgroundColor:R==="inactive"?"#2d3748":"#1a1f2e",minWidth:"120px",flex:1},children:["Inactive (",I.length,")"]}),te&&e.jsxs("button",{onClick:()=>U(!0),style:{...o.touchButton,backgroundColor:o.success,color:"#fff",border:"none",minWidth:"160px"},children:[e.jsx(gt,{})," Create BOLO"]})]}),W?e.jsx("p",{style:{textAlign:"center",padding:"48px",fontSize:"16px",color:"#9ca3af"},children:"Loading BOLOs..."}):(R==="active"?a:I).length>0?(R==="active"?a:I).map(r=>{const p=r.subjectFirstName||r.subjectLastName||r.subjectLicense,C=r.vehiclePlate,v=p&&C?"BOTH":p?"PERSON":"VEHICLE",X=r.priority==="high"?"#ef4444":r.priority==="medium"?"#f59e0b":"#10b981",Ce=p||C;return e.jsxs("div",{style:{backgroundColor:"#111827",borderRadius:"8px",marginBottom:"10px",borderLeft:`4px solid ${X}`,overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",borderBottom:Ce||r.description?"1px solid #1f2937":"none"},children:[e.jsx("span",{style:{padding:"2px 7px",borderRadius:"4px",fontSize:"11px",fontWeight:"700",letterSpacing:"0.04em",backgroundColor:X,color:r.priority==="medium"?"#000":"#fff",flexShrink:0},children:(r.priority||"medium").toUpperCase()}),e.jsx("span",{style:{padding:"2px 7px",borderRadius:"4px",fontSize:"11px",fontWeight:"600",backgroundColor:"#1f2937",color:"#9ca3af",flexShrink:0},children:v}),e.jsx("span",{style:{flex:1,fontWeight:"600",fontSize:"14px",color:"#f9fafb",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.reason||"No reason"}),e.jsx("span",{style:{fontSize:"11px",color:"#4b5563",flexShrink:0},children:r.issuedBy||"Unknown"}),e.jsxs("div",{style:{display:"flex",gap:"5px",flexShrink:0},children:[e.jsx("button",{onClick:()=>N(r._id),title:"Print poster",style:{padding:"5px 9px",backgroundColor:"#1f2937",color:"#d1d5db",border:"none",borderRadius:"5px",cursor:"pointer",fontSize:"13px",lineHeight:1},children:e.jsx(Ms,{})}),te&&e.jsxs(e.Fragment,{children:[R==="active"&&e.jsx("button",{onClick:()=>ne(r),title:"Deactivate",style:{padding:"5px 9px",backgroundColor:"#78350f",color:"#fcd34d",border:"none",borderRadius:"5px",cursor:"pointer",fontSize:"13px",lineHeight:1},children:e.jsx(Us,{})}),e.jsx("button",{onClick:()=>G(r),title:"Edit",style:{padding:"5px 9px",backgroundColor:"#1e3a5f",color:"#93c5fd",border:"none",borderRadius:"5px",cursor:"pointer",fontSize:"13px",lineHeight:1},children:e.jsx(Ct,{})}),e.jsx("button",{onClick:()=>se(r._id),title:"Delete",style:{padding:"5px 9px",backgroundColor:"#450a0a",color:"#fca5a5",border:"none",borderRadius:"5px",cursor:"pointer",fontSize:"13px",lineHeight:1},children:e.jsx(zt,{})})]})]})]}),Ce&&e.jsxs("div",{style:{display:"grid",gridTemplateColumns:p&&C?"1fr 1fr":"1fr",gap:"1px",backgroundColor:"#1f2937"},children:[p&&e.jsxs("div",{style:{padding:"10px 14px",backgroundColor:"#111827"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"10px",fontWeight:"700",color:"#6b7280",letterSpacing:"0.08em",textTransform:"uppercase",marginBottom:"5px"},children:[e.jsx(we,{style:{fontSize:"9px"}})," Subject"]}),e.jsx("div",{style:{fontWeight:"600",fontSize:"14px",color:"#f9fafb"}
1,children:[r.subjectFirstName,r.subjectLastName].filter(Boolean).join(" ")||"Unknown"}),e.jsx("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"2px"},children:[r.subjectDOB&&`DOB: ${new Date(r.subjectDOB).toLocaleDateString()}`,r.subjectLicense&&`ID: ${r.subjectLicense}`].filter(Boolean).join(" · ")})]}),C&&e.jsxs("div",{style:{padding:"10px 14px",backgroundColor:"#111827"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"10px",fontWeight:"700",color:"#6b7280",letterSpacing:"0.08em",textTransform:"uppercase",marginBottom:"5px"},children:[e.jsx(Bt,{style:{fontSize:"10px"}})," Vehicle"]}),e.jsx("div",{style:{fontWeight:"700",fontSize:"14px",color:"#f9fafb",letterSpacing:"0.06em"},children:r.vehiclePlate}),e.jsx("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"2px"},children:[r.vehicleYear,r.vehicleColor,r.vehicleMake,r.vehicleModel].filter(Boolean).join(" ")||"-"})]})]}),r.description&&e.jsx("div",{style:{padding:"8px 14px",fontSize:"12px",color:"#6b7280",borderTop:"1px solid #1f2937",lineHeight:1.5},children:r.description})]},r._id)}):e.jsxs("div",{style:{textAlign:"center",padding:"60px",color:"#4b5563",fontSize:"15px"},children:["No ",R," BOLOs"]})]})]})},Ur=({active:t,onSelect:o,themeStyles:h,statusMap:n=Tt})=>{const[y,k]=l.useState(null);return e.jsx("div",{className:"cad-status-sidebar",style:h.statusSidebar,children:n.map(({ui:w,text:f,api:m,actualStatus:W,code:M,color:R,bgColor:S,borderColor:P,requiresCallsign:U,action:ee,icon:q,description:j})=>{const V=t.includes(W||m)||t.includes(w)||t.includes(M),_=y===w;return e.jsxs("button",{onClick:()=>o(W||m,ee||"update"),onMouseEnter:()=>k(w),onMouseLeave:()=>k(null),style:{...h.statusButton,backgroundColor:V?S:_?"#2d3748":"#1a1f2e",color:V?R:"#e2e8f0",border:`2px solid ${V?P:"#2d3748"}`,fontWeight:V?"bold":"normal"},children:[e.jsx("div",{style:{fontSize:"24px",marginBottom:"6px"},children:q}),e.jsx("div",{style:{fontSize:"20px",fontWeight:"bold",marginBottom:"4px"},children:w}),e.jsx("div",{style:{fontSize:"13px",opacity:.9},children:f})]},w)})})},qr=({user:t,themeStyles:o,setShowCommunityModal:h,onLogout:n,userRoles:y,activeCommunityId:k,activeCommunity:w,soundVolume:f,onVolumeChange:m})=>{const[W,M]=l.useState(!1),[R,S]=l.useState(!1),P=ht(),U=l.useRef(null),ee=c=>{if(!c)return"https://cdn.discordapp.com/embed/avatars/0.png";if(c.avatarURL&&!R)return c.avatarURL;if(c.discordId&&c.avatar){const u=c.avatar.startsWith("a_")?"gif":"png";return`https://cdn.discordapp.com/avatars/${c.discordId}/${c.avatar}.${u}?size=128`}return c.discordId?`https://cdn.discordapp.com/embed/avatars/${parseInt(c.discordId)%5}.png`:"https://cdn.discordapp.com/embed/avatars/0.png"},q=()=>{if(!t)return!1;if(t.isSuperAdmin||y?.isSuperAdmin)return!0;const c=w,u=w?._id||w?.id||k;if(!u)return!1;if(c?.ownerId===t.discordId)return!0;if(t.communities&&Array.isArray(t.communities))for(const A of t.communities){const oe=A.community?._id||A.community||A._id;if(oe&&oe.toString()===u?.toString()&&(A.permissions?.isCommunityAdmin===!0||A.role==="admin"||A.role==="owner"))return!0}return!!y?.isCommunityAdmin};l.useEffect(()=>{const c=u=>{U.current&&!U.current.contains(u.target)&&M(!1)};if(W)return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[W]);const j=ee(t),V=q(),_={padding:"16px 20px",cursor:"pointer",fontSize:"16px",borderBottom:"1px solid #2d3748",minHeight:"52px",display:"flex",alignItems:"center"};return e.jsxs("div",{ref:U,style:{position:"relative"},children:[e.jsxs("button",{onClick:()=>M(!W),style:{backgroundColor:"transparent",border:"1px solid #2d3748",color:"#e2e8f0",padding:"10px 16px",borderRadius:"6px",cursor:"pointer",display:"flex",alignItems:"center",gap:"10px",fontSize:"16px",minHeight:"48px",WebkitTapHighlightColor:"transparent"},children:[e.jsx("img",{src:j,alt:"avatar",style:{width:"32px",height:"32px",borderRadius:"50%",border:"2px solid #3b82f6",objectFit:"cover"},onError:()=>S(!0)}),e.jsx("span",{children:t?.callSign||t?.username||"User"}),e.jsx(qs,{style:{fontSize:"14px"}})]}),W&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:999},onClick:()=>M(!1)}),e.jsxs("div",{style:{position:"absolute",top:"100%",right:0,marginTop:"6px",backgroundColor:"#0f1419",border:"1px solid #2d3748",borderRadius:"6px",minWidth:"240px",zIndex:1e3,overflow:"hidden"},children:[e.jsx("div",{onClick:()=>{P("/account"),M(!1)},style:_,onMouseEnter:c=>c.currentTarget.style.backgroundColor="#2d3748",onMouseLeave:c=>c.currentTarget.style.backgroundColor="transparent",children:"Profile Settings"}),e.jsx("div",{onClick:()=>{P("/home"),M(!1)},style:_,onMouseEnter:c=>c.currentTarget.style.backgroundColor="#2d3748",onMouseLeave:c=>c.currentTarget.style.backgroundColor="transparent",children:"Back to Home"}),e.jsx("div",{onClick:()=>{P("/civilian"),M(!1)},style:_,onMouseEnter:c=>c.currentTarget.style.backgroundColor="#2d3748",onMouseLeave:c=>c.currentTarget.style.backgroundColor="transparent",children:"Civilian"}),e.jsx("div",{onClick:()=>{P("/dispatch"),M(!1)},style:_,onMouseEnter:c=>c.currentTarget.style.backgroundColor="#2d3748",onMouseLeave:c=>c.currentTarget.style.backgroundColor="transparent",children:"Dispatch"}),e.jsx("div",{onClick:()=>{h(!0),M(!1)},style:_,onMouseEnter:c=>c.currentTarget.style.backgroundColor="#2d3748",onMouseLeave:c=>c.currentTarget.style.backgroundColor="transparent",children:"Switch Community"}),V&&e.jsx("div",{onClick:()=>{P("/community-admin"),M(!1)},style:_,onMouseEnter:c=>c.currentTarget.style.backgroundColor="#2d3748",onMouseLeave:c=>c.currentTarget.style.backgroundColor="transparent",children:"Community Admin"}),y?.isSuperAdmin&&e.jsx("div",{onClick:()=>{P("/admin"),M(!1)},style:_,onMouseEnter:c=>c.currentTarget.style.backgroundColor="#2d3748",onMouseLeave:c=>c.currentTarget.style.backgroundColor="transparent",children:"Super Admin Panel"}),e.jsx("div",{style:{padding:"16px 20px",borderBottom:"1px solid #2d3748",background:"linear-gradient(135deg, #0f1419 0%, #1a1f2e 100%)"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("button",{onClick:()=>m(f>0?0:.5),style:{background:f>0?"linear-gradient(135deg, #3b82f6 0%, #2563eb 100%)":"#374151",border:"none",borderRadius:"8px",width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",flexShrink:0,transition:"all 0.2s ease",boxShadow:f>0?"0 2px 8px rgba(59, 130, 246, 0.3)":"none"},children:f>0?e.jsx(Hs,{style:{color:"#fff",fontSize:"14px"}}):e.jsx(Vs,{style:{color:"#6b7280",fontSize:"14px"}})}),e.jsxs("div",{style:{flex:1,position:"relative"},children:[e.jsx("div",{style:{position:"absolute",top:"50%",left:0,right:0,height:"4px",borderRadius:"2px",backgroundColor:"#1e293b",transform:"translateY(-50%)",pointerEvents:"none"},children:e.jsx("div",{style:{width:`${f*100}%`,height:"100%",borderRadius:"2px",background:"linear-gradient(90deg, #3b82f6, #60a5fa)",transition:"width 0.1s ease",boxShadow:f>0?"0 0 6px rgba(59, 130, 246, 0.4)":"none"}})}),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.05",value:f,onChange:c=>m(parseFloat(c.target.value)),style:{width:"100%",height:"20px",cursor:"pointer",opacity:0,position:"relative",zIndex:2,margin:0}})]}),e.jsxs("span",{style:{fontSize:"12px",fontWeight:"600",color:f>0?"#60a5fa":"#4b5563",minWidth:"34px",textAlign:"right",fontVariantNumeric:"tabular-nums"},children:[Math.round(f*100),"%"]})]})}),e.jsx("div",{onClick:()=>{n(),M(!1)},style:{..._,color:"#ef4444",borderBottom:"none"},onMouseEnter:c=>c.currentTarget.style.backgroundColor="#2d3748",onMouseLeave:c=>c.currentTarget.style.backgroundColor="transparent",children:"Logout"})]})]})]})},Hr=({bolos:t,onManage:o,themeStyles:h})=>t?.length?e.jsxs("div",{style:{backgroundColor:"#7f1d1d",color:"#ffffff",padding:"14px 16px",marginBottom:"12px",display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:"16px",border:"1px solid #991b1b",borderRadius:"6px",flexWrap:"wrap",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",flex:1},children:[e.jsx(Gs,{style:{fontSize:"20px"}}),e.jsxs("span",{children:["ACTIVE BOLO (",t.length,")"]}),e.jsxs("span",{style:{fontSize:"14px",opacity:.9},children:[t.slice(0,2).map(n=>n.reason).join(" | "),t.length>2&&"..."]})]}),e.jsx("button",{onClick:o,style:{padding:"10px 20px",backgroundColor:"#ef4444",color:"#fff",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"15px",minHeight:"44px",WebkitTapHighlightColor:"transparent"},children:"View All"})]}):null,Vr=({since:t})=>{const[o,h]=l.useState("");return l.useEffect(()=>{if(!t)return;const n=new Date(t).getTime(),y=()=>{const w=Math.max(0,Math.floor((Date.now()-n)/1e3)),f=Math.floor(w/3600),m=Math.floor(w%3600/60),W=w%60;h(f>0?`${f}:${String(m).padStart(2,"0")}
1:${String(W).padStart(2,"0")}`:`${m}:${String(W).padStart(2,"0")}`)};y();const k=setInterval(y,1e3);return()=>clearInterval(k)},[t]),t?e.jsx("span",{style:{color:"#fbbf24",fontWeight:"bold",fontSize:"13px"},children:o}):null},qt=({title:t,data:o,headers:h,dataKeys:n,highlightKey:y,highlightValue:k,themeStyles:w,showActions:f,onDeleteCall:m,showRefresh:W,onRefresh:M,isRefreshing:R,userRoles:S,priorityColors:P,activeBolos:U=[],calls:ee=[],statusMap:q=Tt,activePanic:j=null,selectedCallId:V,onSelectCall:_,onViewCall:c,onClearAll:u,onCreate911:A,onUnitGroup:oe,isMobile:$=!1,stateLinkAlerts:ge={}})=>{const te=S?.isSuperAdmin||S?.isCommunityAdmin||S?.isSupervisor||S?.isModerator,ae=N=>{if(!N.activeCallId)return null;const a=ee.find(r=>r._id===N.activeCallId||r.attachedUnits?.includes(N._id));if(!a)return null;let I=null;return Array.isArray(a.assignedUnits)&&(I=a.assignedUnits.find(p=>{const C=p.unitId?._id||p.unitId||p._id;return C&&String(C)===String(N._id)||p.callSign&&p.callSign===N.cad_unit||p.username&&p.username===N.username})?.assignedAt||null),I||(I=a.createdAt),{...a,unitAssignedAt:I}},ce=N=>!U||U.length===0?!1:U.some(a=>{if(a.type==="person"||a.type==="both"){const I=N.username?.toLowerCase()||"",r=N.details?.toLowerCase()||"",p=a.subjectFirstName?.toLowerCase()||"",C=a.subjectLastName?.toLowerCase()||"";if(p&&C){const v=`${p} ${C}`;return I.includes(p)||I.includes(C)||I.includes(v)||r.includes(v)||r.includes(p)||r.includes(C)}}return!1}),B=N=>{if(!j)return!1;const a=j.officerName?.toLowerCase()||"";if(!a)return!1;const I=(N.cad_unit||"").toLowerCase(),r=(N.details||"").toLowerCase(),p=(N.username||"").toLowerCase();return I===a||p===a||r.includes(a)||a.includes(I)},g=(N,a)=>
1{if(a)return{text:"PANIC",icon:e.jsx(Ze,{}),color:"#fff",bgColor:"#dc2626",borderColor:"#ef4444"};const I=q.find(r=>N.includes(r.actualStatus||r.api)||N.includes(r.ui)||N.includes(r.code));return I?{text:`${I.code} - ${I.text}`,icon:I.icon,color:I.color,bgColor:I.bgColor,borderColor:I.borderColor}:{text:N,icon:null,color:"#9ca3af"}},E=$?"6px 10px":"10px 16px",G=$?"12px":"15px",se=$?"6px 10px":"10px 16px",ne=$?"12px":"15px";return t==="CAD Units"?e.jsxs("div",{style:w.tableWrapper,children:[e.jsxs("div",{style:{backgroundColor:"#2d3748",padding:$?"8px 10px":"12px 16px",display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:$?"14px":"16px",color:"#ffffff",borderBottom:"1px solid #4a5568"},children:[e.jsx("span",{children:t}),e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[oe&&e.jsxs("button",{onClick:()=>oe(null),style:{padding:$?"6px 10px":"10px 14px",backgroundColor:"rgba(139, 92, 246, 0.15)",color:"#a78bfa",border:"1px solid rgba(139, 92, 246, 0.3)",borderRadius:"6px",cursor:"pointer",fontSize:$?"13px":"15px",minHeight:$?"32px":"44px",display:"flex",alignItems:"center",gap:"6px"},title:"Manage Unit Groups",children:[e.jsx(Ft,{})," Groups"]}),W&&e.jsxs("button",{onClick:M,disabled:R,style:{padding:$?"6px 10px":"10px 16px",backgroundColor:"transparent",color:"#e2e8f0",border:"1px solid #4a5568",borderRadius:"6px",cursor:R?"not-allowed":"pointer",fontSize:$?"13px":"15px",opacity:R?.6:1,minHeight:$?"32px":"44px",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Re,{className:R?"fa-spin":""}),R?"Refreshing...":"Refresh"]})]})]}),e.jsx("div",{style:{overflowX:"hidden"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",tableLayout:"fixed"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{backgroundColor:"#1a1f2e"},children:[e.jsx("th",{style:{textAlign:"left",padding:se,color:"#9ca3af",fontSize:ne,width:"10%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:"Unit"}),e.jsx("th",{style:{textAlign:"left",padding:se,color:"#9ca3af",fontSize:ne,width:"18%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:"Status"}),e.jsx("th",{style:{textAlign:"left",padding:se,color:"#9ca3af",fontSize:ne,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:"Details"}),!$&&e.jsx("th",{style:{textAlign:"left",padding:se,color:"#9ca3af",fontSize:ne,width:"15%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:"Location"}),!$&&e.jsx("th",{style:{textAlign:"left",padding:se,color:"#9ca3af",fontSize:ne,width:"12%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:"Attached Call"})]})}),e.jsx("tbody",{children:o?.length>0?o.map(N=>{const a=ae(N),I=ce(N),r=B(N),p=g(N.status,r),C=ge[N._id]||ge[N.discordId];return e.jsxs("tr",{title:C?`StateLink: ${C.text}`:void 0,style:{backgroundColor:C?void 0:r?"rgba(220, 38, 38, 0.15)":a?"rgba(59, 130, 246, 0.1)":"transparent",borderLeft:C?"4px solid #ffd54f":r?"4px solid #ef4444":a?"4px s
1olid #3b82f6":"none",animation:C?"dp3StateLinkFlash 1s steps(1,end) infinite":r?"panicRowPulse 1.5s ease-in-out infinite":"none"},children:[e.jsx("td",{style:{padding:E,borderBottom:"1px solid #2d3748",fontSize:G,color:r?"#fca5a5":"#e2e8f0",overflow:"hidden"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",overflow:"hidden"},children:[N.cad_unit,C&&e.jsx("span",{title:C.text,style:{padding:"2px 6px",backgroundColor:"#b40000",color:"#fff",borderRadius:"4px",fontSize:"10px",fontWeight:"800",letterSpacing:"0.05em"},children:C.text.toUpperCase()}),N.unitGroupId&&e.jsxs("span",{title:`Group: ${N.unitGroup||"Unit Group"}${N.unitGroupLeader?" (Leader)":""}`,style:{padding:"2px 6px",backgroundColor:"rgba(139, 92, 246, 0.2)",color:"#a78bfa",border:"1px solid rgba(139, 92, 246, 0.3)",borderRadius:"4px",fontSize:"10px",fontWeight:"600",display:"inline-flex",alignItems:"center",gap:"3px",cursor:oe?"pointer":"default"},onClick:v=>{v.stopPropagation(),oe?.(N)},children:[e.jsx(Ft,{style:{fontSize:"9px"}}),N.unitGroup||"GROUP"]}),r&&e.jsxs("span",{style:{padding:"4px 8px",backgroundColor:"#dc2626",color:"#fff",borderRadius:"4px",fontSize:"11px",fontWeight:"800",letterSpacing:"0.05em",display:"inline-flex",alignItems:"center",gap:"4px",animation:"panicFlash 0.5s ease-in-out infinite"},children:[e.jsx(Ze,{}),"PANIC"]}),I&&!r&&e.jsxs("span",{style:{padding:"4px 8px",backgroundColor:"#ef4444",color:"#fff",borderRadius:"4px",fontSize:"12px",fontWeight:"bold",display:"inline-flex",alignItems:"center",gap:"4px"},children:[e.jsx(Ys,{}),"BOLO"]})]})}),e.jsx("td",{style:{padding:E,borderBottom:"1px solid #2d3748",fontSize:G},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:e.jsxs("span",{style:{padding:$?"4px 8px":"6px 12px",backgroundColor:p.bgColor,color:p.color,border:`1px solid ${p.borderColor}`,borderRadius:"6px",fontSize:$?"12px":"14px",display:"inline-flex",alignItems:"center",gap:"6px"},children:[p.icon,p.text]})})}),e.jsx("td",{style:{padding:E,borderBottom:"1px solid #2d3748",fontSize:G,color:"#e2e8f0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:N.details}),!$&&e.jsx("td",{style:{padding:E,borderBottom:"1px solid #2d3748",fontSize:G,color:"#e2e8f0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:N.location}),!$&&e.jsx("td",{style:{padding:E,borderBottom:"1px solid #2d3748",fontSize:G,overflow:"hidden"},children:a?e.jsxs("div",{style:{padding:"4px 6px",backgroundColor:"#0f1419",borderRadius:"4px",border:"1px solid #3b82f6",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Xs,{style:{color:"#3b82f6",flexShrink:0,fontSize:"11px"}}),e.jsx("strong",{style:{color:"#3b82f6",fontSize:"12px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.incident_number||a.incidentNumber})]}),e.jsx("div",{style:{fontSize:"11px",color:"#e2e8f0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.call_type||a.callType})]}):e.jsx("span",{style:{color:"#6b7280",fontStyle:"italic"},children:"Not attached"})})]},N._id)}):e.jsx("tr",{children:e.jsx("td",{colSpan:$?3:5,style:{textAlign:"center",padding:"28px",color:"#9ca3af",fontSize:G},children:"No active units."})})})]})})]}):t==="Active Calls"||t==="Calls"||t==="Clk-Status"||t.includes("Call")?e.jsxs("div",{style:w.tableWrapper,children:[e.jsxs("div",{style:{backgroundColor:"#2d3748",padding:$?"8px 10px":"12px 16px",display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:$?"14px":"16px",color:"#ffffff",borderBottom:"1px solid #4a5568"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("span",{children:t}),V&&e.jsxs("span",{style:{padding:"4px 10px",backgroundColor:"#10b981",color:"#fff",borderRadius:"4px",fontSize:"12px",fontWeight:"bold",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(dt,{})," On Call"]})]}),e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center"},children:[A&&e.jsxs("button",{onClick:A,style:{padding:"6px 12px",backgroundColor:"#10b981",color:"#fff",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"13px",minHeight:"32px",display:"flex",alignItems:"center",gap:"6px",fontWeight:"600"},children:[e.jsx(gt,{})," Create Call"]}),te&&o?.length>1&&e.jsxs("button",{onClick:()=>{F.warn(e.jsxs("div",{children:[e.jsxs("p",{style:{marginBottom:"10px"},children:["Clear ALL ",o.length," calls?"]}),e.jsxs("div",{style:{display:"flex",gap:"10px"},children:[e.jsx("button",{onClick:async()=>{F.dismiss();try{u&&await u(o)}catch(N){F.error(je(N,"Failed to clear all calls"))}},style:{padding:"6px 16px",backgroundColor:"#dc2626",color:"#fff",border:"none",borderRadius:"4px",cursor:"pointer"},children:"Clear All"}),e.jsx("button",{onClick:()=>F.dismiss(),style:{padding:"6px 16px",backgroundColor:"#374151",color:"#fff",border:"none",borderRadius:"4px",cursor:"pointer"},children:"Cancel"})]})]}
1),{autoClose:!1,closeOnClick:!1,draggable:!1,closeButton:!1})},style:{padding:"6px 12px",backgroundColor:"#dc2626",color:"#fff",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"13px",minHeight:"32px",display:"flex",alignItems:"center",gap:"6px",fontWeight:"600"},children:[e.jsx(zt,{})," Clear All"]}),W&&e.jsxs("button",{onClick:M,disabled:R,style:{padding:"10px 16px",backgroundColor:"transparent",color:"#e2e8f0",border:"1px solid #4a5568",borderRadius:"6px",cursor:R?"not-allowed":"pointer",fontSize:"15px",opacity:R?.6:1,minHeight:"44px",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Re,{className:R?"fa-spin":""}),R?"Refreshing...":"Refresh"]})]})]}),e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{backgroundColor:"#1a1f2e"},children:[h.map(N=>e.jsx("th",{style:{textAlign:"left",padding:se,color:"#9ca3af",fontWeight:"normal",fontSize:ne,borderBottom:"1px solid #2d3748",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:N},N)),f&&e.jsx("th",{style:{textAlign:"left",padding:se,color:"#9ca3af",fontSize:ne,borderBottom:"1px solid #2d3748",width:$?"100px":"140px"},children:"Actions"})]})}),e.jsx("tbody",{children:o?.length>0?o.map(N=>{const a=V===N._id,I=P?.[N.incident_code]||"transparent";return e.jsxs("tr",{style:{backgroundColor:a?"rgba(16, 185, 129, 0.15)":I,borderLeft:a?"4px s
1olid #10b981":"4px solid transparent",transition:"all 0.15s ease"},children:[n.map(r=>e.jsx("td",{style:{padding:E,borderBottom:"1px solid #2d3748",fontSize:G,color:"#e2e8f0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:N[r]},r)),f&&e.jsx("td",{style:{padding:E,borderBottom:"1px solid #2d3748"},children:e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("button",{onClick:()=>c?.(N),style:{padding:$?"6px 10px":"10px 16px",backgroundColor:"#3b82f6",color:"#fff",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:G,minHeight:$?"32px":"44px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Rt,{})," View"]}),te&&e.jsx("button",{onClick:()=>m?.(N._id),style:{padding:$?"6px 10px":"10px 16px",backgroundColor:"#ef4444",color:"#fff",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:G,minHeight:$?"32px":"44px"},children:"Clear"})]})})]},N._id)}):e.jsx("tr",{children:e.jsx("td",{colSpan:h.length+(f?1:0),style:{textAlign:"center",padding:"28px",color:"#9ca3af",fontSize:G},children:"No active calls."})})})]})})]}):e.jsxs("div",{style:w.tableWrapper,children:[e.jsxs("div",{style:{backgroundColor:"#2d3748",padding:"12px 16px",display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:"16px",color:"#ffffff",borderBottom:"1px solid #4a5568"},children:[e.jsx("span",{children:t}),W&&e.jsxs("button",{onClick:M,disabled:R,style:{padding:"10px 16px",backgroundColor:"transparent",color:"#e2e8f0",border:"1px solid #4a5568",borderRadius:"6px",cursor:R?"not-allowed":"pointer",fontSize:"15px",opacity:R?.6:1,minHeight:"44px",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Re,{className:R?"fa-spin":""}),R?"Refreshing...":"Refresh"]})]}),e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{backgroundColor:"#1a1f2e"},children:[h.map(N=>e.jsx("th",{style:{textAlign:"left",padding:"12px 16px",color:"#9ca3af",fontWeight:"normal",fontSize:"15px",borderBottom:"1px solid #2d3748"},children:N},N)),f&&te&&e.jsx("th",{style:{textAlign:"left",padding:"12px 16px",color:"#9ca3af",fontSize:"15px"},children:"Actions"})]})}),e.jsx("tbody",{children:o?.length>0?o.map(N=>{const a=P?.[N.incident_code]||(N[y]===k?"#2d3748":"transparent");return e.jsxs("tr",{style:{backgroundColor:a},children:[n.map(I=>e.jsx("td",{style:{padding:"14px 16px",borderBottom:"1px solid #2d3748",fontSize:"15px",color:"#e2e8f0"},children:N[I]},I)),f&&te&&e.jsx("td",{style:{padding:"14px 16px",borderBottom:"1px solid #2d3748"},children:e.jsx("button",{onClick:()=>m?.(N._id),style:{padding:"10px 16px",backgroundColor:"#ef4444",color:"#fff",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"15px",minHeight:"44px"},children:"Clear"})})]},N._id)}):e.jsx("tr",{children:e.jsx("td",{colSpan:h.length+(f&&te?1:0),style:{textAlign:"center",padding:"28px",color:"#9ca3af",fontSize:"15px"},children:"No data available."})})})]})})]})},Gr=({item:t,onClose:o,onRecordLookup:h,themeStyles:n,activeCommunityId:y,onViewReport:k,onSearchItem:w,onRequestSuspension:f})=>{const m=Ht(),[W,M]=l.useState({}),[R,S]=l.useState(!1),[P,U]=l.useState(null),[ee,q]=l.useState(null),[j,V]=l.useState("overview"),[_,c]=l.useState("overview"),[u,A]=l.useState(!!t?.doa),[oe,$]=l.useState(!1),ge=ht(),{activeCommunity:te}=ft();l.useEffect(()=>{t&&!R&&h&&(t.firstName||t.plate||t.name,h(t),S(!0))},[t,R,h]),l.useEffect(()=>{!t?.firstName||!t?.lastName||!y||(U(null),Z.get("/reports/federal-flag",{params:{communityId:y,firstName:t.firstName,lastName:t.lastName}}).then(a=>U(a.data)).catch(()=>U(null)))},[t?.firstName,t?.lastName,y]),l.useEffect(()=>{V("overview"),c("overview")},[t?._id,t?.id,t?.plate,t?.serialNumber]),l.useEffect(()=>{A(!!t?.doa)},[t?._id,t?.doa]),l.useEffect(()=>{t&&ir(t,te)},[t,te]);const ae=async()=>{const a=t?._id||t?.id;if(!a||!y||oe)return;const I=!u;if(!(I&&!window.confirm("Mark this person as DOA (Dead on Arrival)? This flags the record as deceased."))){$(!0);try{await Z.patch(`/lookup/civilian/${a}/doa`,{communityId:y,doa:I}),A(I),t.doa=I}catch(r){console.error("DOA toggle failed:",r?.response?.data?.msg||r.message),alert(r?.response?.data?.msg||"Failed to update DOA flag.")}finally{$(!1)}}};if(!t)return null;const ce=a=>{M(I=>({...I,[a]:!I[a]}))},B=t._type==="firearm"||t.serialNumber,g=!B&&(t._type==="civilian"||t.type==="person"||t.type==="civilian"||t.firstName),E=!B&&(t._type==="vehicle"||t._type==="business_vehicle"||t.type==="vehicle"||t.plate),G=t._type==="business_vehicle",se=!B&&!g&&!E&&(t._type==="business"||t.type==="business"||t.businessName||t.name&&!t.firstName&&!t.plate),ne=!B&&!g&&!E&&!se&&(t._type==="property"||t.type==="property"||t.postal||t.propertyType),N=(a,I)=>{w&&w(a,I),o()};return e.jsx("div",{style:{...n.modal,zIndex:1050},onClick:o,children:e.jsxs("div",{style:{...n.modalContent,maxWidth:"900px",maxHeight:"90vh",overflowY:"auto"},onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px",borderBottom:"2px s
1olid #2d3748",paddingBottom:"16px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[g&&e.jsx(we,{style:{color:"#3b82f6",fontSize:"24px"}}),E&&e.jsx(Ne,{style:{color:"#f59e0b",fontSize:"24px"}}),B&&e.jsx(at,{style:{color:"#ef4444",fontSize:"24px"}}),se&&e.jsx(Ve,{style:{color:"#10b981",fontSize:"24px"}}),ne&&e.jsx(kt,{style:{color:"#8b5cf6",fontSize:"24px"}}),e.jsxs("div",{children:[e.jsxs("h2",{style:{fontSize:"22px",margin:0},children:[g&&`${t.firstName||""} ${t.middleName||""} ${t.lastName||""}`.trim(),E&&t.plate,B&&`S/N: ${t.serialNumber||"Unknown"}`,se&&(t.businessName||t.name),ne&&(t.address||`${t.road||""} ${t.postal?`(${t.postal})`:""}`)]}),e.jsxs("div",{style:{fontSize:"13px",color:"#9ca3af",marginTop:"4px"},children:[g&&"Person Record",E&&(G?"Business Vehicle Record":"Vehicle Record"),B&&"Firearm Record",se&&"Business Record",ne&&"Property Record",e.jsx("span",{style:{marginLeft:"8px",color:"#10b981"},children:"â Added to recent lookups"})]})]})]}),e.jsx("button",{onClick:o,style:{background:"none",border:"none",color:"#e2e8f0",fontSize:"28px",cursor:"pointer",padding:"8px",minWidth:"44px",minHeight:"44px"},children:e.jsx(Qe,{})})]}),(t.flags||t.missingPerson||t.stolen||t.isDangerous||u)&&e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"16px"},children:[t.flags?.hasWarrant&&e.jsxs("span",{style:{padding:"6px 12px",backgroundColor:"#ef4444",color:"#fff",borderRadius:"4px",fontSize:"12px",fontWeight:"bold",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Qs,{})," WARRANT"]}),t.flags?.hasPendingWarrant&&!t.flags?.hasWarrant&&e.jsx("span",{title:"Pending judicial review - do not act",style:{padding:"6px 12px",backgroundColor:"#f59e0b",color:"#1f2937",borderRadius:"4px",fontSize:"11px",fontWeight:"bold",lineHeight:1.2,animation:"pulse 2s infinite"},children:"WARRANT IN REVIEW · do not act"}),(t.flags?.isSuspended||t.flags?.driversLicenseSuspended)&&e.jsx("span",{style:{padding:"6px 12px",backgroundColor:"#f59e0b",color:"#000",borderRadius:"4px",fontSize:"12px",fontWeight:"bold"},children:"LICENSE SUSPENDED"}),t.flags?.isFelon&&e.jsx("span",{style:{padding:"6px 12px",backgroundColor:"#dc2626",color:"#fff",borderRadius:"4px",fontSize:"12px",fontWeight:"bold"},children:"FELON"}),t.flags?.isViolent&&e.jsx("span",{style:{padding:"6px 12px",backgroundColor:"#7f1d1d",color:"#fff",borderRadius:"4px",fontSize:"12px",fontWeight:"bold"},children:"VIOLENT"}),t.flags?.hasDrugCharges&&e.jsx("span",{style:{padding:"6px 12px",backgroundColor:"#8b5cf6",color:"#fff",borderRadius:"4px",fontSize:"12px",fontWeight:"bold"},children:"DRUG CHARGES"}),t.flags?.hasWeaponsCharges&&e.jsx("span",{style:{padding:"6px 12px",backgroundColor:"#ec4899",color:"#fff",borderRadius:"4px",fontSize:"12px",fontWeight:"bold"},children:"WEAPONS"}),t.missingPerson&&e.jsx("span",{style:{padding:"6px 12px",backgroundColor:"#dc2626",color:"#fff",borderRadius:"4px",fontSize:"12px",fontWeight:"bold"},children:"MISSING PERSON"}),t.stolen&&e.jsx("span",{style:{padding:"6px 12px",backgroundColor:"#ef4444",color:"#fff",borderRadius:"4px",fontSize:"12px",fontWeight:"bold"},children:"STOLEN VEHICLE"}),t.isDangerous&&e.jsx("span",{style:{padding:"6px 12px",backgroundColor:"#dc2626",color:"#fff",borderRadius:"4px",fontSize:"12px",fontWeight:"bold"},children:"DANGEROUS"}),u&&e.jsxs("span",{title:t.doaNotes||(t.doaDate?`DOA ${new Date(t.doaDate).toLocaleDateString()}`:"Deceased"),style:{padding:"6px 12px",backgroundColor:"#111827",color:"#fff",border:"1px solid #6b7280",borderRadius:"4px",fontSize:"12px",fontWeight:"bold",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Et,{})," DECEASED (DOA)"]}),G&&e.jsxs("span",{style:{padding:"6px 12px",backgroundColor:"#10b981",color:"#fff",borderRadius:"4px",fontSize:"12px",fontWeight:"bold",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Ve,{})," BUSINESS VEHICLE"]})]}),g&&e.jsx(or,{flags:t.civFlags,style:{margin:"8px 0"}}),g&&e.jsx("div",{style:{marginBottom:"16px"},children:e.jsxs("button",{onClick:ae,disabled:oe,title:u?"Clear the DOA flag on this person":"Mark this person as Dead on Arrival",style:{display:"inline-flex",alignItems:"center",gap:"8px",padding:"8px 14px",borderRadius:"6px",cursor:oe?"wait":"pointer",fontSize:"13px",fontWeight:600,background:u?"transparent":"#111827",color:u?"#e5e7eb":"#fff",border:`1px solid ${u?"#6b7280":"#374151"}`,opacity:oe?.6:1},children:[e.jsx(Et,{})," ",u?"Clear DOA flag":"Mark DOA"]})}),t.activeBolos&&t.activeBolos.length>
10&&e.jsxs("div",{style:{marginBottom:"16px",padding:"16px",backgroundColor:"rgba(239, 68, 68, 0.2)",border:"2px solid #ef4444",borderRadius:"6px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",marginBottom:"12px"},children:[e.jsx(Gt,{style:{color:"#ef4444",fontSize:"20px"}}),e.jsx("strong",{style:{color:"#ef4444",fontSize:"18px"},children:"â ACTIVE BOLO ALERT â "})]}),t.activeBolos.map((a,I)=>e.jsxs("div",{style:{backgroundColor:"#0f1419",padding:"10px",borderRadius:"4px",marginBottom:"8px"},children:[e.jsx("div",{style:{color:"#fbbf24",fontWeight:"bold"},children:a.reason}),e.jsx("div",{style:{fontSize:"14px",color:"#fca5a5"},children:a.description})]},I))]}),g&&e.jsxs("div",{style:{display:"flex",gap:"16px",alignItems:"flex-start"},children:[e.jsx("div",{style:{flexShrink:0,display:"flex",flexDirection:"column",gap:"4px",minWidth:"128px"},children:[["overview","Overview"],["licenses","Licenses"],["vehicles",`Vehicles${t.vehicles?.length?` (${t.vehicles.length})`:""}`],["firearms",`Firearms${t.firearms?.length?` (${t.firearms.length})`:""}`],["records","Records"]].map(([a,I])=>e.jsx("button",{type:"button",onClick:()=>V(a),style:{textAlign:"left",padding:"10px 12px",borderRadius:"6px",cursor:"pointer",fontSize:"13px",fontWeight:600,border:`1px solid ${j===a?"#3b82f6":"#2d3748"}`,background:j===a?"rgba(59,130,246,0.15)":"#0f1419",color:j===a?"#fff":"#9ca3af",transition:"all 0.15s ease"},children:I},a))}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[j==="overview"&&e.jsxs("div",{style:{display:"flex",gap:"16px",marginBottom:"16px"},children:[t.mugshotUrl&&e.jsx("div",{style:{flexShrink:0},children:e.jsx("img",{src:ds(t.mugshotUrl,m),alt:"Photo",style:{width:"150px",height:"190px",objectFit:"cover",borderRadius:"6px",border:"1px solid #2d3748",display:"block"},onError:a=>{a.currentTarget.style.display="none"}})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"12px",backgroundColor:"#0f1419",padding:"16px",borderRadius:"6px",flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx(Ks,{style:{marginRight:"6px",color:"#60a5fa"}}),"DOB: ",t.dateOfBirth?new Date(t.dateOfBirth).toLocaleDateString():"N/A",t.dateOfBirth&&` (Age: ${Math.floor((new Date-new Date(t.dateOfBirth))/31536e6)})`]}),e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx($t,{style:{marginRight:"6px",color:"#60a5fa"}}),"SSN: ",t.ssn||"XXX-XX-XXXX"]}),e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx(Yt,{style:{marginRight:"6px",color:"#60a5fa"}}),"Phone: ",t.phone||"N/A"]}),e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx(lt,{style:{marginRight:"6px",color:"#60a5fa"}}),"Address: ",t.address||"N/A"]}),t.licenseNumber&&e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx($t,{style:{marginRight:"6px",color:"#60a5fa"}}),"License: ",t.licenseNumber]}),t.gender&&e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx(er,{style:{marginRight:"6px",color:"#60a5fa"}}),"Gender: ",t.gender]}),t.race&&e.jsxs("div",{children:["Race: ",t.race]}),t.height&&e.jsxs("div",{children:["Height: ",t.height]}),t.weight&&e.jsxs("div",{children:["Weight: ",t.weight," lbs"]}),t.hairColor&&e.jsxs("div",{children:["Hair: ",t.hairColor]}),t.eyeColor&&e.jsxs("div",{children:["Eyes: ",t.eyeColor]}),t.occupation&&e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx(Ve,{style:{marginRight:"6px",color:"#60a5fa"}}),"Occupation: ",t.occupation]})]})]}),j==="licenses"&&t.licenses&&e.jsxs("div",{style:{marginBottom:"16px",padding:"12px",backgroundColor:"#0f1419",borderRadius:"6px"},children:[e.jsx("h4",{style:{fontSize:"14px",marginBottom:"10px",color:"#60a5fa",display:"flex",alignItems:"center"},children:"License Status"}),e.jsxs("div",{style:{display:"flex",gap:"10px",flexWrap:"wrap"},children:[e.jsx(Je,{type:"Driver's",status:t.licenses.drivers?.status||"None",icon:e.jsx(Ne,{}),licenseNumber:t.licenses.drivers?.licenseNumber,onView:()=>q({type:"drivers",label:"Driver's License",license:t.licenses.drivers})}),e.jsx(Je,{type:"Firearms",status:t.licenses.firearms?.status||"None",icon:e.jsx(at,{}),licenseNumber:t.licenses.firearms?.licenseNumber,onView:()=>q({type:"firearms",label:"Firearms License",license:t.licenses.firearms})}),t.licenses.cdl&&e.jsx(Je,{type:"CDL",status:t.licenses.cdl?.status||"None",icon:e.jsx(tr,{}),licenseNumber:t.licenses.cdl?.licenseNumber,onView:()=>q({type:"cdl",label:"CDL",license:t.licenses.cdl})}),t.licenses.hunting&&e.jsx(Je,{type:"Hunting",status:t.licenses.hunting?.status||"None",icon:e.jsx(sr,{}),onView:()=>q({type:"hunting",label:"Hunting License",license:t.licenses.hunting})}),t.licenses.fishing&&e.jsx(Je,{type:"Fishing",status:t.licenses.fishing?.status||"None",icon:e.jsx(rr,{}),onView:()=>
1q({type:"fishing",label:"Fishing License",license:t.licenses.fishing})}),t.licenses.pilot&&e.jsx(Je,{type:"Pilot",status:t.licenses.pilot?.status||"None",icon:e.jsx(nr,{}),onView:()=>q({type:"pilot",label:"Pilot License",license:t.licenses.pilot})})]})]}),ee&&e.jsx(cr,{civilianId:t._id||t.id,licenseType:ee.type,licenseLabel:ee.label,license:ee.license,civilian:t,onClose:()=>q(null)}),j==="vehicles"&&t.vehicles&&t.vehicles.length>0&&e.jsxs("div",{style:{marginBottom:"16px",backgroundColor:"#0f1419",padding:"12px",borderRadius:"6px"},children:[e.jsxs("h4",{style:{fontSize:"14px",marginBottom:"10px",color:"#60a5fa",display:"flex",alignItems:"center"},children:[e.jsx(Ne,{style:{marginRight:"6px"}}),"Registered Vehicles (",t.vehicles.length,")"]}),t.vehicles.map((a,I)=>{const r=!!W[`veh-${I}`];return e.jsxs("div",{style:{backgroundColor:"#1a1f2e",borderRadius:"4px",marginBottom:"8px",border:`1px solid ${r?"#3b82f6":"#2d3748"}`,overflow:"hidden",transition:"border-color 0.15s ease"},children:[e.jsxs("div",{onClick:()=>ce(`veh-${I}`),style:{padding:"10px",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer"},children:[e.jsxs("div",{children:[e.jsx("strong",{style:{color:"#f59e0b"},children:a.plate}),e.jsxs("span",{style:{marginLeft:"12px",color:"#9ca3af"},children:[a.year," ",a.color," ",a.make," ",a.model]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[a.stolen&&e.jsx("span",{style:{padding:"4px 10px",backgroundColor:"#ef4444",color:"#fff",borderRadius:"4px",fontSize:"12px"},children:"STOLEN"}),r?e.jsx(ut,{style:{color:"#3b82f6"}}):e.jsx(He,{style:{color:"#3b82f6"}})]})]}),r&&e.jsxs("div",{style:{padding:"12px",borderTop:"1px solid #2d3748"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(165px, 1fr))",gap:"8px",fontSize:"13px",color:"#e2e8f0"},children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Plate:"})," ",a.plate]}),a.vin&&e.jsxs("div",{children:[e.jsx("strong",{children:"VIN:"})," ",a.vin]}),a.make&&e.jsxs("div",{children:[e.jsx("strong",{children:"Make:"})," ",a.make]}),a.model&&e.jsxs("div",{children:[e.jsx("strong",{children:"Model:"})," ",a.model]}),a.year&&e.jsxs("div",{children:[e.jsx("strong",{children:"Year:"})," ",a.year]}),a.color&&e.jsxs("div",{children:[e.jsx("strong",{children:"Color:"})," ",a.color]}),a.vehicleType&&e.jsxs("div",{children:[e.jsx("strong",{children:"Type:"})," ",a.vehicleType]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Insurance:"})," ",e.jsx("span",{style:{color:a.insurance?.status==="Valid"?"#10b981":a.insurance?.status==="Expired"?"#f59e0b":"#ef4444",fontWeight:"bold"},children:a.insurance?.status||"None"})]}),a.insurance?.provider&&e.jsxs("div",{children:[e.jsx("strong",{children:"Provider:"})," ",a.insurance.provider]}),a.registrationStatus&&e.jsxs("div",{children:[e.jsx("strong",{children:"Registration:"})," ",a.registrationStatus]}),a.registrationExpiry&&e.jsxs("div",{children:[e.jsx("strong",{children:"Reg. Expires:"})," ",new Date(a.registrationExpiry).toLocaleDateString()]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Status:"})," ",e.jsx("span",{style:{color:a.stolen?"#ef4444":"#10b981",fontWeight:"bold"},children:a.stolen?"STOLEN":"Clear"})]})]}),e.jsxs("button",{type:"button",onClick:p=>{p.stopPropagation(),N(a.plate,"vehicle")},style:{marginTop:"12px",padding:"8px 14px",backgroundColor:"#3b82f6",color:"#fff",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(be,{})," Open full vehicle record"]})]})]},I)})]}),j==="firearms"&&t.firearms&&t.firearms.length>0&&e.jsxs("div",{style:{marginBottom:"16px",backgroundColor:"#0f1419",padding:"12px",borderRadius:"6px"},children:[e.jsxs("h4",{style:{fontSize:"14px",marginBottom:"10px",color:"#60a5fa",display:"flex",alignItems:"center"},children:[e.jsx(at,{style:{marginRight:"6px"}}),"Registered Firearms (",t.firearms.length,")"]}),t.firearms.map((a,I)=>e.jsxs("div",{style:{backgroundColor:"#1a1f2e",borderRadius:"4px",marginBottom:"8px",border:"1px solid #2d3748",padding:"12px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"},children:[e.jsxs("strong",{style:{color:"#ef4444"},children:["S/N: ",a.serialNumber||"N/A"]}),e.jsx("span",{style:{padding:"4px 10px",borderRadius:"4px",fontSize:"12px",fontWeight:"bold",backgroundColor:a.isStolen?"#ef4444":"#10b981",color:"#fff"},children:a.isStolen?"STOLEN":"CLEAR"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:"8px",fontSize:"13px",color:"#e2e8f0"},children:[a.make&&e.jsxs("div",{children:[e.jsx("strong",{children:"Make:"})," ",a.make]}),a.model&&e.jsxs("div",{children:[e.jsx("strong",{children:"Model:"})," ",a.model]}),a.caliber&&e.jsxs("div",{children:[e.jsx("strong",{children:"Caliber:"})," ",a.caliber]}),a.type&&e.jsxs("div",{children:[e.jsx("strong",{children:"Type:"})," ",a.type]}),a.stolenDate&&e.jsxs("div",{children:[e.jsx("strong",{children:"Stolen:"})," ",new Date(a.stolenDate).toLocaleDateString()]})]}),e.jsxs("button",{type:"button",onClick:r=>{r.stopPropagation(),N(a.serialNumber,"firearms")},style:{marginTop:"12px",padding:"8px 14px",backgroundColor:"#3b82f6",color:"#fff",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(be,{})," Open full firearm record"]})]},I))]}),j==="records"&&P?.hasFederalRecords&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"12px 16px",marginBottom:"16
1px",backgroundColor:"#1e1230",border:"1px solid #7c3aed",borderRadius:"6px"},children:[e.jsx("span",{style:{color:"#a78bfa",fontSize:"18px",verticalAlign:"middle"},children:"âï¸"}),e.jsxs("div",{children:[e.jsxs("div",{style:{fontWeight:600,color:"#a78bfa",fontSize:"14px"},children:["Federal Records on File (",P.count,")"]}),e.jsx("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"2px"},children:"Details restricted - viewable from the Judicial panel only"})]})]}),j==="records"&&(()=>{const a=["federal-indictment","federal-warrant","restraining-order","probation-report","grand-jury-subpoena","court-order"],r=(t.reports||t._reports||[]).filter(p=>!a.includes(p.reportType));return r.length===0?null:e.jsxs("div",{style:{backgroundColor:"#0f1419",borderRadius:"6px",border:"1px solid #2d3748",overflow:"hidden",marginBottom:"16px"},children:[e.jsxs("button",{onClick:()=>ce("criminal"),style:{width:"100%",padding:"14px 16px",backgroundColor:"#0f1419",border:"none",color:"#e2e8f0",fontSize:"15px",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center",textAlign:"left"},children:[e.jsxs("span",{style:{color:"#f59e0b",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ze,{})," Criminal History (",r.length," records)"]}),W.criminal?e.jsx(ut,{}):e.jsx(He,{})]}),W.criminal&&e.jsx("div",{style:{padding:"16px",borderTop:"1px solid #2d3748"},children:r.slice(0,10).map((p,C)=>e.jsxs("div",{style:{padding:"14px",backgroundColor:"#1a1f2e",marginBottom:"12px",borderRadius:"6px",border:"1px solid #2d3748"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"8px"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:"bold",color:"#60a5fa",fontSize:"15px"},children:p.reportType?.toUpperCase().replace(/-/g," ")}),e.jsxs("div",{style:{fontSize:"13px",color:"#9ca3af",marginTop:"4px"},children:["Case #: ",p.caseNumber||"N/A"]})]}),e.jsx("span",{style:{padding:"4px 10px",backgroundColor:p.status==="approved"?"#10b981":p.status==="pending"?"#f59e0b":"#6b7280",color:p.status==="pending"?"#000":"#fff",borderRadius:"4px",fontSize:"12px"},children:p.status?.toUpperCase()})]}),e.jsxs("div",{style:{fontSize:"13px",color:"#e2e8f0"},children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Date:"})," ",new Date(p.createdAt||p.dateTime).toLocaleString()]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Location:"})," ",p.location||"N/A"]})]}),p.violations&&p.violations.length>0&&e.jsxs("div",{style:{marginTop:"8px",fontSize:"13px"},children:[e.jsx("strong",{style:{color:"#ef4444"},children:"Charges:"}),e.jsx("ul",{style:{margin:"4px 0 0 20px",padding:0},children:p.violations.slice(0,3).map((v,X)=>e.jsxs("li",{style:{color:"#fca5a5"},children:[v.code," - ",v.description]},X))})]}),e.jsxs("button",{onClick:v=>{v.stopPropagation(),k&&k(p._id)},style:{marginTop:"12px",padding:"8px 14px",backgroundColor:"#3b82f6",color:"#fff",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Rt,{})," View Full Report"]})]},C))})]})})(),j==="licenses"&&!t.licenses&&e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"#6b7280",backgroundColor:"#0f1419",borderRadius:"6px"},children:"No licenses on file."}),j==="vehicles"&&!(t.vehicles&&t.vehicles.length>0)&&e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"#6b7280",backgroundColor:"#0f1419",borderRadius:"6px"},children:"No registered vehicles."}),j==="firearms"&&!(t.firearms&&t.firearms.length>0)&&e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"#6b7280",backgroundColor:"#0f1419",borderRadius:"6px"},children:"No registered firearms."}),j==="records"&&!P?.hasFederalRecords&&!(t.reports||t._reports||[]).some(a=>!["federal-indictment","federal-warrant","restraining-order","probation-report","grand-jury-subpoena","court-order"].includes(a.reportType))&&e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"#6b7280",backgroundColor:"#0f1419",borderRadius:"6px"},children:"No criminal or federal records on file."})]})]}),E&&e.jsxs("div",{style:{display:"flex",gap:"16px",alignItems:"flex-start"},children:[e.jsx("div",{style:{flexShrink:0,display:"flex",flexDirection:"column",gap:"4px",minWidth:"128px"},children:[["overview","Overview"],["owner",G?"Business":"Owner"]].map(([a,I])=>e.jsx("button",{type:"button",onClick:()=>c(a),style:{textAlign:"left",padding:"10px 12px",borderRadius:"6px",cursor:"pointer",fontSize:"13px",fontWeight:600,border:`1px solid ${_===a?"#3b82f6":"#2d3748"}`,background:_===a?"rgba(59,130,246,0.15)":"#0f1419",color:_===a?"#fff":"#9ca3af",transition:"all 0.15s ease"},children:I},a))}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[_==="overview"&&e.jsxs(e.Fragment,{children:[(t._customPlate||t.customPlate)&&t.plate&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"16
1px",padding:"12px",backgroundColor:"#0f1419",borderRadius:"6px",border:"1px solid #2d3748"},children:[e.jsx(es,{plate:t._customPlate||t.customPlate,plateText:(t.plate||"").toUpperCase(),width:180}),e.jsxs("div",{style:{fontSize:"12px",color:"#9ca3af"},children:["Custom plate design:",e.jsx("div",{style:{color:"#e2e8f0",fontWeight:600,marginTop:"2px"},children:(t._customPlate||t.customPlate).name||"Custom"})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"12px",backgroundColor:"#0f1419",padding:"16px",borderRadius:"6px",marginBottom:"16px"},children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Plate:"})," ",t.plate]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Year:"})," ",t.year||"N/A"]}),(t.make||!G)&&e.jsxs("div",{children:[e.jsx("strong",{children:"Make:"})," ",t.make||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Model:"})," ",t.model||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Color:"})," ",t.color||"N/A"]}),!G&&e.jsxs("div",{children:[e.jsx("strong",{children:"VIN:"}
1)," ",t.vin||"N/A"]}),!G&&t.vehicleType&&e.jsxs("div",{children:[e.jsx("strong",{children:"Type:"})," ",t.vehicleType]}),G?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Insurance:"})," ",e.jsx("span",{style:{color:t.insurance?.status==="Valid"?"#10b981":"#ef4444",fontWeight:"bold"},children:t.insurance?.status||"None"})]}),t.insurance?.purchaseDate&&e.jsxs("div",{children:[e.jsx("strong",{children:"Insured Since:"})," ",new Date(t.insurance.purchaseDate).toLocaleDateString()]}),t.registeredDate&&e.jsxs("div",{children:[e.jsx("strong",{children:"Registered:"})," ",new Date(t.registeredDate).toLocaleDateString()]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Insurance:"})," ",e.jsx("span",{style:{color:t.insurance?.status==="Valid"?"#10b981":t.insurance?.status==="Expired"?"#f59e0b":"#ef4444",fontWeight:"bold"},children:t.insurance?.status||"None"})]}),t.insurance?.provider&&e.jsxs("div",{children:[e.jsx("strong",{children:"Provider:"})," ",t.insurance.provider]}),t.insurance?.policyNumber&&e.jsxs("div",{children:[e.jsx("strong",{children:"Policy #:"})," ",t.insurance.policyNumber]}),t.insurance?.expiryDate&&e.jsxs("div",{children:[e.jsx("strong",{children:"Ins. Expires:"})," ",new Date(t.insurance.expiryDate).toLocaleDateString()]}),t.registrationStatus&&e.jsxs("div",{children:[e.jsx("strong",{children:"Registration:"})," ",t.registrationStatus]}),t.registrationExpiry&&e.jsxs("div",{children:[e.jsx("strong",{children:"Reg. Expires:"})," ",new Date(t.registrationExpiry).toLocaleDateString()]})]})]})]}),_==="owner"&&G&&t.business&&e.jsxs("div",{style:{marginBottom:"16px",padding:"16px",backgroundColor:"#0f1419",borderRadius:"6px",border:"1px solid #2d3748"},children:[e.jsxs("h4",{style:{fontSize:"14px",marginBottom:"10px",color:"#10b981",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ve,{})," Registered Business"]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"8px",backgroundColor:"#10b981",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(Ve,{style:{color:"#fff",fontSize:"18px"}})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:"bold",fontSize:"16px"},children:t.business.name}),t.business.type&&e.jsxs("div",{style:{fontSize:"13px",color:"#9ca3af"},children:["Type: ",t.business.type]}),t.business.address&&e.jsxs("div",{style:{fontSize:"13px",color:"#9ca3af"},children:["Address: ",t.business.address]}),t.business.ownerName&&e.jsxs("div",{style:{fontSize:"13px",color:"#9ca3af"},children:["Owner: ",t.business.ownerName]})]})]})]}),_==="owner"&&!G&&(t.ownerName||t.owner?.firstName||t.registeredOwner)&&(()=>{const a=t.vehicleType==="apparatus",I=t.ownerName||`${t.owner?.firstName||""} ${t.owner?.lastName||""}`.trim()||t.registeredOwner;return e.jsxs("div",{onClick:a?void 0:()=>N(t.ownerName||`${t.owner?.firstName} ${t.owner?.lastName}`,"person"),style:{marginBottom:"16px",padding:"16px",backgroundColor:"#0f1419",borderRadius:"6px",cursor:a?"default":"pointer",border:"1px solid #2d3748",transition:"all 0.15s ease"},onMouseEnter:r=>{a||(r.currentTarget.style.borderColor="#3b82f6",r.currentTarget.style.backgroundColor="#1a1f2e")},onMouseLeave:r=>{a||(r.currentTarget.style.borderColor="#2d3748",r.currentTarget.style.backgroundColor="#0f1419")},children:[e.jsxs("h4",{style:{fontSize:"14px",marginBottom:"10px",color:"#60a5fa",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(we,{})," Registered Owner",!a&&e.jsx("span",{style:{marginLeft:"auto",fontSize:"12px",color:"#3b82f6"},children:"Click to view â"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"8px",backgroundColor:"#3b82f6",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},children:a&&t.departmentLogo?e.jsx("img",{src:t.departmentLogo,alt:"",style:{width:"100%",height:"100%",objectFit:"cover"}}):e.jsx(we,{style:{color:"#fff",fontSize:"18px"}})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:"bold",fontSize:"16px"},children:I}),t.owner?.phone&&e.jsxs("div",{style:{fontSize:"13px",color:"#9ca3af"},children:["Phone: ",t.owner.phone]}),t.owner?.address&&e.jsxs("div",{style:{fontSize:"13px",color:"#9ca3af"},children:["Address: ",t.owner.address]})]}),!a&&e.jsx(He,{style:{marginLeft:"auto",color:"#3b82f6"}})]})]})})(),_==="owner"&&!(G?t.business:t.ownerName||t.owner?.firstName||t.registeredOwner)&&e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"#6b7280",backgroundColor:"#0f1419",borderRadius:"6px"},children:"No registered owner on file."})]})]}),B&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"12px",backgroundColor:"#0f1419",padding:"16px",borderRadius:"6px",marginBottom:"16
1px"},children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Serial Number:"})," ",t.serialNumber||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Make:"})," ",t.make||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Model:"})," ",t.model||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Caliber:"})," ",t.caliber||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Type:"})," ",t.type||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Status:"})," ",e.jsx("span",{style:{color:t.isStolen?"#ef4444":"#22c55e",fontWeight:"bold"},children:t.isStolen?"STOLEN":"CLEAR"})]}),t.stolenDate&&e.jsxs("div",{children:[e.jsx("strong",{children:"Stolen Date:"})," ",new Date(t.stolenDate).toLocaleDateString()]})]}),t.owner&&(t.owner.firstName||t.owner.lastName)&&e.jsxs("div",{onClick:()=>N(`${t.owner.firstName||""} ${t.owner.lastName||""}`.trim(),"person"),style:{marginBottom:"16px",padding:"16px",backgroundColor:"#0f1419",borderRadius:"6px",cursor:"pointer",border:"1px solid #2d3748",transition:"all 0.15s ease"},onMouseEnter:a=>{a.currentTarget.style.borderColor="#3b82f6",a.currentTarget.style.backgroundColor="#1a1f2e"},onMouseLeave:a=>{a.currentTarget.style.borderColor="#2d3748",a.currentTarget.style.backgroundColor="#0f1419"},children:[e.jsxs("h4",{style:{fontSize:"14px",marginBottom:"10px",color:"#60a5fa",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(we,{})," Registered Owner",e.jsx("span",{style:{marginLeft:"auto",fontSize:"12px",color:"#3b82f6"},children:"Click to view â"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"8px",backgroundColor:"#3b82f6",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(we,{style:{color:"#fff",fontSize:"18px"}})}),e.jsxs("div",{children:[e.jsxs("div",{style:{fontWeight:"bold",fontSize:"16px"},children:[t.owner.firstName," ",t.owner.lastName]}),t.owner.phone&&e.jsxs("div",{style:{fontSize:"13px",color:"#9ca3af"},children:["Phone: ",t.owner.phone]}),e.jsxs("div",{style:{fontSize:"13px",color:"#9ca3af"},children:["Firearms License: ",t.owner.licenses?.firearms?.status||"Unknown"]})]}),e.jsx(He,{style:{marginLeft:"auto",color:"#3b82f6"}})]})]})]}),se&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"12px",backgroundColor:"#0f1419",padding:"16px",borderRadius:"6px",marginBottom:"16px"},children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Name:"})," ",t.businessName||t.name]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Type:"})," ",t.businessType||t.category||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Phone:"})," ",t.phone||t.businessPhone||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Address:"})," ",t.address||t.businessAddress||"N/A"]}),t.ownerName&&e.jsxs("div",{onClick:()=>N(t.ownerName,"person"),style:{cursor:"pointer",color:"#3b82f6",textDecoration:"underline"},children:[e.jsx("strong",{children:"Owner:"})," ",t.ownerName," â"]}),t.licenseNumber&&e.jsxs("div",{children:[e.jsx("strong",{children:"License:"})," ",t.licenseNumber]}),t.website&&e.jsxs("div",{children:[e.jsx("strong",{children:"Website:"})," ",t.website]}),t.email&&e.jsxs("div",{children:[e.jsx("strong",{children:"Email:"})," ",t.email]})]}),t.vehicles&&t.vehicles.length>0&&e.jsxs("div",{style:{marginBottom:"16px",backgroundColor:"#0f1419",padding:"12px",borderRadius:"6px"},children:[e.jsxs("h4",{style:{fontSize:"14px",marginBottom:"10px",color:"#10b981",display:"flex",alignItems:"center"},children:[e.jsx(Ne,{style:{marginRight:"6px"}}),"Business Vehicles (",t.vehicles.length,")"]}),t.vehicles.map((a,I)=>{const r=!!W[`bizveh-${I}`];return e.jsxs("div",{style:{backgroundColor:"#1a1f2e",borderRadius:"4px",marginBottom:"8px",border:`1px solid ${r?"#10b981":"#2d3748"}`,overflow:"hidden",transition:"border-color 0.15s ease"},children:[e.jsxs("div",{onClick:()=>ce(`bizveh-${I}`),style:{padding:"10px",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer"},children:[e.jsxs("div",{children:[e.jsx("strong",{style:{color:"#f59e0b"},children:a.plate}),e.jsxs("span",{style:{marginLeft:"12px",color:"#9ca3af"},children:[a.year," ",a.color," ",a.make," ",a.model]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[a.stolen&&e.jsx("span",{style:{padding:"4px 10px",backgroundColor:"#ef4444",color:"#fff",borderRadius:"4px",fontSize:"12px"},children:"STOLEN"}),r?e.jsx(ut,{style:{color:"#10b981"}}):e.jsx(He,{style:{color:"#10b981"}})]})]}),r&&e.jsxs("div",{style:{padding:"12px",borderTop:"1px solid #2d3748"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(165px, 1fr))",gap:"8px",fontSize:"13px",color:"#e2e8f0"},children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Plate:"})," ",a.plate]}),a.vin&&e.jsxs("div",{children:[e.jsx("strong",{children:"VIN:"})," ",a.vin]}),a.make&&e.jsxs("div",{children:[e.jsx("strong",{children:"Make:"})," ",a.make]}),a.model&&e.jsxs("div",{children:[e.jsx("strong",{children:"Model:"})," ",a.model]}),a.year&&e.jsxs("div",{children:[e.jsx("strong",{children:"Year:"})," ",a.year]}
1),a.color&&e.jsxs("div",{children:[e.jsx("strong",{children:"Color:"})," ",a.color]}),a.vehicleType&&e.jsxs("div",{children:[e.jsx("strong",{children:"Type:"})," ",a.vehicleType]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Insurance:"})," ",e.jsx("span",{style:{color:a.insurance?.status==="Valid"?"#10b981":a.insurance?.status==="Expired"?"#f59e0b":"#ef4444",fontWeight:"bold"},children:a.insurance?.status||"None"})]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Status:"})," ",e.jsx("span",{style:{color:a.stolen?"#ef4444":"#10b981",fontWeight:"bold"},children:a.stolen?"STOLEN":"Clear"})]})]}),e.jsxs("button",{type:"button",onClick:p=>{p.stopPropagation(),N(a.plate,"vehicle")},style:{marginTop:"12px",padding:"8px 14px",backgroundColor:"#3b82f6",color:"#fff",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(be,{})," Open full vehicle record"]})]})]},I)})]})]}),ne&&e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"12px",backgroundColor:"#0f1419",padding:"16px",borderRadius:"6px",marginBottom:"16px"},children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Address:"})," ",t.address||t.road||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Postal:"})," ",t.postal||"N/A"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Type:"})," ",t.propertyType||t.type||"N/A"]}),t.ownerName&&e.jsxs("div",{onClick:()=>N(t.ownerName,"person"),style:{cursor:"pointer",color:"#3b82f6",textDecoration:"underline"},children:[e.jsx("strong",{children:"Owner:"})," ",t.ownerName," â"]}),t.zoning&&e.jsxs("div",{children:[e.jsx("strong",{children:"Zoning:"})," ",t.zoning]}),t.description&&e.jsxs("div",{style:{gridColumn:"span 2"},children:[e.jsx("strong",{children:"Description:"})," ",t.description]})]}),e.jsxs("div",{style:{display:"flex",gap:"10px",marginTop:"24px",flexWrap:"wrap"},children:[e.jsxs("button",{onClick:()=>ge("/reports"),style:{padding:"12px 20px",backgroundColor:"#3b82f6",color:"#fff",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"14px",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(It,{})," Create Report"]}),g&&f&&e.jsxs("button",{onClick:()=>{f(t),o()},style:{padding:"12px 20px",backgroundColor:"#f59e0b",color:"#000",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"14px",display:"flex",alignItems:"center",gap:"8px",fontWeight:"600"},children:[e.jsx(Qt,{})," Request License Suspension"]}),e.jsx("button",{onClick:o,style:{padding:"12px 20px",backgroundColor:"#6b7280",color:"#fff",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"14px"},children:"Close"})]})]})})},Yr=({themeStyles:t,activeCommunityId:o,unitIdentifier:h,communityName:n,onViewReport:y,activeCallId:k,onAttachToCall:w,guildId:f,externalSearchTrigger:m,activeCommunity:W=null,onSearchItem:M=()=>{}})=>{const[R,S]=l.useState(""),[P,U]=l.useState(null),[ee,q]=l.useState([]),[j,V]=l.useState([]),[_,c]=l.useState(!1),[u,A]=l.useState(""),[oe,$]=l.useState(""),[ge,te]=l.useState({}),[ae,ce]=l.useState(null),[B,g]=l.useState({}),[E,G]=l.useState(!1),[se,ne]=l.useState(null),[N,a]=l.useState(null),[I,r]=l.useState([]),[p,C]=l.useState(!1),[v,X]=l.useState({ssn:"",dob:"",phone:"",address:"",licenseNumber:"",gender:"",hairColor:"",eyeColor:"",race:"",height:""}),[Ce,We]=l.useState(0),{user:De}=wt();ht();const[fe,ze]=l.useState("search"),[Te,Ge]=l.useState([]),[Be,ct]=l.useState(!1),[yt,At]=l.useState([]),[et,tt]=l.useState(null);l.useEffect(()=>{m&&(S(m.query),ze("search"),setTimeout(()=>$e(null,m.query),100))},[m]);const st=s=>s&&{...s,firstName:s.firstName||s.firstname,lastName:s.lastName||s.lastname,middleName:s.middleName||s.middlename,dateOfBirth:s.dateOfBirth||s.dateofbirth||s.dob,licenseNumber:s.licenseNumber||s.licensenumber,expiryDate:s.expiryDate||s.expirydate,issuedDate:s.issuedDate||s.issueddate,suspendedDate:s.suspendedDate||s.suspendeddate},Ee=l.useCallback(async()=>{if(o){ct(!0);try{const s=await Z.get("/lookup/recent",{params:{communityId:o,limit:50}});Ge(s.data||[])}catch(s){console.error("Error fetching recent lookups:",s)}finally{ct(!1)}}},[o]);l.useEffect(()=>{fe==="previous"&&Ee()},[fe,Ee]);const rt=async()=>
1{if(await Ts({danger:!0,message:"Clear all recent lookups?"}))try{await Z.delete("/lookup/recent/clear",{params:{communityId:o}}),Ge([]),F.success("Recent lookups cleared")}catch(s){console.error("Error clearing lookups:",s),F.error(je(s,"Failed to clear lookups"))}},Ae=s=>{const L=s.lookupType==="civilian"?s.snapshot?.name||`${s.snapshot?.firstName||""} ${s.snapshot?.lastName||""}`.trim():s.snapshot?.plate||"";L&&(S(L),ze("search"),$e(null,L))},nt=s=>{if(!s)return"";const L=new Date(s);if(isNaN(L.getTime()))return"";const b=Math.floor((new Date-L)/1e3);if(b<0||b<60)return"Just now";const J=Math.floor(b/60);if(J<60)return`${J}m ago`;const ie=Math.floor(J/60);return ie<24?`${ie}h ago`:`${Math.floor(ie/24)}d ago`},mt=l.useCallback(async s=>{if(!(!o||!s)&&s._id)try{const L=s._type==="firearm"||s.serialNumber,b=!L&&(s._type==="civilian"||s.type==="person"||s.type==="civilian"||s.firstName),J=!L&&(s._type==="vehicle"||s.type==="vehicle"||s.plate),ie=!L&&!b&&!J&&(s._type==="business"||s.type==="business"||s.businessName),re=!L&&!b&&!J&&!ie&&(s._type==="property"||s.type==="property"||s.postal);let K="other";L?K="firearm":b?K="civilian":J?K="vehicle":ie?K="business":re&&(K="property");let T={};b?T={name:`${s.firstName||""} ${s.lastName||""}`.trim()||"Unknown",firstName:s.firstName||"",lastName:s.lastName||"",dateOfBirth:s.dateOfBirth||null,dob:s.dateOfBirth||null,licenseNumber:s.licenseNumber||s.ssn||"",phone:s.phone||"",address:s.address||"",hasWarrants:s.flags?.hasWarrant||!1,isMissing:s.missingPerson||!1}:L?T={serialNumber:s.serialNumber||"Unknown",make:s.make||"",model:s.model||"",caliber:s.caliber||"",type:s.type||"",ownerName:s.owner?`${s.owner.firstName||""} ${s.owner.lastName||""}`.trim():"Unknown",isStolen:s.isStolen||!1}:J?T={plate:s.plate||"Unknown",make:s.make||"",model:s.model||"",color:s.color||"",year:s.year||"",ownerName:s.ownerName||(s.owner?`${s.owner.firstName||""} ${s.owner.lastName||""}`.trim():"")||"Unknown",isStolen:s.stolen||!1}:ie?T={name:s.businessName||s.name||"Unknown Business",businessName:s.businessName||s.name||"",businessType:s.businessType||s.category||"",address:s.address||"",phone:s.phone||""}:re&&(T={name:s.address||`${s.road||""} ${s.postal||""}`.trim()||"Unknown Property",address:s.address||"",postal:s.postal||"",road:s.road||"",propertyType:s.propertyType||s.type||"",ownerName:s.ownerName||""});const le={communityId:o,lookupType:K,recordId:s._id,searchQuery:R||"",snapshot:T};await Z.post("/lookup/record",le),fe==="previous"&&Ee()}catch(L){console.error("Error recording lookup:",L),console.error("Error response:",L.response?.data)}},[o,fe,Ee,R]),bt=(s,L)=>{s&&(tt(null),S(s),ze("search"),setTimeout(()=>{document.querySelector("form")?.requestSubmit()},100))},ve=(s,L)=>{const b={hasWarrant:s.hasWarrant||!1,isSuspended:s.licenses?.drivers?.status==="Suspended"||s.licenses?.drivers?.status==="Revoked"||s.licenses?.firearms?.status==="Suspended"||s.licenses?.firearms?.status==="Revoked",driversLicenseSuspended:s.licenses?.drivers?.status==="Suspended",driversLicenseRevoked:s.licenses?.drivers?.status==="Revoked",driversLicenseExpired:s.licenses?.drivers?.status==="Expired",firearmsLicenseSuspended:s.licenses?.firearms?.status==="Suspended",firearmsLicenseRevoked:s.licenses?.firearms?.status==="Revoked",cdlSuspended:s.licenses?.cdl?.status==="Suspended",noValidLicense:s.licenses?.drivers?.status==="None"||!s.licenses?.drivers,isFelon:!1,isViolent:!1,isDangerous:s.isDangerous||!1,hasDUI:!1,hasMultipleDUI:!1,hasDrugCharges:!1,hasWeaponsCharges:!1,hasTheftCharges:!1,hasDomesticViolence:!1,hasResistingArrest:!1,isMissing:s.missingPerson||!1,isWanted:!1,hasPendingWarrant:!1,isSexOffender:!1,isGangAffiliated:!1,hasRestrainingOrder:!1,totalReports:L?L.length:0,totalArrests:0,totalCitations:0,totalWarnings:0,recentActivity:!1};if(L&&L.length>0){const J=new Date;J.setDate(J.getDate()-30);let ie=0;L.forEach(re=>{re.reportType==="arrest"&&b.totalArrests++,re.reportType==="citation"&&b.totalCitations++,re.reportType==="written-warning"&&b.totalWarnings++,new Date(re.createdAt||re.dateTime)>J&&(b.recentActivity=!0),re.reportType==="arrest-warrant"&&re.status!=="served"&&re.status!=="approved"&&re.approvalStatus!=="resolved"&&!["expired","judicial-denied"].includes(re.warrantApprovalState)&&(re.warrantApprovalState==="pending-judicial"?b.hasPendingWarrant=!0:(b.hasWarrant=!0,b.isWanted=!0)),re.violations&&re.violations.forEach(K=>{const T=(K.description||"").toLowerCase();(K.code||"").toLowerCase(),(T.includes("felony")||K.severity==="felony")&&(b.is
1Felon=!0),T.match(/assault|battery|robbery|violence|murder|homicide|manslaughter/i)&&(b.isViolent=!0,b.isDangerous=!0),T.match(/dui|dwi|intoxicated|impaired driving/i)&&(b.hasDUI=!0,ie++),T.match(/drug|narcotic|controlled substance|possession|distribution|trafficking/i)&&(b.hasDrugCharges=!0),T.match(/weapon|firearm|gun|armed|concealed/i)&&(b.hasWeaponsCharges=!0,b.isDangerous=!0),T.match(/theft|burglary|larceny|stealing|shoplifting|robbery/i)&&(b.hasTheftCharges=!0),T.match(/domestic|dv|spouse|partner abuse/i)&&(b.hasDomesticViolence=!0,b.isDangerous=!0),T.match(/resisting|fleeing|eluding|obstruction/i)&&(b.hasResistingArrest=!0),T.match(/sex offense|sexual|indecent|molestation/i)&&(b.isSexOffender=!0,b.isDangerous=!0),T.match(/gang|racketeering|organized crime/i)&&(b.isGangAffiliated=!0,b.isDangerous=!0),T.match(/restraining order|protection order|no contact/i)&&(b.hasRestrainingOrder=!0)})}),ie>=2&&(b.hasMultipleDUI=!0,b.isDangerous=!0)}return b},$e=l.useCallback(async(s,L)=>{s&&s.preventDefault();const b=(L||R).trim(),J={gender:v.gender||"",hairColor:v.hairColor||"",eyeColor:v.eyeColor||"",race:v.race||"",height:v.height||""},ie=Object.values(J).some(T=>T&&String(T).trim());if(!b&&!ie){$("Enter a search term, or set at least one Advanced Search filter.");return}if(typeof GetParentResourceName<"u")return await Ye(s);U(null),q([]),V([]),$(""),te({}),ce(null),g({}),We(T=>T+1),c(!0),A("Searching database...");let K=[];try{const T=b.split(/\s+/).filter(Boolean);let le="all";const _e=b.replace(/\s/g,"");/^[\d\s\-\(\)\.]+$/.test(b)&&b.replace(/\D/g,"").length>=7?le="phone":/^\d{3}-?\d{2}-?\d{4}$/.test(_e)?le="ssn":T.length>=2&&T.every(z=>/^[a-zA-Z\-'\.]+$/.test(z))?le="name":T.length===1&&/^[a-zA-Z\-'\.]+$/.test(T[0])?le="partial_name":(/^[A-Z0-9]{2,8}$/i.test(_e)&&/\d/.test(_e)||/^[A-Z]{2,3}\s*[0-9]{2,5}$/i.test(b))&&(le="plate"),`${le}${b}`,`${T.join(", ")}`;const ye=[];if(le==="name"&&T.length>=2){const z=T[0],O=T[T.length-1];if(ye.push({query:b,type:"name",description:"primary name search",priority:1}),ye.push({query:`${O} ${z}`,type:"name",description:"reversed name order",priority:2}),ye.push({query:b,type:"all",description:"comprehensive fallback",priority:3}),T.length>2){const de=T[1];ye.push({query:`${de} ${O}`,type:"name",description:"middle-last combination",priority:4})}}else le==="partial_name"?(ye.push({query:b,type:"partial_name",description:"partial name search",priority:1}),ye.push({query:b,type:"all",description:"comprehensive fallback",priority:3})):(ye.push({query:b,type:le,description:`primary ${le} search`,priority:1}),le!=="all"&&ye.push({query:b,type:"all",description:"comprehensive fallback",priority:3}));`${ye.length}`,ye.map(z=>`${z.description}: "${z.query}" (type: ${z.type})`);const Le=async z=>{try{const O=await Z.post("/lookup",{query:z.query,type:z.type,communityId:o,...ie?{filters:J}:{},_t:Date.now()},{timeout:12e3});return O.data&&Array.isArray(O.data)?(`${z.description}${O.data.length}`,O.data.map(de=>({...st(de),searchSource:z.description,searchPriority:z.priority,_type:de._type||(de.firstName?"civilian":de.plate?"vehicle":de.name?"business":"unknown")}))):[]}catch(O){return O.response?.status===404?`${z.description}`:O.code==="ECONNABORTED"?`${z.description}`:console.error(`Error in ${z.description} search:`,O.message),[]}},Q=ye.filter(z=>z.priority<=2),Ue=ye.filter(z=>z.priority>2);A("Searching database..."),`${Q.length}`;const ot=(await Promise.all(Q.map(Le))).flat();if(ot.length>0?(`${ot.length}`,K=ot):Ue.length>0&&(`${Ue.length}`,A("Expanding search..."),K=(await Promise.all(Ue.map(Le))).flat()),`${K.length}`,K.length===0){U([]),A(""),c(!1);return}A("Removing duplicates...");const Ie=[],pt=new Set;K.sort((z,O)=>z.searchPriority!==O.searchPriority?z.searchPriority-O.searchPriority:0);for(const z of K){let O;if(z._id)O=z._id;else if(z._type==="civilian"||z.firstName||z.lastName){const de=(z.firstName||"").toLowerCase().trim(),Oe=(z.lastName||"").toLowerCase().trim(),Pe=z.dateOfBirth||"no-dob";O=`civilian-${de}-${Oe}-${Pe}`}else z._type==="vehicle"||z.plate?O=`vehicle-${z.plate.toLowerCase().replace(/\s/g,"")}`:z._type==="business"||z.name?O=`business-${(z.name||"").toLowerCase()}`:z._type==="property"?O=`property-${z.postal||""}-${z.road||""}`:O=`other-${JSON.stringify(z).substring(0,100)}`;pt.has(O)?`${z.firstName||z.name||z.plate||"Unknown"}${z.searchSource}`:(pt.add(O),Ie.push(z),`${z.firstName||z.name||z.plate||"Unknown"}${z.searchSource}`)}`${Ie.length}`,A("Checking BOLOs...");let xe=[];try{const z=await Z.get("/bolos/active",{params:{communityId:o}});xe=Array.isArray(z.data)?z.data:[]}catch(z){console.error("Error fetching BOLOs:",z)}const ue=[];for(let z=0;z<Ie.length;z++){const O=Ie[z];if(A(`Processing result ${z+1}/${Ie.length}...`),O.type||(O.type=O._type||(O.firstName?"person":O.plate?"vehicle":O.name?"business":O.postal?"property":"unknown")),(O.type==="person"||O.type==="civilian")&&(O.firstName||O.lastName))try{let de=O._reports||[],Oe=[],Pe={};`${de.length}
1${O.firstName}${O.lastName}`;try{Oe=xe.filter(ke=>{const xt=(ke.subjectFirstName||"").toLowerCase(),jt=(ke.subjectLastName||"").toLowerCase(),qe=(O.firstName||"").toLowerCase(),Xe=(O.lastName||"").toLowerCase();return xt===qe&&jt===Xe||jt===Xe&&xt.charAt(0)===qe.charAt(0)})}catch(ke){console.error("Error filtering BOLOs:",ke),Oe=[]}try{Pe=ve(O,de)}catch(ke){console.error("Error analyzing flags:",ke),Pe={}}ue.push({...O,reports:de,activeBolos:Oe,flags:Pe})}catch(de){console.error("Error enhancing person result:",de),ue.push({...O,reports:[],activeBolos:[],flags:{}})}else if(O.type==="vehicle")try{const de=xe.filter(Oe=>{const Pe=(Oe.vehiclePlate||"").replace(/\s/g,"").toUpperCase(),ke=(O.plate||"").replace(/\s/g,"").toUpperCase();return Pe===ke});ue.push({...O,reports:O._reports||[],activeBolos:de})}catch(de){console.error("Error enhancing vehicle result:",de),ue.push({...O,reports:[],activeBolos:[]})}else ue.push({...O,reports:O._reports||[],activeBolos:[]})}`${ue.length}`,U(ue),V(xe),A(""),ue.length>0&&he.playLookupOutcome(Sr(ue));const Fe={query:b,timestamp:new Date().toLocaleTimeString(),resultCount:ue.length,type:ue.length>0?ue[0].type||"mixed":"none"};r(z=>[Fe,...z.filter(de=>de.query!==b)].slice(0,10))}catch(T){console.error("Lookup error:",T),$("Lookup failed. Please try again."),A("")}finally{c(!1),A("")}},[R,o,v]),Ye=l.useCallback(async s=>{s&&s.preventDefault();const L=R.trim();if(!L){$("Please enter a search term.");return}U(null),q([]),V([]),$(""),c(!0),A("Searching...");try{const b=await fetch(`https://${GetParentResourceName()}/performLookup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:L,communityId:o})});if(!b.ok)throw new Error(`HTTP ${b.status}`);const J=await b.json(),re=(Array.isArray(J)?J:J.results||[]).map(K=>({...st(K),type:K.type||(K.firstName?"person":"unknown"),reports:[],activeBolos:[],flags:{}}));U(re),A(""),re.length>0&&he.playLookupSuccess(),re.length}catch(b){console.error("FiveM search error:",b),$(`Search failed: ${b.message}`),U([{_id:"test-1",firstName:"Test",lastName:"User",type:"person",dateOfBirth:"1990-01-01",licenseNumber:"TEST123",phone:"555-1234",address:"123 Test St",reports:[],activeBolos:[],flags:{}}])}finally{c(!1),A("")}},[R,o]),Me=s=>{ne(s),G(!0)};return e.jsxs("div",{style:{...t.tableWrapper,padding:"24px"},children:[N&&e.jsx(ss,{call:N,onClose:()=>a(null),themeStyles:t,recentLookups:Te,guildId:f,activeCommunity:W,onSearchItem:(s,L)=>{a(null),M(s,L)}}),et&&e.jsx(Gr,{item:et,onClose:()=>tt(null),onRecordLookup:mt,themeStyles:t,activeCommunityId:o,onViewReport:y,onSearchItem:bt,onRequestSuspension:Me}),E&&se&&e.jsx(Pr,{person:se,onClose:()=>{G(!1),ne(null)},onSubmit:async s=>{try{await Dr({...s,personId:se._id,personName:`${se.firstName} ${se.lastName}`,personLicense:se.licenseNumber||se.licenses?.drivers?.number||"N/A",communityId:o,requestedBy:De?.username||De?.email||"Officer",requestedById:De?.id||De?._id}),G(!1),ne(null),F.success("Suspension request submitted successfully")}catch(L){console.error("Failed to submit suspension request:",L),F.error("Failed to submit suspension request: "+(L.response?.data?.msg||L.message))}},themeStyles:t}),ae&&e.jsx(ts,{reportId:ae._id,onClose:()=>ce(null),themeStyles:t}),e.jsx("h3",{style:{fontSize:"20px",marginBottom:"20px"},children:"Database Lookup"}),e.jsxs("div",{style:{display:"flex",gap:"0",marginBottom:"20px",borderBottom:"2px solid #2d3748"},children:[e.jsxs("button",{onClick:()=>ze("search"),style:{padding:"12px 24px",backgroundColor:fe==="search"?"#1a1f2e":"transparent",border:"none",borderBottom:fe==="search"?"2px solid #3b82f6":"2px solid transparent",color:fe==="search"?"#3b82f6":"#9ca3af",fontSize:"16px",fontWeight:fe==="search"?"bold":"normal",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",marginBottom:"-2px"},children:[e.jsx(be,{})," New Search"]}),e.jsxs("button",{onClick:()=>ze("previous"),style:{padding:"12px 24px",backgroundColor:fe==="previous"?"#1a1f2e":"transparent",border:"none",borderBottom:fe==="previous"?"2px solid #3b82f6":"2px solid transparent",color:fe==="previous"?"#3b82f6":"#9ca3af",fontSize:"16px",fontWeight:fe==="previous"?"bold":"normal",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",marginBottom:"-2px"},children:[e.jsx(St,{})," Previous Lookups",Te.length>0&&e.jsx("span",{style:{backgroundColor:"#3b82f6",color:"#fff",padding:"2px 8px",borderRadius:"10px",fontSize:"12px",fontWeight:"bold"},children:Te.length})]})]}),fe==="search"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{backgroundColor:"#0f1419",padding:"12px",borderRadius:"6px",marginBottom:"16
1px",border:"1px solid #2d3748",fontSize:"13px",color:"#9ca3af"},children:[e.jsx("strong",{style:{color:"#60a5fa"},children:"Search Tips:"})," You can search by:",e.jsx("span",{style:{marginLeft:"8px"},children:"⢠First name ⢠Last name ⢠Full name ⢠Phone ⢠SSN ⢠License plate ⢠Address ⢠Firearm serial number"})]}),e.jsxs("form",{onSubmit:$e,style:{marginBottom:"20px"},children:[e.jsxs("div",{style:{display:"flex",gap:"14px",marginBottom:"12px"},children:[e.jsx("input",{value:R,onChange:s=>S(s.target.value),placeholder:"Search by Name, Phone, Address, SSN, or Plate...",style:{...t.modalInput,flex:1,marginBottom:0},disabled:_}),e.jsxs("button",{type:"submit",disabled:_||!R.trim(),style:{...t.touchButton,margin:0,backgroundColor:t.primary,color:"#fff",opacity:_||!R.trim()?.6:1,border:"none",minWidth:"120px"},children:[_?e.jsx(Re,{className:"fa-spin"}):e.jsx(be,{}),e.jsx("span",{style:{marginLeft:"8px"},children:_?"Searching...":"Search"})]})]}),e.jsxs("button",{type:"button",onClick:()=>C(!p),style:{backgroundColor:"transparent",border:"1px solid #2d3748",color:"#60a5fa",padding:"8px 16px",borderRadius:"6px",cursor:"pointer",fontSize:"14px",display:"flex",alignItems:"center",gap:"6px",marginBottom:p?"12px":0},children:[p?e.jsx(ut,{}):e.jsx(He,{}),"Advanced Filters"]}),p&&e.jsxs("div",{style:{backgroundColor:"#0f1419",padding:"16px",borderRadius:"6px",border:"1px solid #2d3748",marginBottom:"12px"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"12px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#9ca3af",display:"block",marginBottom:"4px"},children:"SSN"}),e.jsx("input",{type:"text",placeholder:"XXX-XX-XXXX",value:v.ssn,onChange:s=>X({...v,ssn:s.target.value}),style:{...t.modalInput,marginBottom:0,padding:"8px 12px",fontSize:"14px"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#9ca3af",display:"block",marginBottom:"4px"},children:"Date of Birth"}),e.jsx("input",{type:"date",value:v.dob,onChange:s=>X({...v,dob:s.target.value}),style:{...t.modalInput,marginBottom:0,padding:"8px 12px",fontSize:"14px"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#9ca3af",display:"block",marginBottom:"4px"},children:"Phone Number"}),e.jsx("input",{type:"tel",placeholder:"(555) 123-4567",value:v.phone,onChange:s=>X({...v,phone:s.target.value}),style:{...t.modalInput,marginBottom:0,padding:"8px 12px",fontSize:"14px"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#9ca3af",display:"block",marginBottom:"4px"},children:"License Number"}),e.jsx("input",{type:"text",placeholder:"License #",value:v.licenseNumber,onChange:s=>X({...v,licenseNumber:s.target.value}),style:{...t.modalInput,marginBottom:0,padding:"8px 12px",fontSize:"14px"}})]}),e.jsxs("div",{style:{gridColumn:"span 2"},children:[e.jsx("label",{style:{fontSize:"12px",color:"#9ca3af",display:"block",marginBottom:"4px"},children:"Address"}),e.jsx("input",{type:"text",placeholder:"Street address...",value:v.address,onChange:s=>X({...v,address:s.target.value}),style:{...t.modalInput,marginBottom:0,padding:"8px 12px",fontSize:"14px"}})]}),e.jsx("div",{style:{gridColumn:"1 / -1",borderTop:"1px solid #2d3748",marginTop:"4px",paddingTop:"10px"},children:e.jsx("span",{style:{fontSize:"11px",color:"#6b7280",textTransform:"uppercase",letterSpacing:"0.05em",fontWeight:700},children:"Physical Description"})}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#9ca3af",display:"block",marginBottom:"4px"},children:"Gender"}),e.jsxs("select",{value:v.gender,onChange:s=>X({...v,gender:s.target.value}),style:{...t.modalInput,marginBottom:0,padding:"8px 12px",fontSize:"14px"},children:[e.jsx("option",{value:"",children:"Any"}),e.jsx("option",{value:"Male",children:"Male"}),e.jsx("option",{value:"Female",children:"Female"}),e.jsx("option",{value:"Other",children:"Other"})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#9ca3af",display:"block",marginBottom:"4px"},children:"Race"}),e.jsxs("select",{value:v.race,onChange:s=>X({...v,race:s.target.value}),style:{...t.modalInput,marginBottom:0,padding:"8px 12px",fontSize:"14px"},children:[e.jsx("option",{value:"",children:"Any"}),e.jsx("option",{value:"White",children:"White"}),e.jsx("option",{value:"Black",children:"Black"}
1),e.jsx("option",{value:"Hispanic",children:"Hispanic"}),e.jsx("option",{value:"Asian",children:"Asian"}),e.jsx("option",{value:"Native American",children:"Native American"}),e.jsx("option",{value:"Middle Eastern",children:"Middle Eastern"}),e.jsx("option",{value:"Other",children:"Other"})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#9ca3af",display:"block",marginBottom:"4px"},children:"Hair Color"}),e.jsxs("select",{value:v.hairColor,onChange:s=>X({...v,hairColor:s.target.value}),style:{...t.modalInput,marginBottom:0,padding:"8px 12px",fontSize:"14px"},children:[e.jsx("option",{value:"",children:"Any"}),e.jsx("option",{value:"Black",children:"Black"}),e.jsx("option",{value:"Brown",children:"Brown"}),e.jsx("option",{value:"Blonde",children:"Blonde"}),e.jsx("option",{value:"Red",children:"Red"}),e.jsx("option",{value:"Gray",children:"Gray"}),e.jsx("option",{value:"White",children:"White"}),e.jsx("option",{value:"Bald",children:"Bald"}),e.jsx("option",{value:"Other",children:"Other"})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#9ca3af",display:"block",marginBottom:"4px"},children:"Eye Color"}),e.jsxs("select",{value:v.eyeColor,onChange:s=>X({...v,eyeColor:s.target.value}),style:{...t.modalInput,marginBottom:0,padding:"8px 12px",fontSize:"14px"},children:[e.jsx("option",{value:"",children:"Any"}),e.jsx("option",{value:"Brown",children:"Brown"}),e.jsx("option",{value:"Blue",children:"Blue"}),e.jsx("option",{value:"Green",children:"Green"}),e.jsx("option",{value:"Hazel",children:"Hazel"}),e.jsx("option",{value:"Gray",children:"Gray"}),e.jsx("option",{value:"Amber",children:"Amber"}),e.jsx("option",{value:"Other",children:"Other"})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"12px",color:"#9ca3af",display:"block",marginBottom:"4px"},children:"Height"}),e.jsx("input",{type:"text",placeholder:`e.g. 5'10" or 178`,value:v.height,onChange:s=>X({...v,height:s.target.value}),style:{...t.modalInput,marginBottom:0,padding:"8px 12px",fontSize:"14px"}})]})]}),e.jsx("div",{style:{display:"flex",gap:"10px",marginTop:"12px"},children:e.jsx("button",{type:"button",onClick:()=>X({ssn:"",dob:"",phone:"",address:"",licenseNumber:"",gender:"",hairColor:"",eyeColor:"",race:"",height:""}),style:{padding:"8px 16px",backgroundColor:"#6b7280",color:"#fff",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"14px"},children:"Clear Filters"})})]})]}),I.length>0&&!_&&!P&&e.jsxs("div",{style:{backgroundColor:"#0f1419",padding:"16px",borderRadius:"6px",marginBottom:"20px",border:"1px solid #2d3748"},children:[e.jsx("h4",{style:{fontSize:"14px",marginBottom:"12px",color:"#60a5fa"},children:"Recent Searches"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px"},children:I.map((s,L)=>e.jsxs("button",{onClick:()=>{S(s.query),$e(null,s.query)},style:{padding:"6px 12px",backgroundColor:"#1a1f2e",border:"1px solid #2d3748",color:"#e2e8f0",borderRadius:"4px",cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",gap:"6px"},onMouseEnter:b=>b.currentTarget.style.backgroundColor="#2d3748",onMouseLeave:b=>b.currentTarget.style.backgroundColor="#1a1f2e",children:[e.jsx(St,{style:{fontSize:"11px"}}),e.jsx("span",{children:s.query}),e.jsxs("span",{style:{color:"#6b7280",fontSize:"11px"},children:["(",s.resultCount,")"]})]},L))})]}),_&&u&&e.jsx("div",{style:{padding:"20px",backgroundColor:"#0f1419",border:"1px solid #3b82f6",borderRadius:"6px",marginBottom:"20px",textAlign:"center",fontSize:"16px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"12px"},children:[e.jsx(Re,{className:"fa-spin",style:{color:"#3b82f6",fontSize:"20px"}}),e.jsx("span",{style:{color:"#60a5fa"},children:u})]})}),oe&&e.jsx("div",{style:{padding:"16px",backgroundColor:"rgba(220, 53, 69, 0.1)",border:"1px solid #dc3545",color:"#dc3545",borderRadius:"6px",marginBottom:"20px",fontSize:"16px"},children:oe}),P&&!_&&e.jsx("div",{children:P.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"12px",fontSize:"14px",color:"#9ca3af"},children:["Found ",P.length," result",P.length!==1?"s":"",' for "',R,'"']}),e.jsxs("div",{style:{padding:"10px 14px",backgroundColor:"rgba(59, 130, 246, 0.1)",border:"1px solid #3b82f6",borderRadius:"6px",marginBottom:"16
1px",fontSize:"13px",color:"#60a5fa",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Js,{}),"Click on any result to view full details and add to recent lookups"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:P.filter(s=>{if(!p)return!0;let L=!0;if(v.ssn&&s.ssn){const b=v.ssn.replace(/\D/g,""),J=s.ssn.replace(/\D/g,"");L=L&&J.includes(b)}if(v.dob&&s.dateOfBirth){const b=new Date(v.dob).toDateString(),J=new Date(s.dateOfBirth).toDateString();L=L&&b===J}if(v.phone&&s.phone){const b=v.phone.replace(/\D/g,""),J=s.phone.replace(/\D/g,"");L=L&&J.includes(b)}return v.address&&s.address&&(L=L&&s.address.toLowerCase().includes(v.address.toLowerCase())),v.licenseNumber&&s.licenseNumber&&(L=L&&s.licenseNumber.toLowerCase().includes(v.licenseNumber.toLowerCase())),L}).map((s,L)=>{const b=s._type==="firearm"||s.serialNumber,J=!b&&(s._type==="civilian"||s.type==="person"||s.type==="civilian"||s.firstName||s.lastName),ie=!b&&(s._type==="vehicle"||s.type==="vehicle"||s.plate),re=!b&&!J&&!ie&&(s._type==="property"||s.type==="property"||s.postal||s.propertyType),K=!b&&!J&&!ie&&!re&&(s._type==="business"||s.type==="business"||(s.name||s.businessName)&&!s.firstName&&!s.plate&&!s.postal);return e.jsxs("div",{onClick:()=>tt(s),style:{display:"flex",alignItems:"center",gap:"14px",padding:"14px 18px",backgroundColor:"#0f1419",border:"1px solid #2d3748",borderRadius:"8px",cursor:"pointer",transition:"all 0.15s ease"},onMouseEnter:T=>{T.currentTarget.style.backgroundColor="#1a1f2e",T.currentTarget.style.borderColor="#3b82f6"},onMouseLeave:T=>{T.currentTarget.style.backgroundColor="#0f1419",T.currentTarget.style.borderColor="#2d3748"},children:[ie&&(s._customPlate||s.customPlate)?e.jsx(es,{plate:s._customPlate||s.customPlate,plateText:(s.plate||s.licensePlate||"").toUpperCase(),width:88}):e.jsxs("div",{style:{width:"44px",height:"44px",borderRadius:"8px",backgroundColor:J?"#3b82f6":ie?"#f59e0b":b?"#ef4444":re?"#8b5cf6":"#10b981",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,overflow:"hidden"},children:[J&&(()=>{const T=s.mugshotUrl;if(!T)return e.jsx(we,{style:{color:"#fff",fontSize:"18px"}});let le;return T.startsWith("data:")||T.startsWith("http://")||T.startsWith("https://")||T.startsWith("//")?le=T:T.startsWith("/9j")?le=`data:image/jpeg;base64,${T}`:T.startsWith("iVBOR")?le=`data:image/png;base64,${T}`:le=`data:image/png;base64,${T}`,e.jsx("img",{src:le,alt:"",style:{width:"44px",height:"44px",objectFit:"cover"},onError:_e=>{_e.currentTarget.style.display="none"}})})(),ie&&e.jsx(Ne,{style:{color:"#fff",fontSize:"18px"}}),b&&e.jsx(at,{style:{color:"#fff",fontSize:"18px"}}),re&&e.jsx(kt,{style:{color:"#fff",fontSize:"18px"}}),K&&e.jsx(Ve,{style:{color:"#fff",fontSize:"18px"}})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",flexWrap:"wrap"},children:[e.jsxs("strong",{style:{fontSize:"17px",color:"#e2e8f0"},children:[J&&`${s.firstName||""} ${s.middleName||""} ${s.lastName||""}`.trim(),ie&&s.plate,b&&`S/N: ${s.serialNumber||"Unknown"} - ${s.make||""} ${s.model||""}`.trim(),re&&(s.address||`${s.road||"Property"} ${s.postal?`(${s.postal})`:""}`),K&&(s.businessName||s.name||"Unknown Business")]}),s.flags?.hasPendingWarrant&&!s.flags?.hasWarrant&&e.jsx("span",{title:"Pending judicial review - do not act",style:{padding:"2px 8px",backgroundColor:"#f59e0b",color:"#1f2937",borderRadius:"4px",fontSize:"11px",fontWeight:"bold"},children:"IN REVIEW"}),s.flags?.hasWarrant&&e.jsx("span",{style:{padding:"2px 8px",backgroundColor:"#ef4444",color:"#fff",borderRadius:"4px",fontSize:"11px",fontWeight:"bold"},children:"WARRANT"}),s.missingPerson&&e.jsx("span",{style:{padding:"2px 8px",backgroundColor:"#dc2626",color:"#fff",borderRadius:"4px",fontSize:"11px",fontWeight:"bold"},children:"MISSING"}),(s.stolen||s.isStolen)&&e.jsx("span",{style:{padding:"2px 8px",backgroundColor:"#ef4444",color:"#fff",borderRadius:"4px",fontSize:"11px",fontWeight:"bold"},children:"STOLEN"}),s.flags?.isFelon&&e.jsx("span",{style:{padding:"2px 8px",backgroundColor:"#dc2626",color:"#fff",borderRadius:"4px",fontSize:"11px",fontWeight:"bold"},children:"FELON"}),s.flags?.isSuspended&&e.jsx("span",{style:{padding:"2px 8px",backgroundColor:"#f59e0b",color:"#000",borderRadius:"4px",fontSize:"11px",fontWeight:"bold"},children:"SUSPENDED"}),s.activeBolos?.length>0&&e.jsx("span",{style:{padding:"2px 8px",backgroundColor:"#ef4444",color:"#fff",borderRadius:"4px",fontSize:"11px",fontWeight:"bold"},children:"BOLO"}),s.flags?.isViolent&&e.jsx("span",{style:{padding:"2px 8px",backgroundColor:"#7f1d1d",color:"#fff",borderRadius:"4px",fontSize:"11px",fontWeight:"bold"},children:"VIOLENT"}),s.flags?.hasDrugCharges&&e.jsx("span",{style:{padding:"2px 8px",backgroundColor:"#8b5cf6",color:"#fff",borderRadius:"4px",fontSize:"11px",fontWeight:"bold"},children:"DRUGS"}),s.flags?.hasWeaponsCharges&&e.jsx("span",{style:{padding:"2px 8px",backgroundColor:"#ec4899",color:"#fff",borderRadius:"4px",fontSize:"11px",fontWeight:"bold"},children:"WEAPONS"}),s.isDangerous&&e.jsx("span",{style:{padding:"2px 8px",backgroundColor:"#dc2626",color:"#fff",borderRadius:"4px",fontSize:"11px",fontWeight:"bold"},children:"DANGEROUS"})]}),e.jsxs("div",{style:{fontSize:"13px",color:"#9ca3af",marginTop:"4px"},children:[J&&e.jsxs(e.Fragment,{children:[s.ssn&&e.jsxs("span",{style:{color:"#60a5fa"}
1,children:["SSN: ",s.ssn]}),s.ssn&&s.dateOfBirth&&" ⢠",s.dateOfBirth&&`DOB: ${new Date(s.dateOfBirth).toLocaleDateString()}`,s.dateOfBirth&&` (Age: ${Math.floor((new Date-new Date(s.dateOfBirth))/31536e6)})`,s.address&&` ⢠${s.address}`]}),ie&&e.jsxs(e.Fragment,{children:[[s.year,s.color,s.make,s.model].filter(Boolean).join(" "),(s.ownerName||s.owner?.firstName)&&` ⢠Owner: ${s.ownerName||`${s.owner?.firstName||""} ${s.owner?.lastName||""}`.trim()}`]}),b&&e.jsxs(e.Fragment,{children:[[s.caliber,s.type].filter(Boolean).join(" ⢠"),s.owner&&` ⢠Owner: ${s.owner.firstName||""} ${s.owner.lastName||""}`.trim()]}),re&&e.jsxs(e.Fragment,{children:[s.propertyType||"Property",s.postal&&` ⢠Postal: ${s.postal}`,s.ownerName&&` ⢠Owner: ${s.ownerName}`]}),K&&e.jsxs(e.Fragment,{children:[s.businessType||s.category||"Business",s.address&&` ⢠${s.address}`]})]})]}),e.jsx(He,{style:{color:"#4a5568",fontSize:"16px",flexShrink:0}})]},`${Ce}-${s._id||L}`)})})]}):e.jsxs("div",{style:{padding:"40px",textAlign:"center",backgroundColor:"#0f1419",borderRadius:"6px",border:"1px solid #2d3748"},children:[e.jsx(be,{style:{fontSize:"48px",color:"#4a5568",marginBottom:"16px",display:"block",margin:"0 auto 16px"}}),e.jsx("h3",{style:{fontSize:"20px",color:"#e2e8f0",marginBottom:"8px"},children:"No Results Found"}),e.jsxs("p",{style:{fontSize:"16px",color:"#9ca3af"},children:['No records found for "',R,'" in the database.']}),e.jsx("p",{style:{fontSize:"14px",color:"#6b7280",marginTop:"8px"},children:"Try searching with a different name, plate number, or SSN."})]})},`search-results-${Ce}`)]}),fe==="previous"&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px",flexWrap:"wrap",gap:"10px"},children:[e.jsxs("div",{children:[e.jsx("h3",{style:{margin:0,fontSize:"18px",color:"#e2e8f0"},children:"Recent Database Lookups"}),e.jsxs("p",{style:{margin:"4px 0 0",fontSize:"13px",color:"#9ca3af"},children:["Your last ",Te.length," searches"]})]}),e.jsxs("div",{style:{display:"flex",gap:"10px"},children:[e.jsx("button",{onClick:Ee,disabled:Be,style:{padding:"10px 16px",backgroundColor:"#3b82f6",color:"#fff",border:"none",borderRadius:"6px",cursor:Be?"not-allowed":"pointer",fontSize:"14px",opacity:Be?.6:1},children:e.jsx(Re,{className:Be?"fa-spin":""})}),Te.length>0&&e.jsx("button",{onClick:rt,style:{padding:"10px 16px",backgroundColor:"#dc2626",color:"#fff",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"14px"},children:e.jsx(zt,{})})]})]}),k&&e.jsxs("div",{style:{padding:"12px",backgroundColor:"rgba(16, 185, 129, 0.1)",border:"1px solid #10b981",borderRadius:"6px",marginBottom:"16px",fontSize:"14px",color:"#10b981",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(dt,{}),e.jsx("span",{children:"Active call selected - Use Attach buttons to link lookups"})]}),Be?e.jsxs("div",{style:{textAlign:"center",padding:"40px",color:"#9ca3af"},children:[e.jsx(Re,{className:"fa-spin",style:{fontSize:"24px",marginBottom:"12px"}}),e.jsx("p",{children:"Loading recent lookups..."})]}):Te.length>0?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:Te.map(s=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"16px",backgroundColor:"#0f1419",border:"1px solid #2d3748",borderRadius:"8px",transition:"all 0.2s"},children:[e.jsxs("div",{style:{width:"40px",height:"40px",borderRadius:"8px",backgroundColor:s.lookupType==="civilian"?"#3b82f6":s.lookupType==="vehicle"?"#f59e0b":s.lookupType==="firearm"?"#ef4444":s.lookupType==="business"?"#10b981":s.lookupType==="property"?"#8b5cf6":"#6b7280",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:[s.lookupType==="civilian"&&e.jsx(we,{style:{color:"#fff",fontSize:"18px"}}),s.lookupType==="vehicle"&&e.jsx(Ne,{style:{color:"#fff",fontSize:"18px"}}),s.lookupType==="firearm"&&e.jsx(at,{style:{color:"#fff",fontSize:"18px"}}),s.lookupType==="business"&&e.jsx(Ve,{style:{color:"#fff",fontSize:"18px"}}),s.lookupType==="property"&&e.jsx(kt,{style:{color:"#fff",fontSize:"18px"}}),!["civilian","vehicle","firearm","business","property"].includes(s.lookupType)&&e.jsx(be,{style:{color:"#fff",fontSize:"18px"}})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"},children:[e.jsxs("strong",{style:{fontSize:"16px",color:"#e2e8f0"},children:[s.lookupType==="civilian"&&(s.snapshot?.name||`${s.snapshot?.firstName||""} ${s.snapshot?.lastName||""}`.trim()||"Unknown"),s.lookupType==="vehicle"&&(s.snapshot?.plate||"Unknown Plate"),s.lookupType==="firearm"&&`S/N: ${s.snapshot?.serialNumber||"Unknown"} - ${s.snapshot?.make||""} ${s.snapshot?.model||""}`.trim(),s.lookupType==="business"&&(s.snapshot?.businessName||s.snapshot?.name||"Unknown Business"),s.lookupType==="property"&&(s.snapshot?.address||s.snapshot?.name||"Unknown Property"),!["civilian","vehicle","firearm","business","property"].includes(s.lookupType)&&(s.snapshot?.name||"Unknown")]}),s.snapshot?.hasWarrants&&e.jsx("span",{style:{padding:"2px 8px",backgroundColor:"#dc2626",color:"#fff",borderRadius:"4px",fontSize:"11px",fontWeight:"bold"},children:"WARRANT"}),s.snapshot?.isMissing&&e.jsx("span",{style:{padding:"2px 8px",backgroundColor:"#f59e0b",color:"#000",borderRadius:"4px",fontSize:"11px",fontWeight:"bold"},children:"MISSING"}),s.snapshot?.isStolen&&e.jsx("span",{style:{padding:"2px 8px",backgroundColor:"#dc2626",color:"#fff",borderRadius:"4px",fontSize:"11px",fontWeight:"bold"},children:"STOLEN"})]}),e.jsxs("div",{style:{fontSize:"13px",color:"#9ca3af",marginTop:"4px"},children:[s.lookupType==="civilian"&&e.jsxs(e.Fragment,{children:[s.snapshot?.dateOfBirth&&`DOB: ${new Date(s.snapshot.dateOfBirth).toLocaleDateString()}`,s.snapshot?.licenseNumber&&` ⢠License: ${s.snapshot.licenseNumber}`,s.snapshot?.phone&&` ⢠${s.snapshot.phone}`]}),s.lookupType==="vehicle"&&e.jsxs(e.Fragment,{children:[[s.snapshot?.color,s.snapshot?.year,s.snapshot?.make,s.snapshot?.model].filter(
1Boolean).join(" "),s.snapshot?.ownerName&&` ⢠Owner: ${s.snapshot.ownerName}`]}),s.lookupType==="firearm"&&e.jsxs(e.Fragment,{children:[[s.snapshot?.caliber,s.snapshot?.type].filter(Boolean).join(" ⢠"),s.snapshot?.ownerName&&` ⢠Owner: ${s.snapshot.ownerName}`]}),s.lookupType==="business"&&e.jsxs(e.Fragment,{children:[s.snapshot?.businessType||"Business",s.snapshot?.address&&` ⢠${s.snapshot.address}`]}),s.lookupType==="property"&&e.jsxs(e.Fragment,{children:[s.snapshot?.propertyType||"Property",s.snapshot?.postal&&` ⢠Postal: ${s.snapshot.postal}`]})]})]}),e.jsx("div",{style:{fontSize:"12px",color:"#6b7280",flexShrink:0,textAlign:"right"},children:nt(s.createdAt)}),e.jsxs("div",{style:{display:"flex",gap:"6px",flexShrink:0},children:[k&&(s.lookupType==="civilian"||s.lookupType==="vehicle")&&e.jsxs("button",{onClick:async L=>{L.stopPropagation();try{const b=s.recordId||s.civilianId||s.vehicleId;s.lookupType==="vehicle"?(await Z.patch(`/calls/${k}/attach-vehicle`,{vehicleId:b,plate:s.snapshot?.plate,color:s.snapshot?.color,make:s.snapshot?.make,model:s.snapshot?.model,year:s.snapshot?.year}),F.success("Vehicle attached to call")):(await Vt(k,{civilianId:b,firstName:s.snapshot?.firstName,lastName:s.snapshot?.lastName,dateOfBirth:s.snapshot?.dateOfBirth,phone:s.snapshot?.phone,licenseNumber:s.snapshot?.licenseNumber},"dashboard-page-3"),F.success("Civilian attached to call")),w&&w()}catch(b){console.error("Attach error:",b),F.error(je(b,"Failed to attach to call"))}},style:{padding:"8px 12px",backgroundColor:"#10b981",color:"#fff",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[e.jsx(gt,{})," Attach"]}),e.jsx("button",{onClick:L=>{L.stopPropagation(),Ae(s)},style:{padding:"8px 12px",backgroundColor:"#3b82f6",color:"#fff",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",gap:"6px",flexShrink:0},title:"Re-run this search",children:e.jsx(be,{})})]})]},s._id))}):e.jsxs("div",{style:{padding:"60px 20px",textAlign:"center",backgroundColor:"#0f1419",borderRadius:"8px",border:"1px solid #2d3748"},children:[e.jsx(St,{style:{fontSize:"48px",color:"#4a5568",marginBottom:"16px"}}),e.jsx("h3",{style:{fontSize:"18px",color:"#e2e8f0",marginBottom:"8px"},children:"No Recent Lookups"}),e.jsx("p",{style:{fontSize:"14px",color:"#9ca3af",marginBottom:"20px"},children:"Your database searches will appear here for quick reference"}),e.jsxs("button",{onClick:()=>ze("search"),style:{padding:"12px 24px",backgroundColor:"#3b82f6",color:"#fff",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"14px",display:"inline-flex",alignItems:"center",gap:"8px"},children:[e.jsx(be,{})," Start Searching"]})]})]})]})},Wn=()=>{const{user:t,loading:o,logout:h}=wt(),{activeCommunity:n,setActiveCommunity:y}=ft(),k=l.useMemo(()=>Lr(n?.cadSettings?.statusCodes),[n?.cadSettings?.statusCodes]),w=ht(),[f,m]=l.useState(window.innerWidth<768);l.useEffect(()=>{const i=()=>m(window.innerWidth<768);return window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[]);const[W,M]=l.useState(window.innerWidth<768),[R,S]=l.useState(t?.status||sessionStorage.getItem("cad_lastStatus")||"10-7");l.useEffect(()=>{t?.status&&t.status!=="10-7"&&t.status!=="Offline"&&(S(t.status),sessionStorage.setItem("cad_lastStatus",t.status))},[t?.status]);const[P,U]=l.useState([]),[ee,q]=l.useState({}),[j,V]=l.useState([]),[_,c]=l.useState(""),[u,A]=l.useState("dashboard"),[oe,$]=l.useState(!1),[ge,te]=l.useState(!1),[ae,ce]=l.useState(!1),[B,g]=l.useState(!1),[E,G]=l.useState(!1),[se,ne]=l.useState(!1),[N,a]=l.useState(""),[I,r]=l.useState(new Date),[p,C]=l.useState(!1),[v,X]=l.useState([]),[Ce,We]=l.useState([]),[De,fe]=l.useState(null),[ze,Te]=l.useState(0),[Ge,Be]=l.useState(null),[ct,yt]=l.useState(null),[At,et]=l.useState(!1),[tt,st]=l.useState(null),[Ee,rt]=l.useState(!1),[Ae,nt]=l.useState(null),[mt,bt]=l.useState(()=>{const i=localStorage.getItem("cad-sound-volume");return i!==null?parseFloat(i):.5}),[ve,$e]=l.useState(null),[Ye,Me]=l.useState([]),[s,L]=l.useState(t?.callSign||sessionStorage.getItem("lastCallSign")||"N/A"),[b,J]=l.useState(t?.department||sessionStorage.getItem("lastDepartment")||"NO DEPT"),[ie,re]=l.useState(sessionStorage.getItem("lastDepartmentFull")||""),[K,T]=l.useState(null),[le,_e]=l.useState(0),ye=l.useRef("dashboard");l.useEffect(()=>{ye.current=u,u==="messages"&&_e(0)},[u]);const Le=l.useRef(new Set),Q=Or(W,f),Ue=yr(gs(Q.modalContent,Q.modalInput)),ot=l.useCallback(i=>{T(i),setTimeout(()=>T(null),5e3)},[]);l.useEffect(()=>{const i=d=>{const x=String(t?._id);if(String(d.senderId)!==x&&!(d.participants&&!d.participants.map(String).includes(x))&&ye.current!=="messages"){let H=!1;try{H=JSON.parse(localStorage.getItem(`muted-convos-${n?._id}`)||"[]").includes(d.conversationId)}catch{}if(!H)try{he.playNotification?.()||he.playSuccess?.()}catch{}if(_e(Y=>Y+1),H)return;T({senderName:d.senderName||"Unknown",senderCallSign:d.senderCallSign,message:d.message?.message||"",conversationId:d.conversationId}),setTimeout(()=>T(null),5e3),it(d.senderName||"CAD",d.message?.message||"",{toastType:"info",tag:`cadmsg:${d.senderId||d.conversationId||""}`,desktopOnly:!0})}};return me.on("cadMessage",i),()=>me.off("cadMessage",i)},[t?._id,n?._id]),l.useEffect(()=>{he.loadCommunitySounds(n?.cadSettings?.customSounds,n?._id)},[n?.cadSettings?.customSounds,n?._id]),l.useEffect(()=>{U([]),V([]),X([]),Me([]),q({})},[n?._id]),l.useEffect(()=>{const i=setInterval(()=>{q(d=>{const x=Date.now()-9e4,D=Object.entries(d).filter(([,H])=>(H.ts||0)>=x);return D.length===Object.keys(d).length?d:Object.fromEntries(D)})},5e3);return()=>clearInterval(i)},[]);const Ie=l.useMemo(()=>{const i={isSuperAdmin:t?.isSuperAdmin===!0,isCommunityAdmin:!1,isSupervisor:!1,isModerator:!1};if(i.isSuperAdmin)return i.isCommunityAdmin=!0,i.isSupervisor=!0,i.isModerator=!0,i;if(t&&n?._id&&Array.isArray(t.communities)){const d=String(n._id),x=t.communities.find(D=>{const H=D.community?._id||D.community||D._id;return String(H)===d});if(x){const D=n.ownerId===t.discordId,H=["admin","owner"].includes(x.role),Y=x.permissions?.isCommunityAdmin===!0,pe=x.permissions?.isSupervisor===!0,Se=["supervisor"].includes(x.role);D||H||Y?(i.isCommunityAdmin=!0,i.isSupervisor=!0,i.isModerator=!0):(pe||Se)&&(i.isSupervisor=!0,i.isModerator=!0)}if(n?.guildId&&n?.permissions?.supervisorRoleIds?.length){const D=t.roles?.[n.guildId]||[];n.permissions.supervisorRoleIds.some(Y=>Y&&D.includes(Y))&&(i.isSupervisor=!0,i.isModerator=!0)}}return i},[t,n]),pt=i=>{bt(i),he.setVolume(i)};l.useEffect(()=>hs(me,n?._id),[n?._id]),l.useEffect(()=>{if(!n?._id||!me)return;const i={"statelink-alert":d=>{d?.unitId&&q(x=>{const D=x[d.unitId];return D&&D.priority<d.priority?{...x,[d.unitId]:{...D,ts:d.ts||Date.now()}}:{...x,[d.unitId]:{text:d.text,priority:d.priority,ts:d.ts||Date.now(),username:d.username||""}}})},"status-update":d=>{U(x=>x.map(D=>D.username===d.username?{...D,status:d.status,location:d.location||D.location}
1:D)),q(x=>{const D=Object.entries(x).find(([,Y])=>Y.username&&Y.username===d.username);if(!D)return x;const H={...x};return delete H[D[0]],H}),d.username===t?.username&&S(d.status)},"unit-info-update":d=>{U(x=>x.map(D=>D.username===d.username?{...D,...d}:D))},"new-bolo":d=>{X(x=>[...x,d]),he.playBolo(),it("BOLO issued",d?.title||d?.subjectName||"",{toastType:"info",tag:`bolo:${d?._id||""}`})},"new-911-call":d=>{z(),setTimeout(()=>{Le.current.has("__new911__")||he.play911Alert(d)},300),it("New 911 Call",d?.callType||d?.nature||d?.location||"",{toastType:"warning",tag:`call:${d?._id||""}`,desktopOnly:!0})},callUpdated:d=>{const x=d?._id;if(x&&d.status!=="closed"&&d.status!=="cancelled"&&V(H=>H.map(Y=>String(Y._id)===String(x)?{...Y,...d}:Y)),x&&Le.current.has(String(x))){z();return}d?.assignedUnits?.some(H=>{const Y=typeof H.unitId=="object"?H.unitId?._id:H.unitId;return String(Y)===String(t?._id)})&&(he.playCallAssigned(d),it("Call assigned to your unit",d?.callType||d?.location||"",{toastType:"info",tag:`assigned:${x||""}`,desktopOnly:!0})),z()},"call-updated":()=>{z()},"panic-button":d=>{$e(d),he.playPanic(),it("PANIC",d?.callSign||d?.officerName||d?.username||"unknown unit",{urgent:!0,toastType:"error",tag:`panic:${d?.officerId||d?.officerName||d?.username||""}`})},"call-note-added":d=>{d?.assignedUnits?.some(x=>{const D=typeof x.unitId=="object"?x.unitId?._id:x.unitId;return String(D)===String(t?._id)})&&he.playCallNote()},"new-announcement":d=>{Me(x=>As(x,d)),he.playAnnouncement(d.priority)},"announcement-removed":d=>{Me(x=>x.filter(D=>D._id!==d.id))},"mdt-radio-announcement":d=>{if(d.communityId&&n?._id&&String(d.communityId)!==String(n._id)||d.unitId&&(!t?._id||String(d.unitId)!==String(t._id)))return;d.type,d.message;const x=d.callId?String(d.callId):null;if(x&&(Le.current.add(x),setTimeout(()=>Le.current.delete(x),1e4)),d.type==="new-call"&&(Le.current.add("__new911__"),setTimeout(()=>Le.current.delete("__new911__"),1e4)),d.audioData){const D=d.type==="new-call"?"alert911":null,H=d.type==="new-call"?1200:0;he.playTTS(d.audioData,D,H,d.effects||null).catch(()=>{})}else d.type==="new-call"?he.play911Alert():he.playCallUpdated()}};return Object.entries(i).forEach(([d,x])=>me.on(d,x)),()=>{Object.entries(i).forEach(([d,x])=>me.off(d,x))}},[n?._id]);const xe=l.useCallback(async(i=!1)=>{if(n?._id){i&&C(!0);try{const[d,x]=await Promise.all([ys().catch(()=>({units:[]})),ms().catch(()=>[])]);let D=[];try{D=(await Z.get("/bolos/active",{params:{communityId:n._id}})).data}catch(Se){console.error("Error fetching BOLOs:",Se)}let H=[];try{H=(await Z.get("/announcements/active",{params:{communityId:n._id}})).data}catch(Se){console.error("Error fetching announcements:",Se)}const Y=d.units||[];if(Fe.current){const{status:Se,username:as,userId:ls}=Fe.current,vt=Y.findIndex(Lt=>Lt.username===as||Lt._id===ls);vt!==-1&&(Y[vt]={...Y[vt],status:Se})}U(Y),V(Array.isArray(x)?x:[]),X(Array.isArray(D)?D:[]),Me(Array.isArray(H)?H:[]);const pe=Y.find(Se=>Se.username===t?.username||String(Se._id)===String(t?._id));pe?.status&&pe.status!=="10-7"&&(S(pe.status),sessionStorage.setItem("cad_lastStatus",pe.status))}catch{c("Could not fetch data")}finally{i&&C(!1)}}},[n]),ue=l.useRef(null),Fe=l.useRef(null),z=l.useCallback(()=>{ue.current&&clearTimeout(ue.current),ue.current=setTimeout(()=>xe(),1e3)},[xe]);l.useEffect(()=>()=>{ue.current&&clearTimeout(ue.current)},[]),l.useEffect(()=>{if(n?._id){xe();const i=setInterval(xe,6e4);return()=>clearInterval(i)}},[n?._id,xe]),l.useEffect(()=>{j.length>ze&&ze!==0&&he.play911Alert(),Te(j.length)},[j.length,ze]),l.useEffect(()=>{const i=setInterval(()=>r(new Date),1e3);return()=>clearInterval(i)},[]),l.useEffect(()=>{!o&&!t&&w("/login")},[t,o,w]),l.useEffect(()=>{t&&!n?._id&&ce(!0)},[t,n]),l.useEffect(()=>{n?._id&&Z.get("/reports/departments",{params:{communityId:n._id}}).then(({data:i})=>{const x=(i?.success?i.departments||[]:[]).filter(D=>!D.shortName?.toUpperCase().includes("CIV")&&!D.name?.toUpperCase().includes("CIVILIAN"));We(x)}).catch(()=>We([]))},[n]),l.useEffect(()=>{(async()=>{if(n?._id)try{const d=await Z.get("/user/profile",{params:{communityId:n._id},headers:{"x-community-id":n._id}});if(d.data?.user){const x=d.data.user;x.callSign&&(L(x.callSign),sessionStorage.setItem("lastCallSign",x.callSign)),x.department&&(J(x.department),sessionStorage.setItem("lastDepartment",x.department))}}catch(d){console.error("Failed to fetch user profile:",d);const x=sessionStorage.getItem("lastCallSign"),D=sessionStorage.getItem("lastDepartment");x&&L(x),D&&J(D)}})()},[n?._id]);const O=l.useCallback(async(i,d=null)=>{try{const x=d?`${i} @ ${d}`:i;if(!await Ue({status:x}))return;const D=R;S(x),sessionStorage.setItem("cad_lastStatus",x),U(H=>H.map(Y=>Y.username===t?.username||Y._id===t?._id?{...Y,status:x,location:d||Y.location}:Y)),Fe.current={status:x,username:t?.username,userId:t?._id},setTimeout(()=>{Fe.current?.status===x&&(Fe.current=null)},5e3),await bs(x).catch(H=>{Fe.current=null,S(D),U(Y=>Y.map(pe=>pe.username===t?.username||pe._id===t?._id?{...pe,status:D}:pe)),F.error(je(H,"Failed to update status"))}),me&&n?._id&&me.emit("status-update",{userId:t._id,username:t.username,status:x,communityId:n._id,location:d})}catch{c("Failed to update status")}},[t,n,me,R,Ue]),de=l.useMemo(()=>P.map(i=>{let d=i.status||"Out of Service",x=i.location||"N/A";if(i.status&&i.status.includes("@")){const D=i.status.split("@");d=D[0].trim(),x=D[1].trim()}return{_id:i._id,cad_unit:i.callSign||i.username?.substring(0,8)||"UNIT",status:d,statusFull:i.status,details:`${i.displayName||i.username||"Unknown"} - ${i.department||"N/A"}${i.subDepartment?` [${i.subDepartment}]`:""}`,location:x,username:i.username,activeCallId:i.activeCallId,unitGroup:i.unitGroup,unitGroupId:i.unitGroupId,unitGroupLeader:i.unitGroupLeader}}),[P]),Oe=l.useMemo(()=>j.map(i=>{let d=i.location||"";return i.postal&&!d.includes(i.postal)&&(d=`${d} (Postal: ${i.postal})`),{...i,location:d,incident_code:i.incident_number?.split("-")[0]||"000"}}),[j]),Pe={752:"#7f1d1d",747:"#7f1d1d",757:"#713f12",758:"#713f12"},ke=l.useMemo(()=>{const i=P.find(H=>H.username===t?.username||H.callSign===s);if(!i)return null;const d=(i.status||"").split("@")[0].trim();if(!["10-97","10-23","10-76","10-11"].includes(d))return null;if(i.activeCallId)return i.activeCallId;const D=(i.status||"").includes("@")?i.status.split("@")[1].trim():i.location;if(D&&j.length>0){const H=j.find(Y=>Y.location&&D.toLowerCase().includes(Y.location.toLowerCase()));if(H)return H._id}return null},[P,j,t?.username,s]),xt=async i=>{try{for(const d of i)await Z.delete(`/calls/${d._id}`).catch(()=>{});F.success("All calls cleared!"),await xe()}catch(d){F.error(je(d,"Failed to clear all calls"))}},qe=(()=>{let i=R;return R&&R.includes("@")&&(i=R.split("@")[0].trim()),k.find(x=>i===x.code||i===x.ui||i===x.api||i===x.actualStatus)||k.find(x=>x.code==="10-7")||k[k.length-1]})(),Xe=l.useCallback((i,d)=>{switch(a(i),d){case"trafficStop":te(!0);break;case"beginShift":ne(!0);break;case"attach":$(!0);break;default:O(i);break}},[O]),rs=l.useCallback(i=>{const d=k.find(x=>x.code===i||x.ui===i||x.api===i||x.actualStatus===i);Xe(i,d?.action)},[k,Xe]);js(rs);const ns=async i=>{const d=await Ue({signOn:!0,callSign:i.callSign,department:i.department});if(!d)return;const x=d.callSign?{...i,callSign:d.callSign}:i;try{const D={callSign:x.callSign,department:x.department,subDepartment:x.subDepartment||null,useDiscordNickname:x.useDiscordNickname,displayName:x.useDiscordNickname?void 0:x.displayName};await Z.patch("/user/profile",D).catch(pe=>console.error("Profile update error:",pe));const Y=n?.departments?.find(pe=>pe.name===x.department||pe.shortName===x.department)?.name||x.department||"";if(L(x.callSign),J(x.department),re(Y),sessionStorage.setItem("lastCallSign",x.callSign),sessionStorage.setItem("lastDepartment",x.department),sessionStorage.setItem("lastDepartmentFull",Y),sessionStorage.setItem("lastSubDepartment",x.subDepartment||""),sessionStorage.setItem("lastDisplayName",x.displayName||""),await O("10-41","Beginning Shift"),x.apparatusId&&n?._id)try{await Ns(x.apparatusId,n._id)}catch(pe){console.error("Apparatus assign error:",pe)}me&&n?._id&&me.emit("unit-info-update",{userId:t._id,username:t.username,department:x.department,subDepartment:x.subDepartment||null,callSign:x.callSign,displayName:x.useDiscordNickname?void 0:x.displayName,useDiscordNickname:x.useDiscordNickname,status:"10-41",communityId:n._id}),ne(!1),c(`You are now 10-41 (Beginning Shift) as ${x.callSign}`),setTimeout(()=>c(""),3e3),z()}catch(D){console.error("Error beginning shift:",D),c("Failed to begin shift")}},os=async i=>{const d=`${i.road}${i.postal?`, ${i.postal}`:""} (${i.plate})`,x=[i.color,i.year,i.make,i.model].map(H=>
1String(H||"").trim()).filter(Boolean).join(" "),D=[];x&&D.push(`Vehicle: ${x}`),D.push(`Occupants: ${i.occupants||"1"}x`),i.notes&&D.push(`Reason: ${i.notes}`);try{const Y=(await Z.post("/civilian/911-call",{callType:Cs(ks(n?.cadSettings),"Traffic Stop")||"Traffic Stop",location:d,postal:i.postal||"",callerName:t?.callSign||t?.username,description:D.join(" | ")})).data;if(Y?._id&&t?._id)try{await Z.put(`/calls/${Y._id}/assign-unit`,{action:"add",unitId:t._id,unitName:t.callSign||t.username})}catch(pe){console.error("Failed to auto-attach unit to traffic stop:",pe)}await xe(),O("10-11",d),te(!1)}catch{c("Failed to log traffic stop")}},is=async i=>{F.warn(e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:"10px"},children:"Remove this call?"}),e.jsxs("div",{style:{display:"flex",gap:"10px"},children:[e.jsx("button",{onClick:async()=>{F.dismiss();try{await Z.delete(`/calls/${i}`),await xe(),F.success("Call removed successfully!")}catch(d){F.error(je(d,"Failed to remove call"))}},style:{padding:"6px 16px",backgroundColor:"#dc2626",color:"#fff",border:"none",borderRadius:"4px",cursor:"pointer"},children:"Delete"}),e.jsx("button",{onClick:()=>F.dismiss(),style:{padding:"6px 16px",backgroundColor:"#374151",color:"#fff",border:"none",borderRadius:"4px",cursor:"pointer"},children:"Cancel"})]})]}),{autoClose:!1,closeOnClick:!1,draggable:!1,closeButton:!1})};return o?e.jsx("div",{style:{...Q.container,...Q.content,alignItems:"center",justifyContent:"center"},children:e.jsx("h3",{children:"Loading..."})}):t?e.jsxs("div",{style:Q.container,children:[e.jsxs(Ls,{children:[e.jsx("title",{children:"Police MDT Dashboard | CDE CAD"}),e.jsx("meta",{name:"description",content:"Police Mobile Data Terminal - run lookups, write reports, manage BOLOs, and track units in real time."})]}),ae&&e.jsx(dr,{communities:t?.communities||[],onSelect:i=>{y(i),ce(!1)},themeStyles:Q}),oe&&e.jsx(Fr,{calls:j,onAttach:async i=>{if(i)try{await Z.put(`/calls/${i._id}/assign-unit`,{action:"add",unitId:t._id,unitName:s||t.username})}catch(d){console.error("Failed to assign unit to call:",d)}O(N,i?i.location:null),$(!1)},onClose:()=>$(!1),themeStyles:Q}),ge&&e.jsx(Er,{onLog:os,onClose:()=>te(!1),themeStyles:Q,communityId:n?._id}),se&&e.jsx(_r,{onConfirm:ns,onClose:()=>ne(!1),themeStyles:Q,user:t,availableDepartments:Ce,communityId:n?._id,requireVehicle:!!n?.cadSettings?.requireApparatusSelection}),B&&e.jsx(Mr,{onClose:()=>g(!1),themeStyles:Q,activeCommunityId:n?._id,user:t,userRoles:Ie}),E&&e.jsx($r,{onClose:()=>G(!1),onSubmit:async i=>{await vs(i),await xe()},themeStyles:Q,communityId:n?._id}),At&&e.jsx(lr,{targetUnit:tt,activeUnits:P,communityId:n?._id,currentUserId:t?._id,onClose:()=>{et(!1),st(null)},onRefresh:()=>xe(!0)}),De&&e.jsx(ts,{reportId:De,onClose:()=>fe(null),themeStyles:Q}),e.jsxs("header",{style:Q.header,children:[e.jsxs("div",{style:Q.cadHeaderText,children:[e.jsx(Os,{style:{fontSize:"18px"}}),e.jsx("span",{children:"CDE CAD"}),e.jsx("span",{style:{opacity:.6},children:"|"}),e.jsx("span",{children:n?.name||"NO COMMUNITY"}),(()=>{const i=n?.cadSettings?.jurisdiction||{},d=[i.city,i.county,i.state].filter(Boolean);return d.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{opacity:.6},children:"|"}),e.jsx("span",{children:d.join(", ")})]}):null})(),e.jsx("span",{style:{opacity:.6},children:"|"}),e.jsxs("span",{children:["Unit: ",s]}),e.jsx("span",{style:{opacity:.6},children:"|"}),e.jsx("span",{children:ie||b})]}),e.jsx(qr,{user:t,themeStyles:Q,setShowCommunityModal:ce,onLogout:h,userRoles:Ie,activeCommunityId:n?._id,activeCommunity:n,soundVolume:mt,onVolumeChange:pt})]}),ve&&e.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(127, 29, 29, 0.85)",zIndex:99999,display:"flex",alignItems:"center",justifyContent:"center",backdropFilter:"blur(4px)"},children:e.jsxs("div",{style:{backgroundColor:"#1a1a2e",border:"4px solid #ef4444",borderRadius:"20px",padding:"50px 60px",textAlign:"center",width:"90%",maxWidth:"550px",boxShadow:"0 0 100px rgba(239, 68, 68, 0.6), 0 0 200px rgba(239, 68, 68, 0.3)",animation:"panicPulse 1.5s ease-in-out infinite"},children:[e.jsx("div",{style:{width:"80px",height:"80px",borderRadius:"50%",backgroundColor:"#7f1d1d",display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 20px",border:"3px solid #ef4444",animation:"panicFlash 0.5s ease-in-out infinite"},children:e.jsx(Ze,{style:{fontSize:"36px",color:"#ef4444"}})}),e.jsx("h2",{style:{color:"#ef4444",fontSize:"32px",fontWeight:"900",marginBottom:"6px",letterSpacing:"3px",textTransform:"uppercase",textShadow:"0 0 20px rgba(239, 68, 68, 0.5)"},children:"PANIC ACTIVATED"}),e.jsx("div",{style:{width:"60px",height:"3px",backgroundColor:"#ef4444",margin:"12px auto 20px",borderRadius:"2px"}}),e.jsx("p",{style:{color:"#ffffff",fontSize:"24px",fontWeight:"700",marginBottom:"8px",letterSpacing:"1px"},children:ve.officerName}),e.jsxs("p",{style:{color:"#d1d5db",fontSize:"16px",marginBottom:"20px",display:"flex",alignItems:"center",justifyContent:"center",gap:"6px"},children:[e.jsx(lt,{style:{color:"#ef4444"}}),ve.location||"Unknown Location",ve.postal&&e.jsxs("span",{style:{color:"#9ca3af",marginLeft:"8px"},children:["| Postal: ",ve.postal]})]}),e.jsx("div",{style:{padding:"8px 16px",backgroundColor:"#7f1d1d40",borderRadius:"8px",display:"inline-block",marginBottom:"28px"},children:e.jsxs("span",{style:{color:"#9ca3af",fontSize:"13px"},children:[new Date(ve.timestamp).toLocaleTimeString(),ve.source==="fivem"&&` | Server: ${ve.serverName||"FiveM"}`,ve.source==="mdt"&&" | MDT",ve.source==="dispatch"&&" | Dispatch"]})}),e.jsx("br",{}),e.jsx("button",{onClick:()=>$e(null),style:{padding:"14px 50px",backgroundColor:"#dc2626",color:"#fff",border:"2px s
1olid #ef4444",borderRadius:"10px",cursor:"pointer",fontSize:"16px",fontWeight:"800",letterSpacing:"2px",textTransform:"uppercase"},children:"ACKNOWLEDGE"})]})}),Ye.length>0&&(()=>{const i=Ye[0],d=i?.priority||"info",x=d==="urgent"?{bg:"#5c1a1a",border:"#dc2626",icon:"#f87171",label:"URGENT",badge:"#dc2626",badgeText:"#fff"}:d==="warning"?{bg:"#5c3a1a",border:"#f59e0b",icon:"#fbbf24",label:"WARNING",badge:"#f59e0b",badgeText:"#000"}:{bg:"#1e3a5f",border:"#2563eb",icon:"#60a5fa",label:"INFO",badge:"#3b82f6",badgeText:"#fff"};return e.jsxs("div",{style:{backgroundColor:x.bg,color:"#fff",padding:"8px 16px",display:"flex",alignItems:"center",gap:"10px",fontSize:"13px",borderBottom:`2px solid ${x.border}`},children:[e.jsx(Gt,{style:{color:x.icon,flexShrink:0}}),e.jsx("span",{style:{fontSize:"10px",fontWeight:"800",letterSpacing:"0.05em",padding:"2px 8px",borderRadius:"4px",backgroundColor:x.badge,color:x.badgeText,flexShrink:0},children:x.label}),e.jsxs("span",{style:{flex:1,opacity:.9},children:[i?.title," - ",i?.message?.substring(0,100),i?.message?.length>100?"...":""]}),Ye.length>1&&e.jsxs("span",{style:{color:x.icon,fontSize:"12px"},children:["+",Ye.length-1," more"]}),e.jsx("button",{onClick:()=>Me(D=>D.slice(1)),style:{background:"none",border:"none",color:"#9ca3af",cursor:"pointer",fontSize:"14px"},children:e.jsx(Qe,{})})]})})(),e.jsxs("div",{style:Q.mainArea,children:[e.jsx(Ur,{active:R,onSelect:Xe,themeStyles:Q,statusMap:k}),e.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[e.jsx("div",{className:"cad-menu-sidebar",style:Q.menuSidebar,children:!W&&e.jsx("div",{style:{padding:"10px 0"},children:[{id:"dashboard",label:"Dashboard",icon:e.jsx(Ps,{})},{id:"lookup",label:"Database Lookup",icon:e.jsx(be,{})},{id:"bolo",label:"BOLO Management",icon:e.jsx(Ze,{}),action:()=>g(!0)},{id:"reports",label:"Reports",icon:e.jsx(_s,{}),action:()=>w("/reports")},{id:"judicial",label:"Judicial System",icon:e.jsx(Fs,{}),action:()=>w("/judicial")},{id:"supervisor",label:"Supervisor Panel",icon:e.jsx(Ws,{}),action:()=>w("/supervisor")},{id:"messages",label:"Messages",icon:e.jsx(_t,{}),badge:le>0?le:null},{id:"traditional",label:"Traditional CAD",icon:e.jsx(Es,{}),action:()=>w("/dashboard2",{state:{direct:!0}})},{id:"panic",label:"PANIC",icon:e.jsx(Ze,{}),action:()=>{const i={officerName:Ss(t,n)||zr(t,n?.guildId)||t?.callSign||"Officer",location:"MDT",communityId:n?._id,timestamp:new Date,source:"mdt"};me?.connected&&me.emit("panic-button",{...i,communityId:n?._id})},style:{color:"#ef4444",backgroundColor:"#7f1d1d",border:"2px solid #ef4444",fontWeight:"700"}}].map(i=>e.jsxs("button",{onClick:i.action||(()=>A(i.id)),style:i.style?{...Q.menuButton,...i.style}:u===i.id?{...Q.menuButton,...Q.menuButtonActive}:Q.menuButton,children:[i.icon," ",e.jsx("span",{children:i.label}),i.badge&&e.jsx("span",{style:{marginLeft:"auto",padding:"1px 7px",backgroundColor:"#ef4444",color:"#fff",borderRadius:"10px",fontSize:"11px",fontWeight:"700",minWidth:"18px",textAlign:"center"},children:i.badge})]},i.id))})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,overflow:"hidden",position:"relative"},children:[e.jsx("button",{onClick:()=>M(!W),style:{position:"absolute",top:"10px",left:"10px",backgroundColor:"#0f1419",border:"1px solid #2d3748",color:"#e2e8f0",cursor:"pointer",fontSize:"20px",zIndex:10,padding:"10px",borderRadius:"6px",width:"48px",height:"48px",display:"flex",alignItems:"center",justifyContent:"center",WebkitTapHighlightColor:"transparent"},children:e.jsx($s,{})}),e.jsxs("div",{style:Q.content,children:[_&&e.jsxs("div",{style:{padding:"14px 16px",backgroundColor:_.includes("10-41")?"#052e16":"#7f1d1d",border:`1px solid ${_.includes("10-41")?"#16a34a":"#991b1b"}`,color:"#ffffff",marginBottom:"12px",fontSize:"16px",display:"flex",justifyContent:"space-between",alignItems:"center",borderRadius:"6px"},children:[e.jsx("span",{children:_}),e.jsx("button",{onClick:()=>c(""),style:{background:"none",border:"none",color:"#fff",cursor:"pointer",fontSize:"20px",padding:"8px",minWidth:"40px",minHeight:"40px"},children:"â"})]}),u==="dashboard"?e.jsxs(e.Fragment,{children:[e.jsx(Hr,{bolos:v,onManage:()=>g(!0),themeStyles:Q}),e.jsx(qt,{title:"CAD Units",data:de,headers:f?["Unit","Status","Details"]:["CAD Unit","Status","Details","Location","Attached Call"],dataKeys:f?["cad_unit","status","details"]:["cad_unit","status","details","location","activeCallId"],highlightKey:"cad_unit",highlightValue:t?.callSign||t?.username,themeStyles:Q,showRefresh:!0,onRefresh:()=>xe(!0),isRefreshing:p,userRoles:Ie,activeBolos:v,calls:j,statusMap:k,activePanic:ve,onUnitGroup:i=>{st(i),et(!0)},isMobile:f,stateLinkAlerts:ee}),e.jsx(qt,{title:"Clk-Status",data:Oe,headers:f?["Code","Type"]:["Incident Code","Call Type","Location"],dataKeys:f?["incident_number","call_type"]:["incident_number","call_type","location"],themeStyles:Q,showActions:!0,onDeleteCall:is,onViewCall:i=>Be(i),userRoles:Ie,priorityColors:Pe,selectedCallId:ke,onClearAll:xt,onCreate911:()=>G(!0),isMobile:f})]}):u==="lookup"?e.jsx(Yr,{themeStyles:Q,activeCommunityId:n?._id,unitIdentifier:t?.callSign||t?.username,communityName:n?.name,onViewReport:i=>fe(i),activeCallId:ke,onAttachToCall:()=>xe(),guildId:n?.guildId,externalSearchTrigger:ct,activeCommunity:n,onSearchItem:(i,d)=>{A("lookup"),yt({query:i,type:d,ts:Date.now()})}}):u==="messages"?e.jsx("div",{style:{height:"calc(100vh - 140px)",overflow:"hidden"},children:e.jsx(ar,{user:t,activeUnits:P,communityId:n?._id,guildId:n?.guildId,themeStyles:Q,onNotification:ot})}):e.jsx("div",{style:Q.tableWrapper,children:e.jsx("div",{style:{padding:"24px"},children:e.jsxs("h3",{style:{fontSize:"20px"},children:[u," view not implemented."]})})})]})]})]})]}),Ge&&e.jsx(ss,{call:Ge,liveCall:j.find(i=>String(i._id)===String(Ge._id)),onClose:()=>Be(null),themeStyles:Q,activeUnits:P,guildId:n?.guildId,onSearchItem:(i,d)=>{Be(null),A("lookup"),yt({query:i,type:d,ts:Date.now()})},onCompleteCall:i=>{nt(i),rt(!0)},activeCommunity:n}),Ee&&Ae&&e.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.7)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},children:e.jsxs("div",{style:{backgroundColor:"#1a1d23",border:"1px solid #2d3748",borderRadius:"12px",padding:"24px",width:"440px",maxWidth:"95vw"},children:[e.jsx("h3",{style:{margin:"0 0 16px",fontSize:"18px",color:"#fff"},children:"Close Call - Select Disposition"}),e.jsxs("p",{style:{color:"#9ca3af",fontSize:"13px",marginBottom:"16
1px"},children:["Incident #",Ae.incident_number||Ae.incidentNumber," - ",Ae.call_type||Ae.callType]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px",marginBottom:"20px"},children:(n?.cadSettings?.dispositionTypes?.length>0?n.cadSettings.dispositionTypes:["Report Taken","Citation Issued","Warning","Arrest","GOA/Unable to Locate","Cancelled","Unfounded","Other"]).map(i=>e.jsx("button",{onClick:async()=>{try{await Z.post(`/calls/${Ae._id}/close-with-disposition`,{disposition:i});try{await Z.patch(`/calls/${Ae._id}/units/${t._id}/status`,{status:"cleared"})}catch{}await O("10-8"),U(d=>d.map(x=>x.username===t?.username||x._id===t?._id?{...x,status:"10-8",activeCallId:null}:x)),me&&n?._id&&me.emit("status-update",{userId:t._id,username:t.username,status:"10-8",communityId:n._id}),rt(!1),nt(null),Be(null),F.success(`Call closed - ${i}`),setTimeout(()=>xe(),300)}catch(d){console.error("Error closing call with disposition:",d),F.error(je(d,"Failed to close call"))}},style:{padding:"10px 12px",borderRadius:"8px",border:"1px solid #374151",backgroundColor:"#111827",color:"#e5e7eb",cursor:"pointer",fontSize:"13px",fontWeight:"500",transition:"all 0.15s",textAlign:"center"},onMouseOver:d=>{d.target.style.backgroundColor="#1f2937",d.target.style.borderColor="#10b981"},onMouseOut:d=>{d.target.style.backgroundColor="#111827",d.target.style.borderColor="#374151"},children:i},i))}),e.jsx("button",{onClick:()=>{rt(!1),nt(null)},style:{width:"100%",padding:"10px",borderRadius:"8px",border:"1px solid #374151",backgroundColor:"transparent",color:"#9ca3af",cursor:"pointer",fontSize:"13px"},children:"Cancel"})]})}),e.jsxs("footer",{style:Q.footer,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"14px"},children:[e.jsxs("span",{children:["Calls: ",j.length]}),e.jsx("span",{children:"|"}),e.jsxs("span",{children:["Units: ",P.length]}),e.jsx("span",{children:"|"}),e.jsxs("span",{children:["BOLOs: ",v.length]})]}),e.jsxs("div",{style:{padding:"8px 20px",backgroundColor:qe.bgColor,color:qe.color,border:`2px solid ${qe.borderColor}`,borderRadius:"6px",fontWeight:"bold",fontSize:"16px",display:"flex",alignItems:"center",gap:"10px"},children:[e.jsx("span",{children:"STATUS:"}),e.jsx("span",{children:qe.code})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"14px"},children:[e.jsx("span",{children:I.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),e.jsx("span",{children:"|"}),e.jsx("span",{children:I.toLocaleDateString()})]})]}),e.jsx("style",{children:` 2 /* Sidebar fold lines - show on hover */ 3 .cad-status-sidebar:hover { 4 border-right-color: #2d3748 !important; 5 } 6 .cad-menu-sidebar:hover { 7 border-right-color: #2d3748 !important; 8 } 9 /* Touch-friendly scrollbars */ 10 ::-webkit-scrollbar {
11 width: 14px; 12 height: 14px; 13 } 14 15 ::-webkit-scrollbar-track { 16 background: #0f1419; 17 border: 1px solid #2d3748; 18 } 19 20 ::-webkit-scrollbar-thumb { 21 background: #2d3748; 22 border-radius: 8px; 23 } 24 25 ::-webkit-scrollbar-thumb:hover { 26 background: #4a5568; 27 } 28 29 /* Focus styles for accessibility */ 30 button:focus-visible, 31 input:focus-visible, 32 select:focus-visible, 33 textarea:focus-visible { 34 outline: 3px solid #3b82f6; 35 outline-offset: 2px; 36 } 37 38 /* Prevent text selection on buttons */ 39 button { 40 -webkit-user-select: none; 41 -moz-user-select: none; 42 -ms-user-select: none; 43 user-select: none; 44 } 45 46 /* Improve touch targets */ 47 button, input, select, textarea { 48 min-height: 48px; 49 } 50 51 /* Remove iOS input shadows */ 52 input, textarea, select { 53 -webkit-appearance: none; 54 -moz-appearance: none; 55 appearance: none; 56 } 57 58 /* Improve tap feedback */ 59 button:active { 60 transform: scale(0.98); 61 } 62 63 /* Better mobile typography */ 64 @media (max-width: 768px) { 65 body { 66 -webkit-text-size-adjust: 100%; 67 } 68 } 69 70 /* Spinner animation for loading */ 71 @keyframes spin { 72 from { transform: rotate(0deg); } 73 to { transform: rotate(360deg); } 74 } 75 76 .fa-spin { 77 animation: spin 1s linear infinite; 78 } 79 80 /* Pulse animation for BOLO alerts */ 81 @keyframes pulse { 82 0% { 83 box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); 84 } 85 70% { 86 box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); 87 } 88 100% { 89 box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); 90 } 91 } 92 93 @keyframes panicFlash { 94 0%, 100% { opacity: 1; } 95 50% { opacity: 0.6; } 96 } 97 98 @keyframes dp3StateLinkFlash { 99 0% { background-color: rgba(180,0,0,0.28); } 100 50% { background-color: rgba(255,213,79,0.32); } 101 100% { background-color: rgba(180,0,0,0.28); } 102 } 103 104 @keyframes panicPulse { 105 0%, 100% { box-shadow: 0 0 30px rgba(239, 68, 68, 0.3); } 106 50% { box-shadow: 0 0 80px rgba(239, 68, 68, 0.6); } 107 } 108 109 @keyframes panicRowPulse { 110 0%, 100% { background-color: rgba(220, 38, 38, 0.15); } 111 50% { background-color: rgba(220, 38, 38, 0.30); } 112 } 113 @keyframes msgSlideIn { 114 0% { opacity: 0; transform: translateY(-12px) scale(0.95); } 115 60% { transform: translateY(3px) scale(1.02); } 116 100% { opacity: 1; transform: translateY(0) scale(1); } 117 } 118 `}),K&&e.jsxs("div",{onClick:()=>{A("messages"),T(null)},style:{position:"fixed",top:"20px",right:"20px",zIndex:99999,backgroundColor:"#1e293b",border:"1px solid #3b82f6",borderRadius:"10px",padding:"14px 18px",maxWidth:"340px",cursor:"pointer",boxShadow:"0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(59,130,246,0.3)",animation:"msgSlideIn 0.35s ease-out"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},children:[e.jsx(_t,{style:{color:"#3b82f6",fontSize:"14px"}}),e.jsx("span",{style:{fontWeight:"700",fontSize:"13px",color:"#e2e8f0"},children:"New Message"}),e.jsx("button",{onClick:i=>{i.stopPropagation(),T(null)},style:{marginLeft:"auto",background:"none",border:"none",color:"#6b7280",cursor:"pointer",padding:"2px"},children:e.jsx(Qe,{style:{fontSize:"10px"}})})]}),e.jsxs("div",{style:{fontSize:"12px",color:"#fbbf24",fontWeight:"600",marginBottom:"2px"},children:[K.senderCallSign&&e.jsxs("span",{children:[K.senderCallSign," - "]}),K.senderName]}),e.jsx("div",{style:{fontSize:"12px",color:"#9ca3af",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:K.message})]})]}):null};export{Wn as default,Rr as fetchReportDetails,Ir as generateReportPDF,Fn as getReportsByCivilianNameBatched,Dt as requestManager};
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.