import{_ as B,r as c,c as H,o as q,a as d,b as t,d as o,w as v,e as s,F as p,s as j,v as $,g as m,k as b,j as D,ae as Y,n as z,aU as G,t as f,af as Q,aQ as W}from"./index-BUdRbiwj.js";import{F as i}from"./FPInput-CzR_dWoe.js";import{F as X}from"./FPCard-qHzcEQAE.js";import{F as k}from"./FPCheckbox-Bu8jNAEW.js";import{F as y}from"./FPSelect-C7p47Ma2.js";const J={class:"edit-asset-view"},K={class:"flex items-center justify-between mb-6"},Z={class:"flex items-center space-x-3"},h={key:0,class:"flex items-center justify-center py-12"},_={key:1,class:"max-w-4xl mx-auto"},ee={class:"space-y-6"},le={class:"grid grid-cols-1 md:grid-cols-2 gap-6"},ae={class:"md:col-span-2"},te={key:0,class:"mt-1 text-sm text-red-600"},oe={class:"grid grid-cols-1 md:grid-cols-2 gap-6"},se={class:"grid grid-cols-1 md:grid-cols-2 gap-6"},re={class:"grid grid-cols-1 md:grid-cols-2 gap-6"},ie={class:"grid grid-cols-1 md:grid-cols-2 gap-6"},ne={class:"flex items-start space-x-3 pt-6"},ue={class:"flex items-start space-x-3 pt-6"},de={key:0,class:"p-4 bg-red-50 border border-red-200 rounded-lg"},me={class:"flex items-start"},ve={class:"text-sm text-red-700 space-y-1"},pe={class:"flex items-center justify-between pt-6 border-t mt-6"},be={class:"flex items-center space-x-3"},ce={key:2,class:"text-center py-12"},ye={__name:"EditAssetView",setup(Ve){const x=$(),C=j(),g=c(!0),V=c(!1),l=c(null),A=c(null),r=c({}),N=[{value:"HVAC",label:"HVAC"},{value:"ELEVATOR",label:"Elevator"},{value:"SECURITY",label:"Security"},{value:"ELECTRICAL",label:"Electrical"},{value:"PLUMBING",label:"Plumbing"},{value:"MECHANICAL",label:"Mechanical"},{value:"STRUCTURAL",label:"Structural"},{value:"IT_EQUIPMENT",label:"IT Equipment"},{value:"SAFETY",label:"Safety"},{value:"OTHER",label:"Other"}],S=[{value:"OPERATIONAL",label:"Operational"},{value:"MAINTENANCE",label:"Under Maintenance"},{value:"DOWN",label:"Out of Service"},{value:"DECOMMISSIONED",label:"Decommissioned"}],w=[{value:"LOW",label:"Low"},{value:"MEDIUM",label:"Medium"},{value:"HIGH",label:"High"},{value:"CRITICAL",label:"Critical"}],F=[{value:"Roof Level 3",label:"Roof Level 3"},{value:"Main Lobby",label:"Main Lobby"},{value:"Security Office",label:"Security Office"},{value:"Basement",label:"Basement"},{value:"Floor 1",label:"Floor 1"},{value:"Floor 2",label:"Floor 2"},{value:"Floor 3",label:"Floor 3"}],P=[{value:"REACTIVE",label:"Reactive"},{value:"PREVENTIVE",label:"Preventive"},{value:"PREDICTIVE",label:"Predictive"},{value:"CONDITION_BASED",label:"Condition-Based"}],M=H(()=>Object.keys(r.value).length===0),O=async()=>{g.value=!0,setTimeout(()=>{const e={id:parseInt(C.params.id),name:"Main HVAC Unit",description:"Primary heating and cooling system for floors 1-3",assetNumber:"HVAC-001",category:"HVAC",subcategory:"Air Handler",status:"OPERATIONAL",criticality:"HIGH",manufacturer:"Carrier",model:"30HXC",serialNumber:"HV001234",modelYear:2020,location:"Roof Level 3",condition:"Good",purchasePrice:45e3,currentValue:38e3,purchaseDate:"2020-03-15",installationDate:"2020-03-15",commissionDate:"2020-03-20",depreciationRate:5,lastMaintenanceDate:"2024-01-15",nextMaintenanceDate:"2024-04-15",maintenanceStrategy:"PREVENTIVE",maintenanceInterval:90,barcode:"HV001234",isActive:!0,isCritical:!0};l.value={...e},A.value={...e},g.value=!1},1e3)},u=n=>{var e;switch(n){case"name":(e=l.value.name)!=null&&e.trim()?delete r.value.name:r.value.name="Asset name is required";break;case"category":l.value.category?delete r.value.category:r.value.category="Category is required";break;case"status":l.value.status?delete r.value.status:r.value.status="Status is required";break;case"criticality":l.value.criticality?delete r.value.criticality:r.value.criticality="Criticality is required";break}},R=()=>(r.value={},u("name"),u("category"),u("status"),u("criticality"),Object.keys(r.value).length===0),T=n=>({name:"Asset Name",category:"Category",status:"Status",criticality:"Criticality",assetNumber:"Asset Number"})[n]||n,L=()=>{l.value={...A.value},r.value={}},I=async()=>{if(R())try{V.value=!0,await new Promise(n=>setTimeout(n,2e3)),x.push(`/assets/${l.value.id}`)}catch(n){console.error("Failed to save asset:",n)}finally{V.value=!1}},E=()=>{x.push(`/assets/${C.params.id}`)};return q(()=>{O()}),(n,e)=>(m(),d("div",J,[t("div",K,[e[34]||(e[34]=t("div",null,[t("h1",{class:"text-2xl font-bold text-gray-900"},"Edit Asset"),t("p",{class:"text-gray-600 mt-1"},"Update asset information and settings")],-1)),t("div",Z,[o(s(p),{variant:"ghost",onClick:E},{default:v(()=>e[32]||(e[32]=[b(" Cancel ",-1)])),_:1,__:[32]}),o(s(p),{onClick:I,loading:V.value,disabled:!M.value},{default:v(()=>e[33]||(e[33]=[b(" Save Changes ",-1)])),_:1,__:[33]},8,["loading","disabled"])])]),g.value?(m(),d("div",h,e[35]||(e[35]=[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 asset...")],-1)]))):l.value?(m(),d("div",_,[o(s(X),{class:"p-6"},{default:v(()=>[t("div",ee,[t("div",null,[e[37]||(e[37]=t("h2",{class:"text-xl font-semibold text-gray-900 mb-4 border-b pb-2"},"Basic Information",-1)),t("div",le,[o(s(i),{modelValue:l.value.name,"onUpdate:modelValue":e[0]||(e[0]=a=>l.value.name=a),label:"Asset Name",placeholder:"Enter asset name",required:!0,error:r.value.name,onBlur:e[1]||(e[1]=a=>u("name"))},null,8,["modelValue","error"]),o(s(i),{modelValue:l.value.assetNumber,"onUpdate:modelValue":e[2]||(e[2]=a=>l.value.assetNumber=a),label:"Asset Number",placeholder:"Unique identifier",error:r.value.assetNumber,onBlur:e[3]||(e[3]=a=>u("assetNumber"))},null,8,["modelValue","error"]),t("div",ae,[e[36]||(e[36]=t("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Description",-1)),Y(t("textarea",{"onUpdate:modelValue":e[4]||(e[4]=a=>l.value.description=a),class:z(["w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500",{"border-red-300":r.value.description}]),placeholder:"Describe the asset's purpose and characteristics",rows:"3"},null,2),[[G,l.value.description]]),r.value.description?(m(),d("p",te,f(r.value.description),1)):D("",!0)]),o(s(y),{modelValue:l.value.category,"onUpdate:modelValue":e[5]||(e[5]=a=>l.value.category=a),label:"Category",placeholder:"Select asset category",options:N,required:!0,error:r.value.category,onChange:e[6]||(e[6]=a=>u("category"))},null,8,["modelValue","error"]),o(s(i),{modelValue:l.value.subcategory,"onUpdate:modelValue":e[7]||(e[7]=a=>l.value.subcategory=a),label:"Subcategory",placeholder:"Specific type within category"},null,8,["modelValue"]),o(s(y),{modelValue:l.value.status,"onUpdate:modelValue":e[8]||(e[8]=a=>l.value.status=a),label:"Status",placeholder:"Select current status",options:S,required:!0,error:r.value.status,onChange:e[9]||(e[9]=a=>u("status"))},null,8,["modelValue","error"]),o(s(y),{modelValue:l.value.criticality,"onUpdate:modelValue":e[10]||(e[10]=a=>l.value.criticality=a),label:"Criticality",placeholder:"Select criticality level",options:w,required:!0,error:r.value.criticality,onChange:e[11]||(e[11]=a=>u("criticality"))},null,8,["modelValue","error"])])]),t("div",null,[e[38]||(e[38]=t("h2",{class:"text-xl font-semibold text-gray-900 mb-4 border-b pb-2"},"Physical Details",-1)),t("div",oe,[o(s(i),{modelValue:l.value.manufacturer,"onUpdate:modelValue":e[12]||(e[12]=a=>l.value.manufacturer=a),label:"Manufacturer",placeholder:"Asset manufacturer"},null,8,["modelValue"]),o(s(i),{modelValue:l.value.model,"onUpdate:modelValue":e[13]||(e[13]=a=>l.value.model=a),label:"Model",placeholder:"Model number or name"},null,8,["modelValue"]),o(s(i),{modelValue:l.value.serialNumber,"onUpdate:modelValue":e[14]||(e[14]=a=>l.value.serialNumber=a),label:"Serial Number",placeholder:"Unique serial number"},null,8,["modelValue"]),o(s(i),{modelValue:l.value.modelYear,"onUpdate:modelValue":e[15]||(e[15]=a=>l.value.modelYear=a),modelModifiers:{number:!0},type:"number",label:"Model Year",placeholder:"Year of manufacture",min:1900,max:new Date().getFullYear()+1},null,8,["modelValue","max"]),o(s(y),{modelValue:l.value.location,"onUpdate:modelValue":e[16]||(e[16]=a=>l.value.location=a),label:"Location",placeholder:"Select asset location",options:F},null,8,["modelValue"]),o(s(i),{modelValue:l.value.condition,"onUpdate:modelValue":e[17]||(e[17]=a=>l.value.condition=a),label:"Condition",placeholder:"Current condition (Good, Fair, Poor)"},null,8,["modelValue"])])]),t("div",null,[e[39]||(e[39]=t("h2",{class:"text-xl font-semibold text-gray-900 mb-4 border-b pb-2"},"Financial Information",-1)),t("div",se,[o(s(i),{modelValue:l.value.purchasePrice,"onUpdate:modelValue":e[18]||(e[18]=a=>l.value.purchasePrice=a),modelModifiers:{number:!0},type:"number",label:"Purchase Price",placeholder:"0.00",step:"0.01",min:"0"},null,8,["modelValue"]),o(s(i),{modelValue:l.value.currentValue,"onUpdate:modelValue":e[19]||(e[19]=a=>l.value.currentValue=a),modelModifiers:{number:!0},type:"number",label:"Current Value",placeholder:"0.00",step:"0.01",min:"0"},null,8,["modelValue"]),o(s(i),{modelValue:l.value.purchaseDate,"onUpdate:modelValue":e[20]||(e[20]=a=>l.value.purchaseDate=a),type:"date",label:"Purchase Date"},null,8,["modelValue"]),o(s(i),{modelValue:l.value.installationDate,"onUpdate:modelValue":e[21]||(e[21]=a=>l.value.installationDate=a),type:"date",label:"Installation Date"},null,8,["modelValue"]),o(s(i),{modelValue:l.value.commissionDate,"onUpdate:modelValue":e[22]||(e[22]=a=>l.value.commissionDate=a),type:"date",label:"Commission Date"},null,8,["modelValue"]),o(s(i),{modelValue:l.value.depreciationRate,"onUpdate:modelValue":e[23]||(e[23]=a=>l.value.depreciationRate=a),modelModifiers:{number:!0},type:"number",label:"Depreciation Rate (%)",placeholder:"0",step:"0.1",min:"0",max:"100"},null,8,["modelValue"])])]),t("div",null,[e[40]||(e[40]=t("h2",{class:"text-xl font-semibold text-gray-900 mb-4 border-b pb-2"},"Maintenance Information",-1)),t("div",re,[o(s(i),{modelValue:l.value.lastMaintenanceDate,"onUpdate:modelValue":e[24]||(e[24]=a=>l.value.lastMaintenanceDate=a),type:"date",label:"Last Maintenance Date"},null,8,["modelValue"]),o(s(i),{modelValue:l.value.nextMaintenanceDate,"onUpdate:modelValue":e[25]||(e[25]=a=>l.value.nextMaintenanceDate=a),type:"date",label:"Next Maintenance Date"},null,8,["modelValue"]),o(s(y),{modelValue:l.value.maintenanceStrategy,"onUpdate:modelValue":e[26]||(e[26]=a=>l.value.maintenanceStrategy=a),label:"Maintenance Strategy",placeholder:"Select strategy",options:P},null,8,["modelValue"]),o(s(i),{modelValue:l.value.maintenanceInterval,"onUpdate:modelValue":e[27]||(e[27]=a=>l.value.maintenanceInterval=a),modelModifiers:{number:!0},type:"number",label:"Maintenance Interval (days)",placeholder:"0",min:"1"},null,8,["modelValue"])])]),t("div",null,[e[43]||(e[43]=t("h2",{class:"text-xl font-semibold text-gray-900 mb-4 border-b pb-2"},"Additional Information",-1)),t("div",ie,[o(s(i),{modelValue:l.value.barcode,"onUpdate:modelValue":e[28]||(e[28]=a=>l.value.barcode=a),label:"Barcode/QR Code",placeholder:"Enter or scan barcode"},null,8,["modelValue"]),t("div",ne,[o(s(k),{id:"is-active",modelValue:l.value.isActive,"onUpdate:modelValue":e[29]||(e[29]=a=>l.value.isActive=a)},null,8,["modelValue"]),e[41]||(e[41]=t("div",null,[t("label",{for:"is-active",class:"text-sm font-medium text-gray-700"},"Asset is Active"),t("p",{class:"text-sm text-gray-500 mt-1"}," Inactive assets are excluded from maintenance schedules ")],-1))]),t("div",ue,[o(s(k),{id:"is-critical",modelValue:l.value.isCritical,"onUpdate:modelValue":e[30]||(e[30]=a=>l.value.isCritical=a)},null,8,["modelValue"]),e[42]||(e[42]=t("div",null,[t("label",{for:"is-critical",class:"text-sm font-medium text-gray-700"},"Critical Asset"),t("p",{class:"text-sm text-gray-500 mt-1"}," Critical assets receive priority in maintenance scheduling ")],-1))])])]),Object.keys(r.value).length?(m(),d("div",de,[t("div",me,[e[45]||(e[45]=t("svg",{class:"w-5 h-5 text-red-400 mt-0.5 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})],-1)),t("div",null,[e[44]||(e[44]=t("h4",{class:"text-sm font-medium text-red-800 mb-1"},"Please fix the following errors:",-1)),t("ul",ve,[(m(!0),d(Q,null,W(r.value,(a,U)=>(m(),d("li",{key:U},' " '+f(T(U))+": "+f(a),1))),128))])])])])):D("",!0)]),t("div",pe,[o(s(p),{variant:"secondary",onClick:L},{default:v(()=>e[46]||(e[46]=[b(" Reset Changes ",-1)])),_:1,__:[46]}),t("div",be,[o(s(p),{variant:"ghost",onClick:E},{default:v(()=>e[47]||(e[47]=[b(" Cancel ",-1)])),_:1,__:[47]}),o(s(p),{onClick:I,loading:V.value,disabled:!M.value},{default:v(()=>e[48]||(e[48]=[b(" Save Changes ",-1)])),_:1,__:[48]},8,["loading","disabled"])])])]),_:1})])):(m(),d("div",ce,[e[50]||(e[50]=t("svg",{class:"w-12 h-12 mx-auto mb-4 text-red-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})],-1)),e[51]||(e[51]=t("h3",{class:"text-lg font-medium text-gray-900 mb-2"},"Asset Not Found",-1)),e[52]||(e[52]=t("p",{class:"text-gray-500 mb-4"},"The requested asset could not be found.",-1)),o(s(p),{onClick:e[31]||(e[31]=a=>n.$router.push("/assets"))},{default:v(()=>e[49]||(e[49]=[b(" Back to Assets ",-1)])),_:1,__:[49]})]))]))}},Me=B(ye,[["__scopeId","data-v-ba4f7f7a"]]);export{Me as default};