import{r as x,c as Q,s as J,o as K,m as X,i as Y,w as l,l as Z,v as tt,f as et,g as i,b as t,a as r,j as v,d,e as c,k as u,t as a,af as h,aR as k,F as y,b9 as st}from"./index-QAlcqU00.js";import{a as ot}from"./locations-ElrWcwNd.js";import{F as nt,a as at}from"./FPPageHeader-CFIwZZgQ.js";import{F as g}from"./FPBadge-DvOitM1C.js";const it={class:"px-6 py-8"},rt={key:0,class:"flex items-center justify-center py-12"},lt={key:1,class:"space-y-6"},dt={class:"bg-white shadow rounded-lg p-6"},ut={class:"flex items-start space-x-4"},ct={class:"flex items-center space-x-4 mb-2"},vt={class:"text-sm text-gray-500"},mt={class:"text-gray-600"},gt={class:"grid grid-cols-1 lg:grid-cols-3 gap-6"},pt={class:"lg:col-span-2 space-y-6"},xt={class:"bg-white shadow rounded-lg p-6"},yt={class:"grid grid-cols-1 md:grid-cols-2 gap-6"},ft={class:"mt-1 text-sm text-gray-900"},ht={class:"mt-1"},kt={key:0},wt={class:"mt-1 text-sm text-gray-900"},_t={key:1},bt={class:"mt-1 text-sm text-gray-900"},Ct={key:0,class:"bg-white shadow rounded-lg p-6"},Lt={key:0,class:"mb-4"},Mt={class:"flex items-center space-x-2"},jt={class:"font-medium"},Bt={key:1},At={class:"space-y-2"},Ht={class:"flex items-center space-x-3"},zt={key:0,class:"text-sm text-gray-500"},Vt={class:"bg-white shadow rounded-lg p-6"},Ft={class:"flex items-center justify-between mb-4"},Nt={key:0,class:"text-center py-8 text-gray-500"},St={key:1,class:"space-y-3"},$t=["onClick"],Wt={class:"flex items-center space-x-3"},Pt={class:"font-medium text-gray-900"},Dt={class:"text-sm text-gray-500"},It={class:"flex items-center space-x-3"},Ut={class:"bg-white shadow rounded-lg p-6"},Ot={class:"flex items-center justify-between mb-4"},Rt={key:0,class:"text-center py-8 text-gray-500"},Tt={key:1,class:"space-y-3"},Gt=["onClick"],Et={class:"flex items-center space-x-3"},qt={class:"font-medium text-gray-900"},Qt={class:"text-sm text-gray-500"},Jt={class:"flex items-center space-x-3"},Kt={class:"space-y-6"},Xt={class:"bg-white shadow rounded-lg p-6"},Yt={class:"space-y-4"},Zt={class:"flex items-center justify-between"},te={class:"font-medium"},ee={class:"flex items-center justify-between"},se={class:"font-medium"},oe={class:"flex items-center justify-between"},ne={class:"font-medium"},ae={key:0,class:"flex items-center justify-between"},ie={class:"font-medium"},re={key:0,class:"bg-white shadow rounded-lg p-6"},le={class:"space-y-2"},de={class:"text-sm font-medium"},ue={key:1,class:"bg-white shadow rounded-lg p-6"},ce={class:"mt-2 text-xs text-gray-500"},ve={key:2,class:"text-center py-12"},fe={__name:"LocationDetailView",setup(me){const F=J(),f=tt(),M=ot(),{showNotification:N}=Z(),s=x(null),w=x(!1),_=x(null),p=x([]),b=x([]),C=x([]),m=Q(()=>F.params.id),j=async()=>{if(m.value){w.value=!0,_.value=null;try{s.value=await M.getLocationById(m.value);try{p.value=await M.getChildLocations(m.value)}catch{p.value=[]}}catch(o){_.value=o,N("error","Failed to load location details")}finally{w.value=!1}}},S=()=>{f.push(`/locations?edit=${m.value}`)},B=()=>{f.push(`/assets?create=true&locationId=${m.value}`)},A=()=>{f.push(`/work-orders?create=true&locationId=${m.value}`)},$=o=>{f.push(`/assets/${o.id}`)},W=o=>{f.push(`/work-orders/${o.id}`)},P=o=>({active:"green",inactive:"red",construction:"yellow",maintenance:"orange"})[o]||"gray",L=o=>({building:"blue",floor:"green",room:"yellow",area:"purple",zone:"pink",equipment_space:"orange"})[o]||"gray",D=o=>({active:"Active",inactive:"Inactive",construction:"Under Construction",maintenance:"Maintenance"})[o]||"Unknown",I=o=>({operational:"green",maintenance:"yellow",retired:"red",down:"red"})[o]||"gray",U=o=>({operational:"Operational",maintenance:"Maintenance",retired:"Retired",down:"Down"})[o]||"Unknown",O=o=>({open:"blue",in_progress:"yellow",on_hold:"orange",complete:"green"})[o]||"gray",R=o=>({open:"Open",in_progress:"In Progress",on_hold:"On Hold",complete:"Complete"})[o]||"Unknown",T=o=>({none:"gray",low:"green",medium:"yellow",high:"red"})[o]||"gray",G=o=>({none:"None",low:"Low",medium:"Medium",high:"High"})[o]||"Unknown",E=o=>o?new Date(o).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"N/A";return K(()=>{j()}),X(m,()=>{j()}),(o,e)=>{const H=et("router-link");return i(),Y(nt,null,{header:l(()=>[d(at,{title:s.value?s.value.name:"Location Details",description:s.value?s.value.description||"Location information and details":"Loading location details...",breadcrumbs:[{text:"Locations",to:"/locations"},{text:s.value?s.value.name:"Loading...",to:null}]},st({_:2},[s.value?{name:"actions",fn:l(()=>[d(c(y),{variant:"secondary",size:"sm",onClick:S},{default:l(()=>e[1]||(e[1]=[t("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})],-1),u(" Edit Location ",-1)])),_:1,__:[1]}),d(c(y),{variant:"primary",size:"sm",onClick:B},{default:l(()=>e[2]||(e[2]=[t("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})],-1),u(" Add Asset ",-1)])),_:1,__:[2]}),d(c(y),{variant:"primary",size:"sm",onClick:A},{default:l(()=>e[3]||(e[3]=[t("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})],-1),u(" Create Work Order ",-1)])),_:1,__:[3]})]),key:"0"}:void 0]),1032,["title","description","breadcrumbs"])]),default:l(()=>{var z,V;return[t("div",it,[w.value?(i(),r("div",rt,e[4]||(e[4]=[t("div",{class:"flex items-center space-x-2 text-gray-500"},[t("svg",{class:"w-8 h-8 animate-spin",fill:"none",viewBox:"0 0 24 24"},[t("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),t("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]),t("span",null,"Loading location details...")],-1)]))):s.value?(i(),r("div",lt,[t("div",dt,[t("div",ut,[e[5]||(e[5]=t("div",{class:"w-16 h-16 bg-green-100 rounded-lg flex items-center justify-center"},[t("svg",{class:"w-8 h-8 text-green-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})])],-1)),t("div",null,[t("div",ct,[d(c(g),{variant:P(s.value.status)},{default:l(()=>[u(a(D(s.value.status)),1)]),_:1},8,["variant"]),d(c(g),{variant:L(s.value.type)},{default:l(()=>[u(a(s.value.type||"General"),1)]),_:1},8,["variant"]),t("span",vt,"Location #"+a(s.value.id),1)]),t("p",mt,a(s.value.description||"No description available"),1)])])]),t("div",gt,[t("div",pt,[t("div",xt,[e[10]||(e[10]=t("h3",{class:"text-lg font-medium text-gray-900 mb-4"},"Basic Information",-1)),t("div",yt,[t("div",null,[e[6]||(e[6]=t("dt",{class:"text-sm font-medium text-gray-500"},"Name",-1)),t("dd",ft,a(s.value.name),1)]),t("div",null,[e[7]||(e[7]=t("dt",{class:"text-sm font-medium text-gray-500"},"Type",-1)),t("dd",ht,[d(c(g),{variant:L(s.value.type)},{default:l(()=>[u(a(s.value.type||"General"),1)]),_:1},8,["variant"])])]),s.value.address?(i(),r("div",kt,[e[8]||(e[8]=t("dt",{class:"text-sm font-medium text-gray-500"},"Address",-1)),t("dd",wt,a(s.value.address),1)])):v("",!0),s.value.latitude&&s.value.longitude?(i(),r("div",_t,[e[9]||(e[9]=t("dt",{class:"text-sm font-medium text-gray-500"},"Coordinates",-1)),t("dd",bt,a(s.value.latitude.toFixed(6))+", "+a(s.value.longitude.toFixed(6)),1)])):v("",!0)])]),s.value.parentLocation||p.value.length>0?(i(),r("div",Ct,[e[15]||(e[15]=t("h3",{class:"text-lg font-medium text-gray-900 mb-4"},"Location Hierarchy",-1)),s.value.parentLocation?(i(),r("div",Lt,[e[12]||(e[12]=t("dt",{class:"text-sm font-medium text-gray-500 mb-2"},"Parent Location",-1)),t("div",Mt,[d(H,{to:`/locations/${s.value.parentLocation.id}`,class:"text-blue-600 hover:text-blue-800 font-medium"},{default:l(()=>[u(a(s.value.parentLocation.name),1)]),_:1},8,["to"]),e[11]||(e[11]=t("span",{class:"text-gray-400"},"→",-1)),t("span",jt,a(s.value.name),1)])])):v("",!0),p.value.length>0?(i(),r("div",Bt,[e[14]||(e[14]=t("dt",{class:"text-sm font-medium text-gray-500 mb-2"},"Child Locations",-1)),t("div",At,[(i(!0),r(h,null,k(p.value,n=>(i(),r("div",{key:n.id,class:"flex items-center justify-between p-3 bg-gray-50 rounded-lg"},[t("div",Ht,[e[13]||(e[13]=t("svg",{class:"w-5 h-5 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"})],-1)),t("div",null,[d(H,{to:`/locations/${n.id}`,class:"font-medium text-gray-900 hover:text-blue-600"},{default:l(()=>[u(a(n.name),1)]),_:2},1032,["to"]),n.description?(i(),r("p",zt,a(n.description),1)):v("",!0)])]),d(c(g),{variant:L(n.type)},{default:l(()=>[u(a(n.type||"General"),1)]),_:2},1032,["variant"])]))),128))])])):v("",!0)])):v("",!0),t("div",Vt,[t("div",Ft,[e[17]||(e[17]=t("h3",{class:"text-lg font-medium text-gray-900"},"Associated Assets",-1)),d(c(y),{variant:"outline",size:"sm",onClick:B},{default:l(()=>e[16]||(e[16]=[t("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),u(" Add Asset ",-1)])),_:1,__:[16]})]),b.value.length===0?(i(),r("div",Nt,e[18]||(e[18]=[t("svg",{class:"w-12 h-12 mx-auto mb-4 text-gray-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2 2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-2.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 009.586 13H7"})],-1),t("p",null,"No assets found for this location",-1)]))):(i(),r("div",St,[(i(!0),r(h,null,k(b.value,n=>(i(),r("div",{key:n.id,class:"flex items-center justify-between p-3 bg-gray-50 rounded-lg hover:bg-gray-100 cursor-pointer",onClick:q=>$(n)},[t("div",Wt,[e[19]||(e[19]=t("div",{class:"w-8 h-8 bg-blue-100 rounded-lg flex items-center justify-center"},[t("svg",{class:"w-4 h-4 text-blue-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2 2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-2.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 009.586 13H7"})])],-1)),t("div",null,[t("h4",Pt,a(n.name),1),t("p",Dt,a(n.description||n.assetNumber),1)])]),t("div",It,[d(c(g),{variant:I(n.status)},{default:l(()=>[u(a(U(n.status)),1)]),_:2},1032,["variant"])])],8,$t))),128))]))]),t("div",Ut,[t("div",Ot,[e[21]||(e[21]=t("h3",{class:"text-lg font-medium text-gray-900"},"Recent Work Orders",-1)),d(c(y),{variant:"outline",size:"sm",onClick:A},{default:l(()=>e[20]||(e[20]=[t("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),u(" Create Work Order ",-1)])),_:1,__:[20]})]),C.value.length===0?(i(),r("div",Rt,e[22]||(e[22]=[t("svg",{class:"w-12 h-12 mx-auto mb-4 text-gray-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})],-1),t("p",null,"No work orders found for this location",-1)]))):(i(),r("div",Tt,[(i(!0),r(h,null,k(C.value,n=>(i(),r("div",{key:n.id,class:"flex items-center justify-between p-3 bg-gray-50 rounded-lg hover:bg-gray-100 cursor-pointer",onClick:q=>W(n)},[t("div",Et,[e[23]||(e[23]=t("div",{class:"w-8 h-8 bg-orange-100 rounded-lg flex items-center justify-center"},[t("svg",{class:"w-4 h-4 text-orange-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})])],-1)),t("div",null,[t("h4",qt,a(n.title),1),t("p",Qt,a(E(n.createdAt)),1)])]),t("div",Jt,[d(c(g),{variant:O(n.status)},{default:l(()=>[u(a(R(n.status)),1)]),_:2},1032,["variant"]),d(c(g),{variant:T(n.priority)},{default:l(()=>[u(a(G(n.priority)),1)]),_:2},1032,["variant"])])],8,Gt))),128))]))])]),t("div",Kt,[t("div",Xt,[e[28]||(e[28]=t("h3",{class:"text-lg font-medium text-gray-900 mb-4"},"Quick Stats",-1)),t("div",Yt,[t("div",Zt,[e[24]||(e[24]=t("span",{class:"text-sm text-gray-600"},"Assets",-1)),t("span",te,a(b.value.length),1)]),t("div",ee,[e[25]||(e[25]=t("span",{class:"text-sm text-gray-600"},"Work Orders",-1)),t("span",se,a(C.value.length),1)]),t("div",oe,[e[26]||(e[26]=t("span",{class:"text-sm text-gray-600"},"Child Locations",-1)),t("span",ne,a(p.value.length),1)]),((z=s.value.workers)==null?void 0:z.length)>0?(i(),r("div",ae,[e[27]||(e[27]=t("span",{class:"text-sm text-gray-600"},"Assigned Workers",-1)),t("span",ie,a(s.value.workers.length),1)])):v("",!0)])]),((V=s.value.teams)==null?void 0:V.length)>0?(i(),r("div",re,[e[30]||(e[30]=t("h3",{class:"text-lg font-medium text-gray-900 mb-4"},"Assigned Teams",-1)),t("div",le,[(i(!0),r(h,null,k(s.value.teams,n=>(i(),r("div",{key:n.id,class:"flex items-center space-x-2 p-2 bg-gray-50 rounded"},[e[29]||(e[29]=t("svg",{class:"w-5 h-5 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"})],-1)),t("span",de,a(n.name),1)]))),128))])])):v("",!0),s.value.latitude&&s.value.longitude?(i(),r("div",ue,[e[31]||(e[31]=t("h3",{class:"text-lg font-medium text-gray-900 mb-4"},"Location Map",-1)),e[32]||(e[32]=t("div",{class:"bg-gray-100 rounded-lg h-32 flex items-center justify-center"},[t("span",{class:"text-gray-500 text-sm"},"Map integration coming soon")],-1)),t("div",ce," Coordinates: "+a(s.value.latitude.toFixed(6))+", "+a(s.value.longitude.toFixed(6)),1)])):v("",!0)])])])):_.value?(i(),r("div",ve,[e[34]||(e[34]=t("svg",{class:"w-16 h-16 mx-auto mb-4 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.728-.833-2.498 0L4.316 16.5c-.77.833.192 2.5 1.732 2.5z"})],-1)),e[35]||(e[35]=t("h3",{class:"text-lg font-medium text-gray-900 mb-2"},"Location not found",-1)),e[36]||(e[36]=t("p",{class:"text-gray-500 mb-4"},"The location you're looking for doesn't exist or has been removed.",-1)),d(c(y),{variant:"primary",onClick:e[0]||(e[0]=n=>o.$router.push("/locations"))},{default:l(()=>e[33]||(e[33]=[u(" Back to Locations ",-1)])),_:1,__:[33]})])):v("",!0)])]}),_:1})}}};export{fe as default};