1import{_ as x}from"./WnQqIRvp.js";import{aP as C,aQ as w,K as y,aR as L,a9 as f,d as O,am as B,o as d,c as g,Y as V,b,h as G,i as I,t as _,C as A,j as F,$ as k,as as N,a8 as P}from"./2kXm08UW.js";import{u as S}from"./CGusSF9L.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]}},$=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=n=>{const t=f(n._source.center)?.split(",");return{id:n._id,name:f(n._source[s]),postcode:f(n._source.postcode),bbox:n._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)},D=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:h}=y(),{context:p}=B();async function m(n){const t=n.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 n=>{try{return s.suggestionsConfig?.function?await S(s.suggestionsConfig.function,"suggestionsFunctions")(n,{...s.suggestionsConfig.args||{},searchProvider:h.tide.search.provider}):await $(n,s.suggestionsIndex,s.suggestionsKey,s.mapResultsFnName)}catch(t){P(t),console.error(t)}},u=N(async n=>{if(!n){o.value=[];return}if(typeof n!="string")return;const t=await c(n);!t||t.length===0?o.value=[]:o.value=t},300);return(n,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:b(o),showNoResults:!0,maxSuggestionsDisplayed:8,placeholder:e.placeholder,getOptionId:a=>a?.id||a?.name,getSuggestionVal:a=>a?.name||"",getOptionLabel:a=>a?.name||"",isBusy:e.isGettingLocation,isFreeText:!1,submitOnClear:!0,iconPosition:e.iconPosition,showSubmitButton:e.showSubmitButton,submitOnSuggestionOnly:e.submitOnSuggestionOnly,analyticsName:b(p).name,globalEvents:!1,onSubmit:m,"onUpdate:inputValue":b(u)},{suggestion:G(({option:{option:a}})=>[I("span",null,_(a?.name),1),e.tagsComponent?(d(),g(A(e.tagsComponent),{key:0,option:a},null,8,["option"])):a?.postcode?(d(),g(r,{key:1,label:a?.postcode,variant:"dark",class:"rpl-u-margin-l-3"},null,8,["label"])):a?.tag?(d(),g(r,{key:2,label:a?.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(D,{__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.