import{r as i,d as t,B as s,h as o,H as n,e}from"./p-f8363b1b.js";import{G as a}from"./p-d5534cd3.js";import{L as l}from"./p-29d0604b.js";import"./p-f13bd533.js";import"./p-bf71b10e.js";const r=class{constructor(s){i(this,s),this.fireenjinTrigger=t(this,"fireenjinTrigger",7),this.mapMarkers=[],this.options={},this.visible=!0,this.markers=[],this.isVisible=!0}async addMarker(i){var t;this.google||(this.google=(null===(t=null===window||void 0===window?void 0:window.google)||void 0===t?void 0:t.maps)?window.google:await this.loadGoogleMaps());const s="string"==typeof i?JSON.parse(i):i,o=new this.google.maps.Marker({position:s.position,map:this.map,title:(null==s?void 0:s.name)||"",icon:(null==s?void 0:s.icon)?{url:s.icon,origin:new this.google.maps.Point(0,0),anchor:new this.google.maps.Point(15,15),scaledSize:new this.google.maps.Size(34,34),shape:{coords:[17,17,18],type:"circle"},optimized:!1}:null});return o.addListener("click",(()=>{this.onMarkerClick(o,s)})),this.mapMarkers.push(o),o}async updateMarkers(){return await this.clearMarkers(),this.markers.length>=1&&this.markers.map(this.addMarker.bind(this)),this.markers}async setMarkers(i=[]){return this.markers=i,await this.clearMarkers(),this.markers.length>=1&&this.markers.map(this.addMarker.bind(this)),this.markers}async setZoom(i){return this.map.setZoom(i)}async setCenter(i){return this.map.setCenter(i)}async clearMarkers(){var i;for(let t=0;t<this.mapMarkers.length;t++)(null===(i=this.mapMarkers[t])||void 0===i?void 0:i.setMap)&&this.mapMarkers[t].setMap(null);return this.mapMarkers=[],!0}onMarkerClick(i,t){this.map.setZoom(12),this.map.setCenter(i.getPosition()),this.fireenjinTrigger.emit({name:"markerClick",payload:{marker:i,location:t}})}getLocationCoords(i){try{a.getCurrentPosition().then((t=>{i&&"function"==typeof i&&i(t.coords)})).catch((async()=>{fetch("http://ip-api.com/json").then((async t=>{const s=await t.json();i({latitude:s.lat,longitude:s.lon})})),i&&"function"==typeof i&&i(!1)}))}catch(t){i(!1)}}async createMap(i){var t;this.google||(this.google=(null===(t=null===window||void 0===window?void 0:window.google)||void 0===t?void 0:t.maps)?window.google:await this.loadGoogleMaps()),this.map=new this.google.maps.Map(this.mapEl.querySelector("#map"),{zoom:9,center:{lat:i.latitude,lng:i.longitude}})}async loadGoogleMaps(i){return new l(this.googleMapsKey,i||{}).load()}async componentDidLoad(){var i;(null==s?void 0:s.isBrowser)&&(this.isVisible=this.visible,this.google=(null===(i=null===window||void 0===window?void 0:window.google)||void 0===i?void 0:i.maps)?window.google:await this.loadGoogleMaps(),setTimeout((()=>{this.getLocationCoords((async i=>{this.position=i||{latitude:38.6270025,longitude:-90.19940419999999},this.createMap(this.position),await this.setMarkers(this.markers)}))}),100))}render(){return o(n,{class:{"map-is-visible":this.isVisible}},o("div",{id:"map"}))}get mapEl(){return e(this)}static get watchers(){return{markers:["updateMarkers"]}}};r.style="fireenjin-map{position:relative;display:block}fireenjin-map #map{display:block;height:0px;width:100%;margin:0 auto;opacity:0;transition:all ease 0.5s}fireenjin-map.map-is-visible #map{height:var(--map-height, 300px);opacity:1}";const d=class{constructor(t){i(this,t),this.lines="inset"}render(){var i,t,s,n,e,a,l,r,d,h,c,v,p;return o("ion-item",{lines:this.lines,href:`/jobs/${null===(i=this.job)||void 0===i?void 0:i.id}`,detail:!0},o("fireenjin-avatar",{slot:"start",style:{display:"inline-block",position:"relative",borderRadius:"4px",padding:"0 !important",overflow:"hidden",marginRight:"10px"},initials:(null===(t=this.job)||void 0===t?void 0:t.title)?null===(s=this.job)||void 0===s?void 0:s.title.charAt(0):"",src:null===(a=null===(e=null===(n=this.job)||void 0===n?void 0:n.photos)||void 0===e?void 0:e[0])||void 0===a?void 0:a.url}),o("ion-label",{class:"ion-text-wrap",style:{position:"relative",textOverflow:"initial"}},o("h2",null,null===(l=this.job)||void 0===l?void 0:l.title),o("fireenjin-chip-bar",null,o("floodteam-select-status",{jobId:null===(r=this.job)||void 0===r?void 0:r.id,value:null===(d=this.job)||void 0===d?void 0:d.status}),o("floodteam-select-location",{disabled:!0,jobId:null===(h=this.job)||void 0===h?void 0:h.id,value:null===(v=null===(c=this.job)||void 0===c?void 0:c.location)||void 0===v?void 0:v.id}),o("ion-router-link",{onClick:i=>i.stopPropagation(),href:`/jobs/${null===(p=this.job)||void 0===p?void 0:p.id}/scope`},o("ion-chip",null,o("ion-icon",{class:"ft-icon-style",name:"list"}),o("ion-label",null,"View Scope"))))))}};export{r as fireenjin_map,d as floodteam_item_job}