1import{r as s,j as e}from"./vendor-react-QE7wLE3r.js";import{a as Ce,bq as Le,aK as Re,cX as Pe,_ as Ae,aI as Te,aJ as Ee,b6 as Ke,o as v,x as $e,n as A,L as w,E as g,M as I,bQ as Y,z as U,F as W,cY as ze,Y as T,b as M,A as Be,B as Oe,U as De,I as Fe,W as _e,bJ as Ze,bS as Ve,h as He}from"./index-C5UqyXey.js";import{u as qe,a as Ge,c as X,M as Je,b as Qe}from"./map-pin-sheet-BZDG-MtY.js";import{A as Ye,M as Ue,a as We,u as Xe}from"./vendor-maps-D6fUS9jS.js";import{S as et}from"./scroll-area-CyKSVCk-.js";import{o as ee}from"./maps-href-4kFrBEBK.js";import{R as tt}from"./responsive-list-Bica1-oW.js";import{S as te,a as ae}from"./entity-links-JM_LkJQq.js";import{s as se,p as re,M as at}from"./modem-detail-sheet-y_s8mCve.js";import{u as st}from"./use-cleo-chart-colors-DKSr0MkN.js";import{m as ne}from"./vendor-motion-DpnOviVe.js";import{N as oe}from"./navigation-B69D39yy.js";import{E as ie}from"./eye-EEZr_Crl.js";import"./vendor-radix-C7HJG0re.js";import"./map-B1xpCfd1.js";import"./list-DN0N08Ke.js";import"./vendor-table-CjTNZf64.js";import"./status-badge-DTVMtRly.js";import"./use-coarse-pointer-By70CtKw.js";import"./tab-swipe-cMLS5UTJ.js";import"./ellipsis-vertical-CJkGqYee.js";import"./organization-badge-CGM-sIRr.js";import"./vendor-charts-DMPIdm6T.js";import"./formatDistanceToNowStrict-Elu22DD0.js";import"./wifi-DkbpPO7J.js";import"./wifi-off-Hgo_vkA0.js";import"./circle-help-CqtmkCpQ.js";function rt({points:d,leftPad:a}){const c=Xe(),h=s.useRef(!1);return s.useEffect(()=>{if(!c||h.current||d.length===0)return;if(h.current=!0,d.length===1){c.setCenter(d[0]),c.setZoom(12);return}const x=new google.maps.LatLngBounds;d.forEach(S=>x.extend(S)),c.fitBounds(x,{top:56,bottom:56,left:a,right:56})},[c,d,a]),null}function At(){const{language:d}=Ce(),a=(t,o)=>He(d,t,o);Le(a("modems.mapTitle"),a("modems.mapSubtitle"),!0,!0);const{user:c}=Re(),{theme:h}=Pe(),x=st(),{ctrlbxLabel:S}=Ae(),E=qe(),K=Te(),b=Ee(),[$,le]=Ge("modemsMap.viewMode"),[r,j]=s.useState(null),de=h==="dark"?"DARK":"LIGHT",ce=Ke(v.actions.config.getGoogleMapsApiKey),[N,me]=s.useState(),[xe,z]=s.useState(!0),[B,pe]=s.useState(null);s.useEffect(()=>{ce({}).then(t=>{me(t),z(!1)}).catch(t=>{pe($e(t)),z(!1)})},[]);const C=A(v.cradlepoint.queries.listModems),ue=C===void 0,i=s.useMemo(()=>(C??[]).filter(t=>typeof t.latitude=="number"&&typeof t.longitude=="number"),[C]),O=A(v.sites.queries.getSitesSummary),D=A(v.organizations.queries.list)??[],F=s.useMemo(()=>new Map((O??[]).map(t=>[String(t._id??t.id),t])),[O]),_=s.useMemo(()=>new Map(D.map(t=>[String(t._id),t])),[D]),Z=s.useCallback(t=>{const o=t.siteId?F.get(String(t.siteId)):void 0,n=o?.organizationId?_.get(String(o.organizationId)):void 0;return{siteName:t.siteName??o?.name,org:n}},[F,_]),[L,ge]=s.useState(""),[he,V]=s.useState(null),[be,R]=s.useState(null),[fe,ye]=s.useState(10),[je,Ne]=s.useState(null),[ke,H]=s.useState(!1),f=s.useRef(null),P=s.useRef(!1),y=s.useMemo(()=>{const t=L.trim().toLowerCase();return[...t?i.filter(n=>[n.name,n.serialNumber,n.ipv4Address,n.siteName,n.groupName].filter(Boolean).join(" ").toLowerCase().includes(t)):i].sort((n,m)=>(n.name??"").localeCompare(m.name??""))},[i,L]),ve=s.useMemo(()=>i.length===0?{lat:45.5017,lng:-73.5673}:{lat:i[0].latitude,lng:i[0].longitude},[i]),we=s.useMemo(()=>i.map(t=>({lat:t.latitude,lng:t.longitude})),[i]),p=t=>t.state==="online"?{color:x.good,label:a("modems.online")}:t.state==="offline"?{color:x.bad,label:a("modems.offline")}:{color:x.muted,label:a("modems.unknown")},q=s.useCallback(t=>{if(!f.current)return;P.current=!0,V(t.ncmRouterId);const o=f.current.getZoom()??10;f.current.panTo({lat:t.latitude,lng:t.longitude}),o<14&&setTimeout(()=>f.current?.setZoom(15),250),setTimeout(()=>{R(t.ncmRouterId),P.current=!1},500)},[]),G=t=>{Ne(t),H(!0)};if(!c)return e.jsxs("div",{className:"max-w-4xl mx-auto p-4 text-center py-20",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-4",children:a("accessDenied")}),e.jsx(w,{href:"/auth",children:e.jsx(g,{variant:"outline",children:a("goToLogin")})})]});const Ie=xe||ue,u=r?Z(r):null,Me=r?[{id:"signal",content:`${a("modems.colSignal")}: ${se(re(r)?.signal).label}`},u?.siteName&&r.siteId?{id:"site",content:e.jsxs(te,{siteId:String(r.siteId),className:X,testId:"map-pin-sheet-site-link",children:[e.jsx(I,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),u.siteName]})}:{id:"no-site",content:a("modems.noneLinkedTitle")},...u?.org?[{id:"org",content:e.jsxs(ae,{organizationId:String(u.org._id),className:X,testId:"map-pin-sheet-org-link",children:[e.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full",style:{backgroundColor:Y(u.org)},"aria-hidden":!0}),u.org.name]})}]:[]]:[];return e.jsxs("div",{className:"flex-1",children:[e.jsx(ne.div,{initial:{opacity:0,y:20}
1,animate:{opacity:1,y:0},transition:{delay:.1},className:"w-full",children:e.jsx(U,{className:M(b?"h-[calc(100dvh-var(--chrome-h-mobile)-var(--tabbar-h))] rounded-none border-x-0":"h-[calc(100vh-4rem)] rounded-none border-x-0","co-card"),children:e.jsxs(W,{className:"relative p-0 h-full",children:[b&&e.jsx("div",{className:"absolute inset-x-0 top-3 z-20 flex justify-center",children:e.jsx(Je,{mode:$,onChange:le,mapLabel:a("modems.mapViewMap"),listLabel:a("modems.mapViewList"),groupLabel:a("modems.mapViewToggleLabel")})}),Ie?e.jsx(ze,{className:"h-full w-full bg-muted/40",label:a("loadingMap")}):b&&$==="list"?i.length>0?e.jsx("div",{className:"h-full pt-16",children:e.jsx(tt,{items:y,getKey:t=>t.ncmRouterId,card:t=>{const o=p(t);return{title:t.name||`#${t.ncmRouterId}`,status:{label:o.label,tone:t.state==="online"?"success":t.state==="offline"?"danger":"neutral"},facts:[t.fullProductName||t.product||"â",t.siteName||a("modems.noneLinkedTitle")],onOpen:()=>j(t)}},desktop:null})}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center gap-4 px-6",children:[e.jsx(T,{className:"h-10 w-10 text-slate-400"}),e.jsx("p",{className:"text-gray-700 dark:text-gray-200 font-medium",children:a("modems.mapNoLocations")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:a("modems.mapNoLocationsHelp")})]}):N?.apiKey&&i.length>0?e.jsx("div",{className:"h-full relative customer-map-container",children:e.jsxs(Ye,{apiKey:N.apiKey,libraries:["marker"],version:"weekly",children:[e.jsxs(Ue,{mapId:"803a2824f67a3d93f9141680",colorScheme:de,style:{width:"100%",height:"100%"},defaultCenter:ve,defaultZoom:6,gestureHandling:"greedy",clickableIcons:!1,onClick:t=>{t.domEvent&&!P.current&&R(null)},onZoomChanged:t=>{t?.map&&ye(t.map.getZoom())},onCameraChanged:t=>{t?.map&&(f.current=t.map)},children:[e.jsx(rt,{points:we,leftPad:K?24:360}),y.map((t,o)=>{const n=p(t),m=be===t.ncmRouterId,J=re(t),{siteName:Q,org:k}=Z(t);return e.jsx(We,{position:{lat:t.latitude,lng:t.longitude},title:t.name||`#${t.ncmRouterId}`,zIndex:m?1e3:1,onClick:l=>{l.domEvent?.stopPropagation()},children:e.jsxs("div",{className:`customer-marker${m?" highlight":""} marker-animation-wrapper visible drop pointer-events-auto flex flex-col items-center gap-1`,"data-marker-id":t.ncmRouterId,style:{"--marker-delay-time":`${Math.min(o*.03,.5)}s`},onClick:l=>{l.stopPropagation(),b?j(t):(R(Se=>Se===t.ncmRouterId?null:t.ncmRouterId),V(t.ncmRouterId))},children:[e.jsx("div",{className:`marker-pin ${m?"expanded":""}`,style:{boxShadow:`0 0 0 2px ${n.color}, 0 1px 3px rgba(0,0,0,0.2)`,borderRadius:"50%"},children:E?e.jsx("img",{src:E,alt:"","aria-hidden":!0,className:"w-5 h-5 object-contain"}):null}),fe>=12&&!m&&e.jsx("div",{className:M("marker-label px-1.5 py-0.5 rounded text-[11px] font-medium whitespace-nowrap shadow-sm max-w-[130px] overflow-hidden text-ellipsis pointer-events-none",h==="dark"?"bg-gray-800/95 text-gray-200 border border-gray-600/50":"bg-white/95 text-gray-800 border border-gray-300/80"),children:t.name||`#${t.ncmRouterId}`}),!b&&m&&e.jsx("div",{className:"marker-popup w-auto max-w-[340px] min-w-[300px] h-auto max-h-[500px] overflow-visible",children:e.jsxs(ne.div,{initial:{opacity:0,scale:.95,y:-8},animate:{opacity:1,scale:1,y:0},transition:{duration:.2,ease:[.25,.1,.25,1]},className:"rounded-xl overflow-hidden border-2 border-brand-200 dark:border-brand-800",style:{boxShadow:"0 20px 40px rgba(0,0,0,0.15), 0 0 0 1px rgba(59,130,246,0.1)"},children:[e.jsxs("div",{className:"bg-gray-800 dark:bg-gray-900 px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full shrink-0",style:{backgroundColor:n.color}}),e.jsx(w,{href:"/modems",onClick:l=>l.stopPropagation(),className:"text-[15px] font-semibold text-white hover:text-brand-300 transition-colors truncate","data-testid":`popup-modem-link-${t.ncmRouterId}`,children:t.name||`#${t.ncmRouterId}`})]}),e.jsx("div",{className:"text-[11.5px] text-gray-400 mt-0.5",children:t.fullProductName||t.product||""})]}),e.jsxs("div",{className:"bg-white/80 dark:bg-gray-800/80 backdrop-blur-md",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-px bg-gray-200/30 dark:bg-gray-700/20 border-b border-gray-200/50 dark:border-gray-700/30",children:[e.jsxs("div",{className:"bg-white/20 dark:bg-gray-800/20 backdrop-blur-sm px-3 py-2.5",children:[e.jsx("div",{className:"text-[10px] text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:a("status")}),e.jsx("div",{className:"text-base font-bold",style:{color:n.color},children:n.label})]}),e.jsxs("div",{className:"bg-white/20 dark:bg-gray-800/20 backdrop-blur-sm px-3 py-2.5",children:[e.jsx("div",{className:"text-[10px] text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:a("modems.colSignal")}),e.jsx("div",{className:"text-base font-bold text-gray-900 dark:text-white",children:se(J?.signal).label}),e.jsx("div",{className:"text-[10px] text-gray-500 dark:text-gray-400 truncate",children:J?.carrier||""})]}),e.jsxs("div",{className:"bg-white/20 dark:bg-gray-800/20 backdrop-blur-sm px-3 py-2.5",children:[e.jsx("div",{className:"text-[10px] text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:a("modems.colIp")}),e.jsx("div",{className:"text-sm font-semibold font-mono text-gray-900 dark:text-white truncate",children:t.ipv4Address||"â"})]}),e.jsxs("div",{className:"bg-white/20 dark:bg-gray-800/20 backdrop-blur-sm px-3 py-2.5",children:[e.jsx("div",{className:"text-[10px] text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:a("modems.colFirmware")}),e.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-white truncate",children:t.actualFirmware||"â"})]})]}),e.jsx("div",{className:"px-4 py-2.5 space-y-1.5",children:Q&&t.siteId?e.jsxs(e.Fragment,{children:[e.jsxs(w,{href:`/sites/${t.siteId}`,onClick:l=>l.stopPropagation(),className:"flex items-center gap-2 text-[12.5px] font-medium text-brand-600 dark:text-brand-300 hover:underline",children:[e.jsx(I,{className:"w-3.5 h-3.5"}),Q]}),k&&e.jsxs("div",{className:"flex items-center gap-2 text-[11.5px] text-gray-500 dark:text-gray-400 pl-[22px]",children:[e.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:Y(k)}}),e.jsx(ae,{organizationId:String(k._id),hitArea:"below",children:k.name})]})]}):e.jsx("div",{className:"text-[12px] text-gray-500 dark:text-gray-400 italic",children:a("modems.noneLinkedTitle")})}),e.jsxs("div",{className:"flex gap-2 px-3 py-3 border-t border-gray-200/50 dark:border-gray-700/30",children:[e.jsxs(g,{variant:"outline",size:"sm",className:"flex-1 min-w-0 justify-center text-[11px] h-8 px-2",onClick:l=>{l.stopPropagation(),ee({lat:t.latitude,lng:t.longitude},{directions:!0})},children:[e.jsx(oe,{className:"w-3 h-3 mr-1 shrink-0"}),e.jsx("span",{className:"truncate",children:a("modems.directions")})]}),e.jsxs(g,{size:"sm",className:"flex-1 min-w-0 justify-center text-[11px] h-8 px-2",onClick:l=>{l.stopPropagation(),G(t)},children:[e.jsx(ie,{className:"w-3 h-3 mr-1 shrink-0"}),e.jsx("span",{className:"truncate",children:a("modems.details")})]})]})]})]})})]})},t.ncmRouterId)})]}),!K&&e.jsxs(U,{className:M("absolute top-4 left-4 w-80 max-h-[calc(100vh-120px)] z-10","co-card"),
1children:[e.jsxs(Be,{className:"p-4 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(T,{className:"w-5 h-5 text-brand-600 dark:text-brand-300"}),e.jsxs(Oe,{className:"text-base font-semibold",children:[a("modems.mapListTitle")," (",y.length,")"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(De,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 w-4 h-4"}),e.jsx(Fe,{type:"text",placeholder:a("modems.searchPlaceholder"),value:L,onChange:t=>ge(t.target.value),className:"pl-9 h-9 text-sm bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700"})]})]}),e.jsx(W,{className:"p-2",children:e.jsx(et,{className:"h-[calc(100vh-240px)]",children:e.jsx("div",{className:"space-y-1",children:y.length===0?e.jsx(_e,{icon:I,title:a("modems.noMatchesTitle"),className:"py-8"}):y.map(t=>{const o=p(t);return e.jsx("div",{role:"button",tabIndex:0,onClick:()=>q(t),onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),q(t))},className:M("w-full text-left p-3 rounded-lg cursor-pointer transition-all duration-200 hover:bg-brand-50 dark:hover:bg-brand-900/20 group",he===t.ncmRouterId?"bg-brand-100 dark:bg-brand-900/30 border-l-4 border-brand-600 dark:border-brand-300":"hover:border-l-4 hover:border-brand-400"),children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 rounded-full shrink-0",style:{backgroundColor:o.color}}),e.jsx("div",{className:"font-medium text-sm text-gray-900 dark:text-white truncate",children:t.name||`#${t.ncmRouterId}`})]}),e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 truncate mt-0.5",children:t.fullProductName||t.product||"â"}),t.siteName&&e.jsxs("div",{className:"text-xs text-brand-600 dark:text-brand-300 truncate mt-0.5 inline-flex items-center gap-1",children:[e.jsx(I,{className:"w-3 h-3"}),e.jsx(te,{siteId:t.siteId?String(t.siteId):null,children:t.siteName})]})]}),e.jsx(Ze,{className:"w-4 h-4 text-gray-400 group-hover:text-brand-600 dark:group-hover:text-brand-300 transition-colors shrink-0"})]})},t.ncmRouterId)})})})})]})]})}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center gap-4 px-6",children:[e.jsx(T,{className:"h-10 w-10 text-slate-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-700 dark:text-gray-200 font-medium",children:N?.apiKey?a("modems.mapNoLocations"):a("mapLoadFailed")}),N?.apiKey&&e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:a("modems.mapNoLocationsHelp")}),B&&e.jsx("p",{className:"text-sm text-red-600 dark:text-red-400 font-medium mt-2",children:B})]}),e.jsx(w,{href:"/modems",children:e.jsxs(g,{variant:"outline",children:[e.jsx(Ve,{className:"w-4 h-4 mr-2"}),a("modems.titleBranded",{ctrlbxLabel:S})]})})]})]})})}),e.jsx(Qe,{open:!!r,onOpenChange:t=>{t||j(null)},title:r?.name||(r?`#${r.ncmRouterId}`:""),description:r?.fullProductName||r?.product||void 0,status:r?e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs font-medium",style:{color:p(r).color},children:[e.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:p(r).color},"aria-hidden":!0}),p(r).label]}):void 0,facts:Me,actions:r&&e.jsxs(e.Fragment,{children:[e.jsxs(g,{variant:"outline",className:"flex-1",onClick:()=>ee({lat:r.latitude,lng:r.longitude},{directions:!0}),children:[e.jsx(oe,{className:"mr-1.5 h-4 w-4"}),a("modems.directions")]}),e.jsxs(g,{className:"flex-1",onClick:()=>{const t=r;j(null),G(t)},children:[e.jsx(ie,{className:"mr-1.5 h-4 w-4"}),a("modems.details")]})]})}),e.jsx(at,{modem:je,open:ke,onOpenChange:H,onReboot:()=>{}})]})}export{At as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.