PageSourceSearch

https://www.immonetzwerk.de/_astro/HeroSearch.astro_astro_type_script_index_0_lang.DmyrR9jG.js

js immonetzwerk.de collected 2026-10-09 01:15:40 UTC 5,829 bytes, 1 lines download raw bytes

1var e={south:47.270111,west:5.866342,north:55.05814,east:15.041896},t=3,n=class extends HTMLElement{input;list;form;items=[];active=-1;session=null;auto=null;places=null;geocoder=null;mapsPromise=null;debounce=0;lastQuery=``;mapsFailed=!1;connectedCallback(){this.input=this.querySelector(`#immosuche_adresse`),this.list=this.querySelector(`[role="listbox"]`),this.form=this.querySelector(`form`);let e=()=>this.loadMaps();this.input.addEventListener(`focus`,e,{once:!0}),this.input.addEventListener(`pointerenter`,e,{once:!0}),this.input.addEventListener(`input`,()=>this.onInput()),this.input.addEventListener(`keydown`,e=>this.onKey(e)),this.input.addEventListener(`blur`,()=>setTimeout(()=>this.close(),120)),this.list.addEventListener(`mousedown`,e=>e.preventDefault()),this.list.addEventListener(`click`,e=>{let t=e.target.closest(`li`);t&&this.select(Number(t.dataset.i))}),this.form.addEventListener(`submit`,e=>this.onSubmit(e))}loadMaps(){return window.gm_authFailure||(window.gm_authFailure=()=>{this.mapsFailed=!0}),window.google?.maps?.places?Promise.resolve():(this.mapsPromise||=new Promise((e,t)=>{let n=`immoMaps_${Math.random().toString(36).slice(2)}`;window[n]=()=>{delete window[n],e()};let r=document.createElement(`script`);r.src=`https://maps.googleapis.com/maps/api/js?`+new URLSearchParams({key:this.dataset.mapsKey,libraries:`places`,language:`de`,region:`DE`,callback:n,loading:`async`}),r.async=!0,r.onerror=()=>t(Error(`Google Maps konnte nicht geladen werden.`)),document.head.appendChild(r)}),this.mapsPromise)}ensure(){let e=window.google;this.auto||=new e.maps.places.AutocompleteService,this.places||=new e.maps.places.PlacesService(document.createElement(`div`)),this.geocoder||=new e.maps.Geocoder,this.session||=new e.maps.places.AutocompleteSessionToken}field(e){return this.querySelector(`#${e}`)}fill(e){this.field(`plz`).value=e.postalCode??``,this.field(`ort`).value=e.city??``,this.field(`lat`).value=e.lat??``,this.field(`lng`).value=e.lng??``}onInput(){this.fill({});let e=this.input.value.trim();if(clearTimeout(this.debounce),e.length<2){this.items=[],this.render();return}this.debounce=window.setTimeout(()=>this.predict(e),140)}async predict(n){try{await this.loadMaps()}catch{return}this.ensure();let r=window.google;this.lastQuery=n,this.auto.getPlacePredictions({input:n,sessionToken:this.session,componentRestrictions:{country:[`DE`]},locationRestriction:new r.maps.LatLngBounds(new r.maps.LatLng(e.south,e.west),new r.maps.LatLng(e.north,e.east))},(e,n)=>{if(this.input.value.trim()===this.lastQuery){if(n!==r.maps.places.PlacesServiceStatus.OK||!Array.isArray(e)){this.items=[],this.render();return}this.items=e.filter(e=>{let t=e.types||[];return t.includes(`establishment`)||t.includes(`plus_code`)?!1:[`street_address`,`route`,`intersection`,`geocode`,`premise`,`subpremise`,`postal_code`,`locality`,`sublocality`].some(e=>t.includes(e))}).slice(0,t),this.active=-1,this.render()}})}render(){this.list.innerHTML=``,this.items.forEach((e,t)=>{let n=document.createElement(`li`);n.id=`immosuche-opt-${t}`,n.setAttribute(`role`,`option`),n.dataset.i=String(t),n.setAttribute(`aria-selected`,String(t===this.active));let r=document.createElement(`span`);r.textContent=e.structured_formatting?.main_text||e.description,n.appendChild(r);let i=e.structured_formatting?.secondary_text;if(i){let e=document.createElement(`span`);e.className=`sub`,e.textContent=i,n.appendChild(e)}this.list.appendChild(n)});let e=this.items.length>0;this.list.hidden=!e,this.input.setAttribute(`aria-expanded`,String(e)),this.active>=0?this.input.setAttribute(`aria-activedescendant`,`immosuche-opt-${this.active}`):this.input.removeAttribute(`aria-activedescendant`)}close(){this.items=[],this.render()}onKey(e){if(!this.list.hidden){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=this.items.length;this.active=e.key===`ArrowDown`?(this.active+1)%t:(this.active-1+t)%t,this.render()}else e.key===`Enter`&&this.items.length?(e.preventDefault(),this.select(this.active>=0?this.active:0)):e.key===`Escape`&&this.close()}}normalizeResult(e){let t={formattedAddress:e.formatted_address||``,postalCode:``,city:``,lat:``,lng:``};for(let n of e.address_components||[]){let e=n.types||[];e.includes(`locality`)&&(t.city=n.long_name),!t.city&&e.includes(`postal_town`)&&(t.city=n.long_name),!t.city&&e.includes(`administrative_area_level_3`)&&(t.city=n.long_name),e.includes(`postal_code`)&&(t.postalCode=n.long_name)}let n=e.geometry?.location;if(n)try{t.lat=String(n.lat()),t.lng=String(n.lng())}catch{}return t}select(e){let t=this.items[e];if(!t?.place_id)return;this.ensure();let n=window.google;this.places.getDetails({placeId:t.place_id,fields:[`address_components`,`formatted_address`,`geometry`],sessionToken:this.session},(e,t)=>{if(t!==n.maps.places.PlacesServiceStatus.OK||!e)return;let r=this.normalizeResult(e);this.input.value=r.formattedAddress||this.input.value,this.fill(r),this.session=new n.maps.places.AutocompleteSessionToken,this.close()})}onSubmit(e){let t=this.form.querySelector(`[type="submit"]`);if(t?.dataset.wait){let e=t.querySelector(`span`);e&&(e.textContent=t.dataset.wait)}if(this.field(`lat`).value&&this.field(`lng`).value)return;let n=this.input.value.trim();if(!n)return;e.preventDefault();let r=!1,i=()=>{r||(r=!0,HTMLFormElement.prototype.submit.call(this.form))},a=window.setTimeout(i,2e3);if(window.gm_authFailure=()=>{this.mapsFailed=!0,clearTimeout(a),i()},this.mapsFailed){clearTimeout(a),i();return}this.loadMaps().then(()=>{this.ensure(),this.geocoder.geocode({address:n,region:`DE`,componentRestrictions:{country:`DE`}},(e,t)=>{!r&&t===`OK`&&e?.length&&this.fill(this.normalizeResult(e[0])),clearTimeout(a),i()})}).catch(()=>{clearTimeout(a),i()})}};
1customElements.get(`immo-place-search`)||customElements.define(`immo-place-search`,n);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.