import{aP as O,r as d,c as v}from"./index-QAlcqU00.js";const u={OPERATIONAL:"OPERATIONAL",MAINTENANCE:"MAINTENANCE",DOWN:"DOWN",DECOMMISSIONED:"DECOMMISSIONED"},c={LOW:"LOW",MEDIUM:"MEDIUM",HIGH:"HIGH",CRITICAL:"CRITICAL"},l={HVAC:"HVAC",ELEVATOR:"ELEVATOR",SECURITY:"SECURITY",ELECTRICAL:"ELECTRICAL",PLUMBING:"PLUMBING",MECHANICAL:"MECHANICAL",STRUCTURAL:"STRUCTURAL",IT_EQUIPMENT:"IT_EQUIPMENT",SAFETY:"SAFETY",OTHER:"OTHER"},S={ACTIVE:"ACTIVE",EXPIRED:"EXPIRED",EXPIRING_SOON:"EXPIRING_SOON",NOT_APPLICABLE:"NOT_APPLICABLE"},b={OPERATIONAL:"OPERATIONAL"},D={id:null,name:"",description:"",assetNumber:"",barcode:"",category:l.OTHER,subcategory:"",assetType:"",model:"",manufacturer:"",serialNumber:"",modelYear:null,status:u.OPERATIONAL,criticality:c.MEDIUM,condition:"",lifecycle:b.OPERATIONAL,location:null,parentAsset:null,children:[],depth:0,path:"",purchasePrice:0,currentValue:0,depreciationRate:0,residualValue:0,purchaseDate:null,installationDate:null,commissionDate:null,lastMaintenanceDate:null,nextMaintenanceDate:null,warranty:{isWarrantyActive:!1,warrantyStartDate:null,warrantyEndDate:null,warrantyProvider:"",warrantyType:"",warrantyTerms:"",status:S.NOT_APPLICABLE},vendor:{id:null,name:"",contactInfo:"",serviceContract:!1,contractExpiry:null},specifications:{powerRating:"",voltage:"",dimensions:"",weight:"",capacity:"",efficiency:"",operatingTemperature:"",customSpecs:{}},customFields:[],metrics:{totalDowntime:0,mtbf:0,mttr:0,availability:100,reliability:100,operatingHours:0},maintenance:{maintenanceSchedule:null,lastPM:null,nextPM:null,maintenanceStrategy:"",criticality:c.MEDIUM},documents:[],images:[],manuals:[],drawings:[],compliance:{regulatoryRequirements:[],inspectionSchedule:null,lastInspection:null,nextInspection:null,certifications:[]},createdAt:null,updatedAt:null,createdBy:null,updatedBy:null,workOrders:[],parts:[],meters:[],isParent:!1,hasChildren:!1,isActive:!0,isCritical:!1},X={name:{required:!0,minLength:2,maxLength:255},assetNumber:{unique:!0,maxLength:50},description:{maxLength:2e3},category:{required:!0,enum:Object.values(l)},status:{required:!0,enum:Object.values(u)},criticality:{required:!0,enum:Object.values(c)},purchasePrice:{min:0,max:99999999999e-2},serialNumber:{maxLength:100}},j={[u.OPERATIONAL]:{label:"Operational",color:"green",badge:"success",icon:"CheckCircleIcon"},[u.MAINTENANCE]:{label:"Under Maintenance",color:"yellow",badge:"warning",icon:"WrenchIcon"},[u.DOWN]:{label:"Out of Service",color:"red",badge:"error",icon:"XCircleIcon"},[u.DECOMMISSIONED]:{label:"Decommissioned",color:"gray",badge:"secondary",icon:"ArchiveIcon"}},Q={[c.LOW]:{label:"Low",color:"blue",badge:"info",priority:1},[c.MEDIUM]:{label:"Medium",color:"yellow",badge:"warning",priority:2},[c.HIGH]:{label:"High",color:"orange",badge:"warning",priority:3},[c.CRITICAL]:{label:"Critical",color:"red",badge:"error",priority:4}},z={[l.HVAC]:{label:"HVAC",icon:"WindIcon",color:"blue"},[l.ELEVATOR]:{label:"Elevator",icon:"ArrowUpIcon",color:"green"},[l.SECURITY]:{label:"Security",icon:"ShieldCheckIcon",color:"red"},[l.ELECTRICAL]:{label:"Electrical",icon:"BoltIcon",color:"yellow"},[l.PLUMBING]:{label:"Plumbing",icon:"WrenchIcon",color:"blue"},[l.MECHANICAL]:{label:"Mechanical",icon:"CogIcon",color:"gray"},[l.STRUCTURAL]:{label:"Structural",icon:"BuildingIcon",color:"brown"},[l.IT_EQUIPMENT]:{label:"IT Equipment",icon:"ComputerDesktopIcon",color:"purple"},[l.SAFETY]:{label:"Safety",icon:"ExclamationTriangleIcon",color:"orange"},[l.OTHER]:{label:"Other",icon:"CubeIcon",color:"gray"}},J=O("assets",()=>{const i=d([]),y=d(null),n=d(!1),r=d(null),I=d(0),p=d([]),f=d([]),E=d([]),T=d([]),o=d({locationId:null,categoryId:null,status:null,search:""}),h=v(()=>{let t=i.value;if(o.value.locationId&&(t=t.filter(e=>e.locationId===o.value.locationId)),o.value.categoryId&&(t=t.filter(e=>e.categoryId===o.value.categoryId)),o.value.status&&(t=t.filter(e=>e.status===o.value.status)),o.value.search){const e=o.value.search.toLowerCase();t=t.filter(a=>{var s,A,m,C;return((s=a.name)==null?void 0:s.toLowerCase().includes(e))||((A=a.description)==null?void 0:A.toLowerCase().includes(e))||((m=a.model)==null?void 0:m.toLowerCase().includes(e))||((C=a.serialNumber)==null?void 0:C.toLowerCase().includes(e))})}return t}),w=v(()=>i.value.reduce((t,e)=>(t[e.status]||(t[e.status]=[]),t[e.status].push(e),t),{})),R=v(()=>i.value.reduce((t,e)=>{var s;const a=((s=e.location)==null?void 0:s.name)||"Unknown";return t[a]||(t[a]=[]),t[a].push(e),t},{})),N=v(()=>i.value.filter(t=>t.criticality==="CRITICAL")),g=async(t={})=>{try{n.value=!0,r.value=null,await new Promise(a=>setTimeout(a,1e3));const e=[{id:1,name:"Main HVAC Unit",assetNumber:"HVAC-001",description:"Primary heating and cooling system for floors 1-3",category:l.HVAC,subcategory:"Air Handler",status:u.OPERATIONAL,criticality:c.HIGH,manufacturer:"Carrier",model:"30HXC",serialNumber:"HV001234",modelYear:2020,location:"Roof Level 3",locationId:1,condition:"Good",purchasePrice:45e3,currentValue:38e3,value:45e3,purchaseDate:"2020-03-15",installationDate:"2020-03-15",commissionDate:"2020-03-20",depreciationRate:5,lastMaintenanceDate:"2024-01-15T10:00:00Z",lastMaintenance:"2024-01-15T10:00:00Z",nextMaintenanceDate:"2024-04-15T10:00:00Z",nextMaintenance:"2024-04-15T10:00:00Z",maintenanceStrategy:"PREVENTIVE",maintenanceInterval:90,barcode:"HV001234",isActive:!0,isCritical:!0,operatingHours:12500,warrantyActive:!0,warranty:{isWarrantyActive:!0,warrantyStartDate:"2020-03-15",warrantyEndDate:"2025-03-15",warrantyProvider:"Carrier Corporation",status:"ACTIVE"},customFields:{refrigerantType:"R-410A",coolingCapacity:"50 tons",heatingCapacity:"450 MBH",powerRequirement:"460V/3Ph/60Hz"},createdAt:"2020-03-15T08:00:00Z",updatedAt:"2024-02-01T10:30:00Z"},{id:2,name:"Passenger Elevator",assetNumber:"EL-001",description:"Main passenger elevator serving all floors",category:l.ELEVATOR,subcategory:"Passenger",status:u.MAINTENANCE,criticality:c.CRITICAL,manufacturer:"Otis",model:"Gen2",serialNumber:"EL002456",modelYear:2019,location:"Main Lobby",locationId:2,condition:"Fair",purchasePrice:12e4,currentValue:95e3,value:12e4,purchaseDate:"2019-08-20",installationDate:"2019-08-20",commissionDate:"2019-09-15",depreciationRate:4,lastMaintenanceDate:"2024-01-20T14:00:00Z",lastMaintenance:"2024-01-20T14:00:00Z",nextMaintenanceDate:"2024-02-20T14:00:00Z",nextMaintenance:"2024-02-20T14:00:00Z",maintenanceStrategy:"PREVENTIVE",maintenanceInterval:30,barcode:"EL002456",isActive:!0,isCritical:!0,operatingHours:18500,warrantyActive:!1,warranty:{isWarrantyActive:!1,warrantyStartDate:"2019-08-20",warrantyEndDate:"2022-08-20",warrantyProvider:"Otis Elevator Company",status:"EXPIRED"},customFields:{capacity:"2500 lbs",speed:"500 fpm",floors:"6 stops",doorType:"Center Opening"},createdAt:"2019-08-20T08:00:00Z",updatedAt:"2024-01-20T14:30:00Z"},{id:3,name:"Fire Alarm Panel",assetNumber:"FA-001",description:"Central fire detection and alarm system",category:l.SECURITY,subcategory:"Fire Alarm",status:u.OPERATIONAL,criticality:c.CRITICAL,manufacturer:"Simplex",model:"4100ES",serialNumber:"FA003789",modelYear:2021,location:"Security Office",locationId:3,condition:"Excellent",purchasePrice:25e3,currentValue:22e3,value:25e3,purchaseDate:"2021-06-10",installationDate:"2021-06-10",commissionDate:"2021-06-15",depreciationRate:3,lastMaintenanceDate:"2024-01-10T09:00:00Z",lastMaintenance:"2024-01-10T09:00:00Z",nextMaintenanceDate:"2024-03-10T09:00:00Z",nextMaintenance:"2024-03-10T09:00:00Z",maintenanceStrategy:"PREVENTIVE",maintenanceInterval:60,barcode:"FA003789",isActive:!0,isCritical:!0,operatingHours:24e3,warrantyActive:!0,value:25e3,warranty:{isWarrantyActive:!0,warrantyStartDate:"2021-06-10",warrantyEndDate:"2026-06-10",warrantyProvider:"Simplex Safety Systems",status:"ACTIVE"},customFields:{zones:"24",batteryBackup:"24 hours",networkCapable:"Yes",voiceEvac:"No"},createdAt:"2021-06-10T08:00:00Z",updatedAt:"2024-01-10T09:30:00Z"},{id:4,name:"Backup Generator",assetNumber:"GEN-001",description:"Emergency backup power generator",category:l.ELECTRICAL,subcategory:"Generator",status:u.DOWN,criticality:c.HIGH,manufacturer:"Caterpillar",model:"C32",serialNumber:"GE004567",modelYear:2018,location:"Basement",locationId:4,condition:"Poor",purchasePrice:75e3,currentValue:45e3,value:75e3,purchaseDate:"2018-12-05",installationDate:"2018-12-05",commissionDate:"2018-12-10",depreciationRate:6,lastMaintenanceDate:"2023-12-05T16:00:00Z",lastMaintenance:"2023-12-05T16:00:00Z",nextMaintenanceDate:"2024-02-05T16:00:00Z",nextMaintenance:"2024-02-05T16:00:00Z",maintenanceStrategy:"REACTIVE",maintenanceInterval:180,barcode:"GE004567",isActive:!1,isCritical:!0,operatingHours:850,warrantyActive:!1,warranty:{isWarrantyActive:!1,warrantyStartDate:"2018-12-05",warrantyEndDate:"2021-12-05",warrantyProvider:"Caterpillar Inc.",status:"EXPIRED"},customFields:{fuelType:"Natural Gas",power:"500 kW",voltage:"480V",fuelTankCapacity:"500 gallons"},createdAt:"2018-12-05T08:00:00Z",updatedAt:"2023-12-05T16:30:00Z"},{id:5,name:"Water Heater Unit A",assetNumber:"WH-001",description:"Primary water heating system for building",category:l.PLUMBING,subcategory:"Water Heater",status:u.OPERATIONAL,criticality:c.MEDIUM,manufacturer:"A.O. Smith",model:"BTP-300",serialNumber:"WH005123",modelYear:2022,location:"Mechanical Room",locationId:8,condition:"Good",purchasePrice:8500,currentValue:7500,value:8500,purchaseDate:"2022-03-12",installationDate:"2022-03-12",commissionDate:"2022-03-15",depreciationRate:8,lastMaintenanceDate:"2024-01-05T11:00:00Z",lastMaintenance:"2024-01-05T11:00:00Z",nextMaintenanceDate:"2024-04-05T11:00:00Z",nextMaintenance:"2024-04-05T11:00:00Z",maintenanceStrategy:"PREVENTIVE",maintenanceInterval:90,barcode:"WH005123",isActive:!0,isCritical:!1,operatingHours:8760,warrantyActive:!0,warranty:{isWarrantyActive:!0,warrantyStartDate:"2022-03-12",warrantyEndDate:"2027-03-12",warrantyProvider:"A.O. Smith Corporation",status:"ACTIVE"},customFields:{capacity:"300 gallons",efficiency:"95%",fuelType:"Natural Gas",ventType:"Power Vent"},createdAt:"2022-03-12T08:00:00Z",updatedAt:"2024-01-05T11:30:00Z"}];return i.value=e,I.value=e.length,{content:e,totalElements:e.length}}catch(e){throw r.value=e.message||"Failed to load assets",e}finally{n.value=!1}};return{assets:i,currentAsset:y,loading:n,error:r,totalCount:I,assetHistory:p,assetWorkOrders:f,assetReadings:E,assetFiles:T,filters:o,filteredAssets:h,assetsByStatus:w,assetsByLocation:R,criticalAssets:N,loadAssets:g,fetchAssets:g,getAssetById:t=>i.value.find(e=>e.id===parseInt(t)),fetchAssetById:async t=>{try{n.value=!0,r.value=null,await new Promise(a=>setTimeout(a,500));const e=i.value.find(a=>a.id===parseInt(t));if(!e)throw new Error("Asset not found");return y.value=e,e}catch(e){throw r.value=e.message||"Failed to fetch asset",e}finally{n.value=!1}},fetchAssetHistory:async t=>{try{n.value=!0,r.value=null;const e=await assetRepository.getAssetHistory(t);return p.value=e,e}catch(e){throw r.value=e.message||"Failed to fetch asset history",e}finally{n.value=!1}},fetchAssetWorkOrders:async t=>{try{n.value=!0,r.value=null;const e=await assetRepository.getAssetWorkOrders(t);return f.value=e,e}catch(e){throw r.value=e.message||"Failed to fetch asset work orders",e}finally{n.value=!1}},fetchAssetReadings:async t=>{try{n.value=!0,r.value=null;const e=await assetRepository.getAssetReadings(t);return E.value=e,e}catch(e){throw r.value=e.message||"Failed to fetch asset readings",e}finally{n.value=!1}},fetchAssetFiles:async t=>{try{n.value=!0,r.value=null;const e=await assetRepository.getAssetFiles(t);return T.value=e,e}catch(e){throw r.value=e.message||"Failed to fetch asset files",e}finally{n.value=!1}},createAsset:async t=>{try{n.value=!0,r.value=null,await new Promise(a=>setTimeout(a,1500));const e={...D,...t,id:Date.now(),createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};return i.value.unshift(e),I.value+=1,e}catch(e){throw r.value=e.message||"Failed to create asset",e}finally{n.value=!1}},updateAsset:async(t,e)=>{var a;try{n.value=!0,r.value=null,await new Promise(m=>setTimeout(m,1e3));const s=i.value.findIndex(m=>m.id===parseInt(t));if(s===-1)throw new Error("Asset not found");const A={...i.value[s],...e,updatedAt:new Date().toISOString()};return i.value[s]=A,((a=y.value)==null?void 0:a.id)===parseInt(t)&&(y.value=A),A}catch(s){throw r.value=s.message||"Failed to update asset",s}finally{n.value=!1}},updateAssetStatus:async(t,e)=>{var a;try{n.value=!0,r.value=null;const s=await assetRepository.updateAssetStatus(t,e),A=i.value.findIndex(m=>m.id===t);return A!==-1&&(i.value[A]=s),((a=y.value)==null?void 0:a.id)===t&&(y.value=s),s}catch(s){throw r.value=s.message||"Failed to update asset status",s}finally{n.value=!1}},addAssetReading:async(t,e)=>{try{n.value=!0,r.value=null;const a=await assetRepository.addAssetReading(t,e);return E.value.unshift(a),a}catch(a){throw r.value=a.message||"Failed to add asset reading",a}finally{n.value=!1}},addAssetFile:async(t,e)=>{try{n.value=!0,r.value=null;const a=await assetRepository.addAssetFile(t,e);return T.value.unshift(a),a}catch(a){throw r.value=a.message||"Failed to upload asset file",a}finally{n.value=!1}},deleteAsset:async t=>{var e;try{return n.value=!0,r.value=null,await assetRepository.delete(t),i.value=i.value.filter(a=>a.id!==t),I.value-=1,((e=y.value)==null?void 0:e.id)===t&&(y.value=null),!0}catch(a){throw r.value=a.message||"Failed to delete asset",a}finally{n.value=!1}},setFilters:t=>{o.value={...o.value,...t}},clearFilters:()=>{o.value={locationId:null,categoryId:null,status:null,search:""}},clearError:()=>{r.value=null}}});export{u as A,z as C,j as S,S as W,Q as a,c as b,l as c,X as d,D as e,J as u};