import{r as i,e as o,h as l}from"./p-a89095f5.js";import{f as n}from"./p-cf4a3445.js";import{s as e}from"./p-188ef7e9.js";import{g as t}from"./p-624bbdaa.js";import{m as s}from"./p-3e7f0e42.js";import"./p-d7f93824.js";import"./p-2a0c7fc9.js";import"./p-86bd3473.js";import"./p-65879f9e.js";import"./p-60cf0cc2.js";import"./p-29ec504c.js";import"./p-8cd54418.js";const a=class{constructor(l){i(this,l),this.fireenjinTrigger=o(this,"fireenjinTrigger",7),this.fireenjinSubmit=o(this,"fireenjinSubmit",7),this.floodteamCloseModal=o(this,"floodteamCloseModal",7),this.fetchData=void 0,this.paginationEl=void 0,this.query=void 0,this.selectedIds=[],this.selectedServices=[],this.services=[],this.filter={tab:null}}onSearchInput(i){this.query=i.target.value}onTrigger(i){var o,l,n,e,t;if("set"!==(null===(o=null==i?void 0:i.detail)||void 0===o?void 0:o.name))return;const s=null===(n=null===(l=null==i?void 0:i.detail)||void 0===l?void 0:l.payload)||void 0===n?void 0:n.name,a=null===(t=null===(e=null==i?void 0:i.detail)||void 0===e?void 0:e.payload)||void 0===t?void 0:t.value;this.fetchData={...this.fetchData,[s]:a}}onCodeChange(i){var o,l;if("bulkEdit"!==(null===(o=null==i?void 0:i.detail)||void 0===o?void 0:o.name)){for(const o of this.selectedIds)this.fireenjinSubmit.emit({name:"bulkEdit",endpoint:"editService",params:{id:o,data:(null===(l=null==i?void 0:i.detail)||void 0===l?void 0:l.data)||{}}});this.floodteamCloseModal.emit()}}async toggleService(i){var o,l;i.preventDefault(),i.stopPropagation();const n=this.selectedIds;console.log(i),this.selectedIds.includes(null===(o=null==i?void 0:i.target)||void 0===o?void 0:o.value)?n.splice(this.selectedIds.indexOf(i.target.value),1):n.push(null===(l=null==i?void 0:i.target)||void 0===l?void 0:l.value),this.selectedIds=n,console.log(this.selectedIds)}async openCodeEditor(i,o){const l=await s.create({component:"fireenjin-mx-modal-code-editor",cssClass:"fireenjin-mx-modal-code-editor-wrapper",componentProps:{pageTitle:"autofill"===i?"Set Auto-Fill":"Set Smart Scoping",name:i,language:"json",value:o,endpoint:"",documentId:!0}});return await l.present(),l}render(){var i,o,s;return[l("ion-content",{class:"ion-padding"},l("floodteam-title-bar",null,l("ion-router-link",{href:"/services"},"Services"),l("ion-buttons",{slot:"end"},l("ion-button",{fill:"solid",color:"primary",href:"/services/new"},"Add"))),l("fireenjin-search-bar",{paginationEl:this.paginationEl,filters:(null===(i=null==e?void 0:e.claims)||void 0===i?void 0:i.tester)||(null===(o=null==e?void 0:e.claims)||void 0===o?void 0:o.admin)?[{name:"tabs",label:"Tab",icon:"albums",multiple:!0,options:t(),value:null===(s=this.filter)||void 0===s?void 0:s.tab}]:null}),l("ion-card",{class:"list-card"},l("ion-list",{class:"ion-no-padding"},l("fireenjin-pagination",{ref:i=>this.paginationEl=i,name:"services",approxItemHeight:84,endpoint:"listServices",pageKey:"name",orderBy:"name",orderDirection:"asc",fetchData:this.fetchData,resultsKey:"services",limit:50,query:this.query,renderItem:i=>l("ion-item",{href:`/services/${i.id}`,detail:!0},l("ion-checkbox",{id:`toggle.${(null==i?void 0:i.id)||""}`,slot:"start",onClick:i=>this.toggleService(i),value:null==i?void 0:i.id,checked:this.selectedIds.includes(null==i?void 0:i.id)}),l("ion-label",null,l("h2",null,(null==i?void 0:i.name)||""," "),l("div",null,Object.entries((null==i?void 0:i.prices)||{}).map((([i,o])=>l("ion-chip",null,l("ion-label",null,i||"",":"," ",l("ion-text",{color:"success",slot:"end"},n(o||0)))))))))})))),l("floodteam-navigation-footer",null,l("fireenjin-chip-bar",null,l("ion-chip",{onClick:()=>this.fireenjinTrigger.emit({name:"import",type:"services"})},l("ion-icon",{class:"ft-icon-style",name:"cloud-upload"}),l("ion-label",null,"Import from CSV")),l("ion-chip",{onClick:()=>this.fireenjinTrigger.emit({name:"export",collection:"services"})},l("ion-icon",{name:"cloud-download",class:"ft-icon-style"}),l("ion-label",null,"Export to CSV")),l("ion-chip",{onClick:()=>this.openCodeEditor("autofill",null)},l("ion-icon",{class:"ft-icon-style",name:"code"}),l("ion-label",null,"Set Auto-Fill")),l("ion-chip",{onClick:()=>this.openCodeEditor("smartScoping",null)},l("ion-icon",{class:"ft-icon-style",name:"code"}),l("ion-label",null,"Set Smart Scoping"))))]}};a.style="";export{a as app_service_list}