1import{_ as x}from"./DWuQ9mkS.js";import{aP as C,aQ as w,K as y,aR as L,a7 as f,d as O,al as B,o as d,c as g,ah as V,b as h,h as G,i as I,t as _,C as A,j as F,a6 as k,ar as N,a5 as P}from"./Lekp9PjB.js";import{u as S}from"./Df-bcL9S.js";const R=async e=>{const o=(await $fetch("https://corp-geo.mapshare.vic.gov.au/arcgis/rest/services/Geocoder/VMAddressEZIAdd/GeocodeServer/findAddressCandidates",{params:{magicKey:e,f:"json"}})).candidates[0];return{id:e.slice(-12),name:C(o.address,{split:i=>i.trim().split(" ")}),center:[o.location.x,o.location.y]}},D=async(e,l=w,s="name",o)=>{const{public:i}=y(),p=`/api/tide/elasticsearch/${L(l,i.tide.search.provider)}/_search`,m={query:{bool:{should:[{match:{[s]:{query:e,operator:"and"}}},{prefix:{[s]:{value:e,case_insensitive:!0}}},{match_phrase_prefix:{[s]:{query:e,max_expansions:150}}},{term:{postcode:{value:e}}}]}}},c=await $fetch(p,{method:"POST",body:{...m,size:20}});let u=a=>{const t=f(a._source.center)?.split(",");return{id:a._id,name:f(a._source[s]),postcode:f(a._source.postcode),bbox:a._source.bbox,center:t?.length===2?[t[1],t[0]]:void 0}};if(o&&(u=S(o,"locationSuggestionMappingFunctions")),c&&c.hits.total.value>0)return c.hits.hits.map(u)},U=O({__name:"TideSearchLocationAutocomplete",props:{inputValue:{default:null},suggestionsIndex:{default:"vic-postcode-localities"},suggestionsKey:{default:"name"},label:{default:"Search by postcode or suburb"},placeholder:{default:"Enter postcode or suburb"},tagsComponent:{default:void 0},mapResultsFnName:{default:""},isGettingLocation:{type:Boolean,default:!1},userGeolocation:{default:null},suggestionsConfig:{default:void 0},showLabel:{type:Boolean,default:!0},iconPosition:{default:"left"},showSubmitButton:{type:Boolean,default:!1},submitOnSuggestionOnly:{type:Boolean,default:!0}},emits:["update"],setup(e,{emit:l}){const s=e,o=k([]),i=l,{public:b}=y(),{context:p}=B();async function m(a){const t=a.payload;if(!(t&&typeof t=="string"))if(t?.arcGISMagicKey){const r=await R(t.arcGISMagicKey);i("update",{...t,...r||{},arcGISMagicKey:void 0})}else i("update",t||null)}const c=async a=>{try{return s.suggestionsConfig?.function?await S(s.suggestionsConfig.function,"suggestionsFunctions")(a,{...s.suggestionsConfig.args||{},searchProvider:b.tide.search.provider}):await D(a,s.suggestionsIndex,s.suggestionsKey,s.mapResultsFnName)}catch(t){P(t),console.error(t)}},u=N(async a=>{if(!a){o.value=[];return}if(typeof a!="string")return;const t=await c(a);!t||t.length===0?o.value=[]:o.value=t},300);return(a,t)=>{const r=x,v=V;return d(),g(v,{id:"tide-address-lookup",inputLabel:e.label,showLabel:e.showLabel,variant:"reverse",inputValue:e.inputValue?.useGeolocation?e.userGeolocation||null:e.inputValue,suggestions:h(o),showNoResults:!0,maxSuggestionsDisplayed:8,placeholder:e.placeholder,getOptionId:n=>n?.id||n?.name,getSuggestionVal:n=>n?.name||"",getOptionLabel:n=>n?.name||"",isBusy:e.isGettingLocation,isFreeText:!1,submitOnClear:!0,iconPosition:e.iconPosition,showSubmitButton:e.showSubmitButton,submitOnSuggestionOnly:e.submitOnSuggestionOnly,analyticsName:h(p).name,globalEvents:!1,onSubmit:m,"onUpdate:inputValue":h(u)},{suggestion:G(({option:{option:n}})=>[I("span",null,_(n?.name),1),e.tagsComponent?(d(),g(A(e.tagsComponent),{key:0,option:n},null,8,["option"])):n?.postcode?(d(),g(r,{key:1,label:n?.postcode,variant:"dark",class:"rpl-u-margin-l-3"},null,8,["label"])):n?.tag?(d(),g(r,{key:2,label:n?.tag,variant:"dark",class:"rpl-u-margin-l-3"},null,8,["label"])):F("",!0)]),_:1},8,["inputLabel","showLabel","inputValue","suggestions","placeholder","getOptionId","getSuggestionVal","getOptionLabel","isBusy","iconPosition","showSubmitButton","submitOnSuggestionOnly","analyticsName","onUpdate:inputValue"])}}}),T=Object.assign(U,{__name:"TideSearchLocationAutocomplete"});export{T as default};
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.