PageSourceSearch

https://www.steiner-vision.de/assets/PlaceAutocomplete-BZKcesVU.js

js steiner-vision.de collected 2026-10-09 22:03:29 UTC 4,942 bytes, 1 lines download raw bytes

1import{r as s,j as a,H as S}from"./index-DtDhvT43.js";import{i as V}from"./PostcodeAutocomplete-7UKIFbMm.js";import{L as q}from"./loader-circle-UfKg_N9a.js";import{M as K}from"./map-pin-CDngzD20.js";const U="/__l5e/assets-v1/3f0cc81b-b0c9-43fc-990e-6e6a83a52a85/easyfit-glasses.jpg",W={url:U};let k=null;async function B(){return k||(k=(await S(async()=>{const{default:p}=await import("./plz-de-Bkm26iYC.js");return{default:p}},[])).default),k}async function Z(p,f){const w=await B(),_=Math.cos(p*Math.PI/180),g=Object.entries(w).map(([n,[c,x]])=>[n,(c-p)**2+((x-f)*_)**2]).sort((n,c)=>n[1]-c[1]).slice(0,12).map(([n])=>n);g.sort((n,c)=>Number(/9\d$/.test(n))-Number(/9\d$/.test(c)));for(const n of g)try{if((await(await fetch(`/api/postcode/suggest?q=${n}`)).json()).suggestions?.some(E=>E.postal_code===n))return n}catch{break}return g[0]??null}function X({id:p,value:f,onChange:w,onResolved:_,onSubmit:g,onStatus:n,placeholder:c="PLZ oder Ort",inputClassName:x="h-12 w-full bg-transparent text-lg outline-none",className:E=""}){const[u,j]=s.useState([]),[l,d]=s.useState(!1),[L,v]=s.useState(!1),[$,N]=s.useState(-1),[P,R]=s.useState(!1),[H,I]=s.useState(!0),[T,O]=s.useState(260),b=s.useRef(!1),z=s.useRef(null),M=s.useRef(null),A=s.useRef(n);A.current=n,s.useEffect(()=>{A.current?.(L?"loading":l?"open":P?"nohits":"idle")},[L,l,P]),s.useEffect(()=>{if(!l)return;const e=()=>{const i=M.current;if(!i)return;const o=i.getBoundingClientRect(),r=window.visualViewport,y=(r?r.height+r.offsetTop:window.innerHeight)-o.bottom,h=o.top-(r?.offsetTop??0),D=y>=200||y>=h;I(D),O(Math.max(140,Math.min(260,(D?y:h)-12)))};e();const t=window.visualViewport;return t?.addEventListener("resize",e),t?.addEventListener("scroll",e),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{t?.removeEventListener("resize",e),t?.removeEventListener("scroll",e),window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[l,u.length]),s.useEffect(()=>{if(b.current){b.current=!1;return}if(R(!1),!V(f)){j([]),d(!1);return}let e=!1;v(!0);const t=setTimeout(async()=>{try{const o=await(await fetch(`/api/postcode/suggest?mode=place&q=${encodeURIComponent(f.trim())}`)).json();if(e)return;const r=Array.isArray(o.suggestions)?o.suggestions:[];j(r),N(-1),d(r.length>0);const m=f.trim();R(r.length===0&&m.length>=3&&!/^\d{4,5}$/.test(m))}catch{e||d(!1)}finally{e||v(!1)}},250);return()=>{e=!0,clearTimeout(t)}},[f]),s.useEffect(()=>{const e=t=>{z.current?.contains(t.target)||d(!1)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[]);async function C(e){b.current=!0,d(!1),j([]),v(!0);let t,i;try{const h=await(await fetch(`/api/postcode/details?id=${encodeURIComponent(e.public_id)}`)).json();t=h.location?.lat,i=h.location?.lng}catch{}let o=e.postal_code;!o&&typeof t=="number"&&typeof i=="number"&&(o=await Z(t,i)??""),v(!1);const r=e.label.split(",")[0]?.trim()??e.label,m=o?e.kind==="postal_code"?`${o} ${e.label.split(",")[0]??""}`.trim():`${o} ${r}`:r;b.current=!0,w(m),o&&_({postalCode:o,lat:t,lng:i,label:m})}return a.jsxs("div",{ref:z,className:`relative ${E}`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{id:p,ref:M,type:"text",autoComplete:"off",enterKeyHint:"search",value:f,placeholder:c,role:"combobox","aria-expanded":l,"aria-autocomplete":"list",onChange:e=>w(e.target.value.slice(0,60)),onFocus:e=>{u.length>0&&d(!0);const t=e.currentTarget;window.matchMedia?.("(pointer: coarse)").matches&&window.setTimeout(()=>t.scrollIntoView({block:"start",behavior:"smooth"}),350)},onKeyDown:e=>{e.key==="ArrowDown"&&l?(e.preventDefault(),N(t=>(t+1)%u.length)):e.key==="ArrowUp"&&l?(e.preventDefault(),N(t=>t<=0?u.length-1:t-1)):e.key==="Escape"?d(!1):e.key==="Enter"&&(e.preventDefault(),l&&u.length>0?C(u[Math.max(0,$)]):g?.())},className:`scroll-mt-24 ${x}`}),L&&a.jsx(q,{className:"h-4 w-4 flex-none animate-spin text-muted-foreground"})]}),l&&u.length>0&&a.jsx("ul",{role:"listbox",style:{maxHeight:T},className:`absolute left-0 right-0 z-[2147483000] ${H?"top-full mt-1":"bottom-full mb-1"} overflow-y-auto rounded-xl border border-medical-line bg-card text-foreground shadow-lg`,children:u.map((e,t)=>a.jsx("li",{role:"option","aria-selected":t===$,children:a.jsxs("button",{type:"button",onPointerDown:i=>i.preventDefault(),onClick:()=>{C(e)},style:{touchAction:"manipulation"},className:`flex w-full items-center gap-2 px-4 py-3 text-left text-[15px] hover:bg-medical-surface ${t===$?"bg-medical-surface":""}`,children:[a.jsx(K,{className:"h-4 w-4 flex-none text-muted-foreground","aria-hidden":!0}),a.jsxs("span",{className:"truncate",children:[e.postal_code&&a.jsx("strong",{className:"mr-1",children:e.postal_code}),e.label]})]})},e.public_id))}),P&&!l&&!n&&a.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Keinen Ort gefunden – bitte Ihre PLZ eingeben."})]})}
1export{X as P,W as e};

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.