import{n as e}from"./options-CDt8ZGCW.js";function t({$el:t,attributeType:n,open:r}){t.hasClass(`aa-input`)||(t.autocomplete({appendTo:document.querySelector(`body`),hint:!1,openOnFocus:!0,minLength:0,tabAutocomplete:!1},[{displayKey:`name`,cache:!1,source:async(t,r)=>{let i=typeof n==`function`?n():n;r((await e.get(`attribute-names/?type=${i}&query=${encodeURIComponent(t)}`)).map(e=>({name:e})))}}]),t.on(`autocomplete:opened`,()=>{t.attr(`readonly`)&&t.autocomplete(`close`)})),r&&t.autocomplete(`open`)}async function n({$el:t,open:n,nameCallback:r}){t.hasClass(`aa-input`)&&t.autocomplete(`destroy`);let i=``;if(r&&(i=r()),i.trim()===``)return;let a=(await e.get(`attribute-values/${encodeURIComponent(i)}`)).map(e=>({value:e}));a.length!==0&&(t.autocomplete({appendTo:document.querySelector(`body`),hint:!1,openOnFocus:!1,minLength:0,tabAutocomplete:!1},[{displayKey:`value`,cache:!1,source:async function(e,t){e=e.toLowerCase(),t(a.filter(t=>t.value.toLowerCase().includes(e)))}}]),t.on(`autocomplete:opened`,()=>{t.attr(`readonly`)&&t.autocomplete(`close`)}),n&&t.autocomplete(`open`))}var r={initAttributeNameAutocomplete:t,initLabelValueAutocomplete:n};export{r as t};