import{r as i,e as t,B as l,h as o}from"./p-a89095f5.js";import{t as e}from"./p-3e7f0e42.js";import{s as a}from"./p-9e8ba117.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 n=class{constructor(l){i(this,l),this.fireenjinFetch=t(this,"fireenjinFetch",7),this.fireenjinSubmit=t(this,"fireenjinSubmit",7),this.fireenjinTrigger=t(this,"fireenjinTrigger",7),this.materialId=void 0,this.material={}}async onSuccess(i){var t,l,o,a,n,r,s,d;if("findMaterial"===(null===(t=null==i?void 0:i.detail)||void 0===t?void 0:t.endpoint))this.material=(null===(o=null===(l=null==i?void 0:i.detail)||void 0===l?void 0:l.data)||void 0===o?void 0:o.material)||null;else if("editMaterial"===(null===(a=null==i?void 0:i.detail)||void 0===a?void 0:a.endpoint))(await e.create({message:"Material saved successfully!",duration:3e3})).present();else if("addMaterial"===(null===(n=null==i?void 0:i.detail)||void 0===n?void 0:n.endpoint)&&"new"===this.materialId){const t=document.querySelector("ion-router");this.materialId=(null===(d=null===(s=null===(r=null==i?void 0:i.detail)||void 0===r?void 0:r.data)||void 0===s?void 0:s.addMaterial)||void 0===d?void 0:d.id)||"new",t&&t.push(`/materials/${this.materialId}`)}}async fetchMaterial(){this.fireenjinFetch.emit({endpoint:"findMaterial",params:{id:this.materialId}})}componentDidLoad(){(null==l?void 0:l.isBrowser)&&this.fetchMaterial()}render(){var i,t,l;return[o("ion-content",{class:"ion-padding"},o("floodteam-title-bar",null,o("ion-router-link",{href:"/materials"},"Materials")),o("ion-card",{style:{overflow:"visible"}},o("fireenjin-form",{resetButton:"Clear",resetButtonColor:"medium",ref:i=>this.formEl=i,endpoint:"new"===this.materialId?"addMaterial":"editMaterial",documentId:"new"===this.materialId?null:this.materialId},o("ion-grid",null,o("ion-row",null,o("ion-col",{size:"10"},o("fireenjin-input",{"data-fill":!0,labelPosition:"stacked",type:"text",name:"name",label:"Name",value:null===(i=this.material)||void 0===i?void 0:i.name,required:!0}))))))),o("floodteam-navigation-footer",null,o("floodteam-title-bar",{back:"/materials"},o("ion-breadcrumbs",null,o("ion-breadcrumb",{href:"/materials"},o("ion-icon",{class:"ft-icon-style",slot:"start",name:"construct"}),"Materials"),o("ion-breadcrumb",{onClick:()=>{var i;return this.fireenjinTrigger.emit({name:"pin",payload:{icon:"flash",href:`/materials/${this.materialId}`,name:(null===(i=this.material)||void 0===i?void 0:i.name)||"Add a Material"}})}},o("ion-icon",{color:(null===(t=((null==a?void 0:a.pins)||[]).map((i=>null==i?void 0:i.href)))||void 0===t?void 0:t.includes(`/materials/${this.materialId}`))?"primary":null,slot:"start",name:"pin"}),(null===(l=this.material)||void 0===l?void 0:l.name)||"Edit Material")))),,]}};n.style="";export{n as app_material}