import{r as i,e,B as l,h as t}from"./p-a89095f5.js";import{t as n}from"./p-3e7f0e42.js";import{s as o}from"./p-188ef7e9.js";import"./p-29ec504c.js";import"./p-8cd54418.js";import"./p-d7f93824.js";import"./p-2a0c7fc9.js";import"./p-86bd3473.js";import"./p-65879f9e.js";import"./p-60cf0cc2.js";const a=class{constructor(l){i(this,l),this.fireenjinFetch=e(this,"fireenjinFetch",7),this.fireenjinTrigger=e(this,"fireenjinTrigger",7),this.toolId=void 0,this.tool=void 0}async onSuccess(i){var e,l,t,o,a,s,d,u;if("findEquipment"===(null===(e=null==i?void 0:i.detail)||void 0===e?void 0:e.endpoint))this.tool=(null===(t=null===(l=null==i?void 0:i.detail)||void 0===l?void 0:l.data)||void 0===t?void 0:t.equipment)||null;else if("editEquipment"===(null===(o=null==i?void 0:i.detail)||void 0===o?void 0:o.endpoint))(await n.create({message:"equipment saved successfully!",duration:3e3})).present();else if("addEquipment"===(null===(a=null==i?void 0:i.detail)||void 0===a?void 0:a.endpoint)&&"new"===this.toolId){const e=document.querySelector("ion-router");this.toolId=(null===(u=null===(d=null===(s=null==i?void 0:i.detail)||void 0===s?void 0:s.data)||void 0===d?void 0:d.addEquipment)||void 0===u?void 0:u.id)||"new",e&&e.push(`/equipment/${this.toolId}`)}}async fetchEquipment(){this.fireenjinFetch.emit({endpoint:"findEquipment",params:{id:this.toolId}})}componentDidLoad(){(null==l?void 0:l.isBrowser)&&this.fetchEquipment()}render(){var i,e,l,n,a,s,d,u;return[t("ion-content",{class:"ion-padding"},t("floodteam-title-bar",null,t("ion-router-link",{href:"/equipment"},"Equipment")),t("ion-card",{style:{overflow:"visible"}},t("ion-card-header",null,(null===(i=this.tool)||void 0===i?void 0:i.id)?"Edit":"Add"," ",(null===(e=this.tool)||void 0===e?void 0:e.name)||"Equipment"),t("fireenjin-form",{resetButton:"Clear",resetButtonColor:"medium",ref:i=>this.formEl=i,endpoint:"new"===this.toolId?"addEquipment":"editEquipment",documentId:"new"===this.toolId?null:this.toolId},t("ion-grid",null,t("ion-row",null,t("ion-col",{size:"10"},t("fireenjin-input",{"data-fill":!0,labelPosition:"stacked",type:"text",name:"name",label:"Name",value:null===(l=this.tool)||void 0===l?void 0:l.name,required:!0})),t("ion-col",{"size-md":"6",size:"10"},t("fireenjin-select",{"data-fill":!0,labelPosition:"stacked",name:"type",options:[{label:"Equipment",value:"equipment"},{label:"Restockable",value:"restockable"},{label:"Vehicle",value:"vehicle"}],label:"Type",value:null===(n=this.tool)||void 0===n?void 0:n.type,required:!0})),t("ion-col",{"size-md":"6",size:"10"},t("fireenjin-select",{"data-fill":!0,labelPosition:"stacked",name:"group",options:[{label:"Matterport",value:"matterport"},{label:"Dehumidifier",value:"dehumidifier"},{label:"Fan",value:"fan"},{label:"Moisture Meter",value:"moistureMeter"},{label:"Vacuum",value:"vacuum"}],label:"Group",value:null===(a=this.tool)||void 0===a?void 0:a.group,required:!0})),t("ion-col",{size:"10"},t("fireenjin-select-tags",{name:"tags",label:"Tags",labelPosition:"stacked",value:null===(s=this.tool)||void 0===s?void 0:s.tags,allowAdding:!0,options:[{label:"Important",value:"important"}]}))))))),t("floodteam-navigation-footer",null,t("floodteam-title-bar",{back:"/equipment"},t("ion-breadcrumbs",null,t("ion-breadcrumb",{href:"/equipment"},t("ion-icon",{class:"ft-icon-style",slot:"start",name:"hammer"}),"Equipment"),t("ion-breadcrumb",{onClick:()=>{var i;return this.fireenjinTrigger.emit({name:"pin",payload:{icon:"flash",href:`/equipment/${this.toolId}`,name:(null===(i=this.tool)||void 0===i?void 0:i.name)||"Add Equipment"}})}},t("ion-icon",{color:(null===(d=((null==o?void 0:o.pins)||[]).map((i=>null==i?void 0:i.href)))||void 0===d?void 0:d.includes(`/equipment/${this.toolId}`))?"primary":null,slot:"start",name:"pin"}),("new"===this.toolId?"Add Equipment":null===(u=this.tool)||void 0===u?void 0:u.name)||"Edit Equipment"))))]}};a.style="";export{a as app_equipment}