import{a as t,aC as P,K as a1,Q as K,Y as x,A as S,l as c1,eo as s1,ep as l1,eq as f1,cm as u1,er as i1,q as m1,es as H,et as G,eu as B,y as U,ev as F,a8 as p1,ew as _1,ex as g1,I as h1,cU as R,o as d1,ey as w1}from"./app.B46ok1sD.js";function v1({description:o,matchedSubstrings:p}){return p.reduce((l,{length:r,offset:s},_,w)=>{const g=s,f=s+r,v=_===0?0:w[_-1].offset+w[_-1].length,z=_===w.length-1;return t("span",{"aria-label":o,children:[l,v===g?null:t(P,{color:"subdued",children:o.substring(v,g)}),g===f?null:t(P,{type:"mark",children:o.substring(g,f)}),z?t(P,{color:"subdued",children:o.substring(f)}):null]})},t(a1,{}))}var m={Autocomplete:"_1tnwc9f1 _1tnwc9f0 _1fragemaf _1fragem9v _1fragemaz _1fragem9b _1fragemuu _1fragemoe",backgroundColorVariant:{base:"_1tnwc9fh _1tnwc9ff _1fragemov",transparent:"_1tnwc9fi _1tnwc9fg _1fragemou"},colorSchemeVariant:{inherit:"_1tnwc9f8",scheme1:"_1tnwc9f9 _1tnwc9f2 _1fragemoo",scheme2:"_1tnwc9fa _1tnwc9f3 _1fragemop",scheme3:"_1tnwc9fb _1tnwc9f4 _1fragemoq",scheme4:"_1tnwc9fc _1tnwc9f5 _1fragemor",scheme5:"_1tnwc9fd _1tnwc9f6 _1fragemos",scheme6:"_1tnwc9fe _1tnwc9f7 _1fragemot"},Header:"_1tnwc9fk _1tnwc9fj _1fragemfz _1fragemhs _1frageme6 _1fragemjl _1fragem3c _1fragemns _1fragem82",Title:"_1tnwc9fm _1tnwc9fl _1fragempf _1fragemt9",Close:"_1tnwc9fo _1tnwc9fn _1fragemfz _1fragemhs _1frageme6 _1fragemjl",Options:"_1tnwc9fq _1tnwc9fp _1fragemh3 _1fragemiw _1fragemfa _1fragemkp _1fragemt9",Option:"_1tnwc9fs _1tnwc9fr _1fragemfz _1fragemhs _1frageme6 _1fragemjl _1fragemp4",optionVariant:{selected:"_1tnwc9fu _1tnwc9ft _1fragemtr"},Footer:"_1tnwc9fw _1tnwc9fv _1fragemfz _1fragemhs _1frageme6 _1fragemjl _1fragemn2 _1fragemuy"};const b1=u1("Autocomplete");function z1({id:o,onInput:p,onChange:l,options:r,onSelectOption:s,value:_,optionsCloseLabel:w,optionsHeaderLabel:g,children:f,autocomplete:v,onBlur:z,...$}){const[a,k]=x(!1),[b,A]=x(),[V,q]=x(!1),[L,N]=x(!1),n=S(null),O=S(null),E=S(null),{control:{background:y="base"}}=c1(),T=s1(),{parent:I}=l1(),u=f1(o,b1),h=i1(),i=()=>{if(q(!0),r.length===0){k(!1);return}a||n.current==null||!F(n.current)||(A(void 0),k(!0))},C=()=>{if(a){z?.();return}r.length===0&&N(!1),z?.(),q(!1)},d=m1(()=>{a&&k(!1)},[a]),J=e=>{e===""?d():i(),p?.(e)},X=e=>{A(e)},Z=e=>{d(),s&&s(r[e])},j=e=>{a&&A(c=>c===void 0?e>0?0:r.length-1:c+e>=r.length?0:c+e<0?r.length-1:c+e)},e1=e=>{switch(e.key){case"ArrowDown":case"Down":e.preventDefault(),j(1),i();break;case"ArrowUp":case"Up":e.preventDefault(),j(-1),i();break;case"Enter":a?(e.preventDefault(),d(),s&&b!=null&&s(r[b])):l?.(e.currentTarget.value);break;case"Escape":case"Esc":a&&(e.stopPropagation(),d());break;case"Tab":d();break}},t1=H.map(f,e=>{if(G(e)&&e.type===Q)return B(e,{id:`${u}-options`},H.toArray(e.props.children).map((c,M)=>{if(typeof c=="object"&&"type"in c&&c.type===W)return B(c,{id:`${u}-option-${M}`,isSelected:b===M,onMouseDown:()=>{Z(M),n.current?.focus()},onMouseOver:()=>X(M)})}))});U(()=>{const e=c=>{c.target instanceof Node&&!n.current?.contains(c.target)&&!E.current?.contains(c.target)?d():c.target!==n.current&&n.current?.focus()};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}},[d]),U(()=>{r.length===0?(a&&n.current&&!F(n.current)&&n.current.focus(),d()):(!a&&n.current&&F(n.current)&&i(),N(!0)),A(void 0)},[r]);const n1=H.map(f,e=>{if(G(e)&&e.type===Y)return e}),r1=!!(n.current&&F(n.current)),D=a&&r.length>0&&r1,o1=K(m.Autocomplete,m.backgroundColorVariant[y],I&&m.colorSchemeVariant[I]);return U(()=>{if(V&&L)return p1({content:T("autocompleteOptionsAvailable",{count:r.length})})},[V,r.length,L,T]),t("div",{ref:O,children:[t(_1,{...$,ariaActiveDescendant:a&&b!==void 0?`${u}-option-${b}`:void 0,ariaAutocomplete:"list",ariaControls:D?`${u}-options`:void 0,ariaOwns:D?`${u}-options`:void 0,ariaExpanded:D,ariaHasPopup:"listbox",autoCorrect:"off",autocomplete:!(a||V)&&v?v:"none",id:u,onInput:J,onChange:l,onFocus:i,onBlur:C,onKeyDown:e1,ref:n,role:"combobox",controlledValue:_}),D&&t(g1,{activator:O.current,sameInlineSize:!0,minInlineSize:320,preventOverflow:!0,positionArea:"block-end",offset:7,children:t("div",{className:o1,ref:E,"aria-labelledby":`${u}-autocomplete-title`,children:[t("div",{className:m.Header,children:[t("h3",{className:m.Title,id:`${u}-autocomplete-title`,children:g}),t("button",{type:"button",className:m.Close,onClick:()=>{d(),n.current?.focus()},tabIndex:h?-1:void 0,"aria-label":w,children:t(h1,{size:"small",type:"x"})})]}),t1,n1]})})]})}function Q({children:o,id:p}){return t("ul",{className:m.Options,id:p,onMouseDown:l=>{l.preventDefault()},role:"listbox",children:o})}function W({children:o,id:p,isSelected:l,onMouseDown:r,onMouseOver:s}){return t("li",{"aria-selected":l,className:K(m.Option,{[m.optionVariant.selected]:l}),id:p,onMouseDown:r,onMouseOver:s,role:"option",children:o})}function Y({children:o}){return t("div",{className:m.Footer,children:o})}const A1=o=>R("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 116 15",...o},R("path",{d:"M4.025 3.572c1.612 0 2.655 1.283 2.655 3.27 0 1.974-1.05 3.27-2.655 3.27-.902 0-1.63-.393-1.974-1.06h-.09v3.057H.95V3.68h.96v1.054h.094c.404-.726 1.16-1.166 2.02-1.166zm-.24 5.63c1.16 0 1.852-.884 1.852-2.36 0-1.477-.692-2.362-1.846-2.362-1.14 0-1.86.91-1.86 2.362 0 1.447.72 2.36 1.858 2.36zm7.072.91c-1.798 0-2.912-1.243-2.912-3.27 0-2.033 1.114-3.27 2.912-3.27 1.8 0 2.913 1.237 2.913 3.27 0 2.027-1.114 3.27-2.913 3.27m0-.91c1.196 0 1.87-.866 1.87-2.36 0-1.5-.674-2.362-1.87-2.362-1.195 0-1.87.862-1.87 2.362 0 1.494.675 2.36 1.87 2.36m12.206-5.518H22.05l-1.244 5.05h-.094L19.3 3.684h-.966l-1.412 5.05h-.094l-1.242-5.05h-1.02L16.336 10h1.02l1.406-4.887h.093L20.268 10h1.025zm3.632.78c-1.008 0-1.71.737-1.787 1.856h3.48c-.023-1.12-.69-1.857-1.693-1.857zm1.664 3.9h1.004c-.305 1.085-1.277 1.747-2.66 1.747-1.752 0-2.848-1.26-2.848-3.26 0-1.986 1.113-3.275 2.847-3.275 1.705 0 2.742 1.213 2.742 3.176v.387h-4.542v.047c.053 1.248.75 2.04 1.822 2.04.815 0 1.366-.3 1.63-.857zM31.03 10h1.01V6.086c0-.89.696-1.535 1.657-1.535.2 0 .563.04.645.06V3.6c-.13-.018-.34-.03-.504-.03-.838 0-1.565.434-1.752 1.05h-.094v-.938h-.96V10zm6.915-5.537c-1.008 0-1.71.738-1.787 1.857h3.48c-.023-1.12-.69-1.857-1.693-1.857m1.664 3.902h1.004c-.304 1.084-1.277 1.746-2.66 1.746-1.752 0-2.848-1.26-2.848-3.26 0-1.986 1.113-3.275 2.847-3.275 1.705 0 2.742 1.213 2.742 3.176v.387h-4.542v.047c.053 1.248.75 2.04 1.822 2.04.815 0 1.366-.3 1.63-.857zm5.01 1.746c-1.62 0-2.658-1.28-2.658-3.265 0-1.98 1.05-3.27 2.654-3.27.878 0 1.622.416 1.98 1.108h.087V1.177h1.008V10h-.96V8.992h-.093c-.4.703-1.15 1.12-2.02 1.12zm.23-5.63c-1.15 0-1.845.89-1.845 2.365s.69 2.36 1.846 2.36c1.15 0 1.858-.9 1.858-2.36 0-1.447-.715-2.362-1.857-2.362zm7.876-3.114h1.024V4.49q.346-.45.827-.69.48-.239 1.043-.237 1.172.001 1.9.806c.49.536.73 1.33.73 2.375q0 1.489-.72 2.473t-1.997.984q-.715 0-1.207-.344-.293-.206-.627-.657v.8h-.97V1.364zm4.02 7.225q.426-.679.426-1.793 0-.99-.425-1.64t-1.25-.65q-.719 0-1.264.532-.541.532-.542 1.757.001.885.224 1.435.416 1.04 1.553 1.04.856 0 1.28-.68zM63.4 3.727h1.167q-.222.603-.99 2.754a145 145 0 0 1-.96 2.635q-.915 2.402-1.29 2.93-.375.526-1.29.527-.221 0-.342-.017a3 3 0 0 1-.296-.065v-.96q.273.074.4.093.119.018.214.018.292 0 .43-.093a.9.9 0 0 0 .232-.237q.03-.05.21-.48.183-.436.264-.646l-2.32-6.457h1.196l1.68 5.11 1.694-5.11zm10.594 1.556V6.87h3.814c-.117.89-.416 1.54-.87 1.998-.557.555-1.427 1.16-2.944 1.16-2.35 0-4.184-1.882-4.184-4.217 0-2.33 1.835-4.214 4.184-4.214a4.07 4.07 0 0 1 2.873 1.135l1.122-1.116C77.04.697 75.77 0 73.99 0c-3.218 0-5.923 2.606-5.923 5.805 0 3.2 2.705 5.804 5.923 5.804 1.738 0 3.048-.57 4.073-1.63 1.05-1.044 1.382-2.52 1.382-3.71 0-.365-.028-.707-.087-.99h-5.37zm10.222-1.29c-2.082 0-3.78 1.574-3.78 3.748 0 2.154 1.698 3.747 3.78 3.747S87.998 9.9 87.998 7.74c0-2.174-1.7-3.748-3.782-3.748zm0 6.018c-1.14 0-2.127-.935-2.127-2.27 0-1.348.982-2.27 2.123-2.27s2.128.922 2.128 2.27c0 1.335-.985 2.27-2.127 2.27zm18.54-5.18h-.06c-.37-.438-1.083-.838-1.985-.838-1.88 0-3.52 1.632-3.52 3.748 0 2.102 1.64 3.747 3.52 3.747.906 0 1.62-.4 1.99-.852h.06v.523c0 1.432-.774 2.2-2.013 2.2-1.012 0-1.64-.723-1.9-1.336l-1.44.593c.414.994 1.51 2.213 3.34 2.213 1.94 0 3.58-1.135 3.58-3.902v-6.74h-1.57v.645zm-1.9 5.18c-1.144 0-2.013-.968-2.013-2.27 0-1.323.87-2.27 2.01-2.27 1.13 0 2.012.967 2.012 2.282.006 1.31-.882 2.258-2.01 2.258zM92.65 3.992c-2.084 0-3.783 1.574-3.783 3.748 0 2.154 1.7 3.747 3.782 3.747 2.08 0 3.78-1.587 3.78-3.747 0-2.174-1.7-3.748-3.78-3.748zm0 6.018c-1.143 0-2.13-.935-2.13-2.27 0-1.348.987-2.27 2.13-2.27 1.14 0 2.126.922 2.126 2.27 0 1.335-.986 2.27-2.127 2.27zM105.622.155h1.628v11.332h-1.628m6.655-1.477c-.843 0-1.44-.38-1.83-1.135l5.04-2.07-.168-.426c-.315-.84-1.275-2.39-3.228-2.39-1.94 0-3.554 1.515-3.554 3.75 0 2.1 1.595 3.744 3.736 3.744 1.725 0 2.724-1.05 3.14-1.658l-1.285-.852c-.428.62-1.01 1.032-1.855 1.032zm-.117-4.612c.668 0 1.24.342 1.427.826l-3.405 1.4c0-1.574 1.122-2.226 1.978-2.226"})),O1="Llh19",y1={GoogleAttribution:O1},C1="autocomplete-service";function V1({error:o,label:p="",autoFocus:l,name:r,field:s,onChange:_,onInput:w,onSelect:g,value:f,required:v,autocomplete:z,disabled:$,readOnly:a,countryCode:k,addressType:b,onBlur:A,id:V=r,allowAllCountries:q,disableAdditionalFields:L=!0,...N}){const n=d1(),{value:O,setValue:E,predictions:y,selectPrediction:T,provider:I}=w1({addressType:b,countryCode:k,field:s,initialAddressQuery:f,allowAllCountries:q});function u({addressId:h,completionService:i}){T(h,i,L,C=>{E(C[s]??"",!1),g&&g(C,h,i)})}return t(z1,{error:o,id:V,label:p,name:r,onInput:h=>{E(h),w?.(h)},onChange:_,onSelectOption:u,options:y,value:O,autoFocus:l,required:v,autocomplete:z,optionsHeaderLabel:n("general.autocomplete_title"),optionsCloseLabel:n("general.autocomplete_close"),disabled:$,readOnly:a,...N,onBlur:()=>{f!==void 0&&O!==f&&_?.(O),A?.()},children:[t(Q,{children:y.map(({addressId:h,description:i,matchedSubstrings:C})=>t(W,{children:t(v1,{description:i,matchedSubstrings:C})},h))}),I&&I===C1&&y.length>0&&y[0].completionService==="GOOGLE_PLACE_AUTOCOMPLETE"?t(Y,{children:t(A1,{className:y1.GoogleAttribution,"aria-label":n("general.autocomplete_powered_by_google",{brandName:n("brand.google")})})}):null]})}export{V1 as default};