import{r as i,d as o,B as l,h as n}from"./p-03169580.js";import{f as t}from"./p-cf4a3445.js";import{s as e}from"./p-e1ee6da1.js";import{s,g as d}from"./p-06a8e283.js";import{m as a}from"./p-5a032a89.js";import"./p-59c95c5f.js";import"./p-3775d1fc.js";import"./p-80de33dc.js";import"./p-c2fbed0d.js";import"./p-5717491f.js";import"./p-de14d315.js";import"./p-2b31742f.js";import"./p-4cb16df5.js";import"./p-f44f0a67.js";function r(i,o=[],l="."){return Object.keys(i).reduce(((n,t)=>Object.assign({},n,Object.prototype.toString.call(i[t])==="[object Object]"?r(i[t],o.concat([t]),l):{[o.concat([t]).join(l)]:i[t]})),{})}function c(i,...o){const l={...i};o.forEach((function(i){delete l[i]}));return l}const u="";let v=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.selectedIds=[];this.selectedServices=[];this.services=[];this.filter={tab:null}}onCodeChange(i){var o,l;if(((o=i===null||i===void 0?void 0:i.detail)===null||o===void 0?void 0:o.name)==="bulkEdit")return;for(const o of this.selectedIds){this.fireenjinSubmit.emit({name:"bulkEdit",endpoint:"editService",params:{id:o,data:((l=i===null||i===void 0?void 0:i.detail)===null||l===void 0?void 0:l.data)||{}}})}this.floodteamCloseModal.emit()}async onSearchInput(i){this.query=i.target.value;this.services=await s(this.query)}async onTrigger(i){var o,l,n,t,e,d;if(i.detail.name==="set"&&((l=(o=i.detail)===null||o===void 0?void 0:o.payload)===null||l===void 0?void 0:l.name)){this.filter={...this.filter,[(t=(n=i.detail)===null||n===void 0?void 0:n.payload)===null||t===void 0?void 0:t.name]:((d=(e=i===null||i===void 0?void 0:i.detail)===null||e===void 0?void 0:e.payload)===null||d===void 0?void 0:d.value)||null};this.services=await s(this.query,(i=>{var o,l;return(l=(o=this.filter)===null||o===void 0?void 0:o.tab)===null||l===void 0?void 0:l.includes(i===null||i===void 0?void 0:i.tab)}))}}async toggleService(i){var o,l;i.preventDefault();i.stopPropagation();const n=this.selectedIds;console.log(i);if(this.selectedIds.includes((o=i===null||i===void 0?void 0:i.target)===null||o===void 0?void 0:o.value)){n.splice(this.selectedIds.indexOf(i.target.value),1)}else{n.push((l=i===null||i===void 0?void 0:i.target)===null||l===void 0?void 0:l.value)}this.selectedIds=n;console.log(this.selectedIds)}async openCodeEditor(i,o){const l=await a.create({component:"fireenjin-mx-modal-code-editor",cssClass:"fireenjin-mx-modal-code-editor-wrapper",componentProps:{pageTitle:i==="autofill"?"Set Auto-Fill":"Set Smart Scoping",name:i,language:"json",value:o,endpoint:"",documentId:true}});await l.present();return l}async componentDidLoad(){if(!(l===null||l===void 0?void 0:l.isBrowser))return;this.services=await s(this.query);console.log(this.services)}render(){var i,o,l;return[n("ion-content",{class:"ion-padding"},n("floodteam-title-bar",null,n("ion-router-link",{href:"/services"},"Services"),n("ion-buttons",{slot:"end"},n("ion-button",{fill:"solid",color:"primary",href:"/services/new"},"Add"))),n("fireenjin-search-bar",{paginationEl:this.paginationEl,filters:((i=e===null||e===void 0?void 0:e.claims)===null||i===void 0?void 0:i.tester)||((o=e===null||e===void 0?void 0:e.claims)===null||o===void 0?void 0:o.admin)?[{name:"tab",label:"Tab",icon:"albums",multiple:true,options:d(),value:(l=this.filter)===null||l===void 0?void 0:l.tab}]:null}),n("ion-card",{class:"list-card"},n("ion-list",{class:"ion-no-padding"},n("fireenjin-pagination",{approxItemHeight:84,results:this.services,renderItem:i=>n("ion-item",{href:`/services/${i.id}`,detail:true},n("ion-checkbox",{id:`toggle.${(i===null||i===void 0?void 0:i.id)||""}`,slot:"start",onClick:i=>this.toggleService(i),value:i===null||i===void 0?void 0:i.id,checked:this.selectedIds.includes(i===null||i===void 0?void 0:i.id)}),n("ion-label",null,n("h2",null,(i===null||i===void 0?void 0:i.name)||""," "),n("div",null,Object.entries((i===null||i===void 0?void 0:i.prices)||{}).map((([i,o])=>n("ion-chip",null,n("ion-label",null,i||"",":"," ",n("ion-text",{color:"success",slot:"end"},t(o||0)))))))))})))),n("floodteam-navigation-footer",null,n("fireenjin-chip-bar",null,n("ion-chip",{onClick:()=>this.fireenjinTrigger.emit({name:"import",type:"services"})},n("ion-icon",{class:"ft-icon-style",name:"cloud-upload"}),n("ion-label",null,"Import from CSV")),n("ion-chip",{onClick:()=>this.fireenjinTrigger.emit({name:"export",payload:this.services.map((i=>r(c(i,"createdAt","updatedAt"))))})},n("ion-icon",{name:"cloud-download",class:"ft-icon-style"}),n("ion-label",null,"Export to CSV")),n("ion-chip",{onClick:()=>this.openCodeEditor("autofill",null)},n("ion-icon",{class:"ft-icon-style",name:"code"}),n("ion-label",null,"Set Auto-Fill")),n("ion-chip",{onClick:()=>this.openCodeEditor("smartScoping",null)},n("ion-icon",{class:"ft-icon-style",name:"code"}),n("ion-label",null,"Set Smart Scoping"))))]}};v.style=u;export{v as app_service_list};
//# sourceMappingURL=p-f7410a4e.entry.js.map