import{r as i,d as o,B as l,h as t}from"./p-846bd001.js";import{s as a}from"./p-4ff8bb4b.js";import{g as n}from"./p-c0e85cbf.js";import{i as d}from"./p-7bd69491.js";import{i as e}from"./p-9c1d1ca8.js";import"./p-5cd01495.js";import"./p-259f1737.js";import"./p-ae2fb9dc.js";import"./p-65879f9e.js";import"./p-dca1478c.js";const s=class{constructor(l){i(this,l),this.fireenjinTrigger=o(this,"fireenjinTrigger",7),this.fireenjinSubmit=o(this,"fireenjinSubmit",7),this.db=void 0,this.groupBy="week",this.unreadCount=0,this.selectedStatuses=["book","evaluate","claim","mitigate","monitor","review"],this.totals={},this.options=void 0,this.timeframe=void 0,this.showMap=!1}async onTrigger(i){var o,l,t,a,n;if("set"===(null===(o=null==i?void 0:i.detail)||void 0===o?void 0:o.name)&&"status"===(null===(t=null===(l=null==i?void 0:i.detail)||void 0===l?void 0:l.payload)||void 0===t?void 0:t.name)){this.selectedStatuses=(null===(n=null===(a=null==i?void 0:i.detail)||void 0===a?void 0:a.payload)||void 0===n?void 0:n.value)||[];try{await this.mapEl.clearMarkers()}catch(i){console.log("Error clearing marker")}}}async onChange(i){var o,l,t,a;console.log(i),"groupBy"===(null===(o=null==i?void 0:i.target)||void 0===o?void 0:o.name)?this.groupBy=null===(l=null==i?void 0:i.target)||void 0===l?void 0:l.value:"timeframe"===(null===(t=null==i?void 0:i.target)||void 0===t?void 0:t.name)&&(this.timeframe=null===(a=null==i?void 0:i.target)||void 0===a?void 0:a.value)}filterJobsByStatus(i,o){return i.filter((i=>o.includes(null==i?void 0:i.status)))}getActivityFeed(){var i;a.feedFetchData={myFeed:null===(i=null==a?void 0:a.session)||void 0===i?void 0:i.uid}}async componentDidLoad(){(null==l?void 0:l.isBrowser)&&(this.options=await this.db.list("/totals/1mFFMb6HglD2asYliHDm/jobs",null),this.getActivityFeed())}render(){var i,o;const l=this.filterJobsByStatus(Object.values((null==a?void 0:a.jobs)||{}).filter((i=>{var o,l,t;return null===(l=null===(o=null==i?void 0:i.userIds)||void 0===o?void 0:o.includes)||void 0===l?void 0:l.call(o,null===(t=null==a?void 0:a.session)||void 0===t?void 0:t.uid)})),this.selectedStatuses);return[t("ion-content",{class:"truck-background ion-padding"},d()&&e()&&t("div",{id:"performance"},t("floodteam-total-graph",{groupBy:this.groupBy,totallerId:"1mFFMb6HglD2asYliHDm"}),t("floodteam-totaller-card-list",{groupBy:this.groupBy,totallerIds:["1mFFMb6HglD2asYliHDm"]})),t("article",{id:"myjobs"},this.showMap&&t("fireenjin-map",{googleMapsKey:null===(o=null===(i=null==a?void 0:a.config)||void 0===i?void 0:i.firebase)||void 0===o?void 0:o.apiKey,ref:i=>this.mapEl=i,markers:l.map((i=>{var o,l;return{payload:{job:i},name:null==i?void 0:i.title,icon:null,position:{lat:null===(o=null==i?void 0:i.address)||void 0===o?void 0:o.lat,lng:null===(l=null==i?void 0:i.address)||void 0===l?void 0:l.lng}}}))}),t("floodteam-title-bar",null,t("ion-router-link",{href:"/jobs"},"My Jobs"," ",t("ion-badge",{style:{borderRadius:"15px"}},t("small",null,l.length||0))),t("ion-buttons",{slot:"end"},t("ion-button",{onClick:()=>this.showMap=!this.showMap,style:{"--color":"rgba(var(--ion-text-color-rgb), 0.5)"},fill:"outline",size:"small"},"Map",t("ion-icon",{slot:"end",name:"map"})),t("ion-button",{style:{"--color":"rgba(var(--ion-text-color-rgb), 0.5)"},onClick:i=>this.fireenjinTrigger.emit({event:i,name:"filter",type:"status",payload:{control:{name:"status",label:"Status",icon:"help-circle",multiple:!0,options:n(),value:this.selectedStatuses}}}),fill:"outline",size:"small"},"Filter",t("ion-icon",{slot:"end",name:"funnel"})))),t("ion-card",{class:"list-card"},t("ion-list",null,l.map((i=>t("floodteam-item-job",{job:i}))))))),t("floodteam-navigation-footer",null)]}};s.style="app-dashboard floodteam-activity-feed .feed-header h3{color:#fff}app-dashboard fireenjin-map{background:var(--ion-color-light-shade);border-radius:15px;display:block;margin:20px auto 0;overflow:hidden;max-width:calc(100% - 30px)}app-dashboard h1 a{padding:0}app-dashboard ion-grid{margin-top:0;padding-top:0}app-dashboard .title-divider{display:flex;justify-content:space-between;align-items:baseline}app-dashboard .title-divider>span{display:flex;align-items:baseline;padding-inline-end:5px;margin-top:auto}app-dashboard .title-divider>span>ion-button{margin-right:5px}";export{s as app_dashboard}